Jump to content

Mesh impostors on 3D object like path?


ian
 Share

Recommended Posts

Hi,
 
Can you please tell me which type of impostors does Oimo.js with Babylon.js support?
I use babylon.js and oimo.js
 
I read this instructions here
 
On this page is mention that
there are 4 impostors:
1. Box
2. Sphere
3. Capsule
4. Mesh
Which of this 4 impostors are supported in oimo.js ???
Which js implement collision oimo.js or babylon.js ???
 
With Blender I did:
I create some simple path and one ball.
I set physic collisions and rigid.
Path objec has Mesh - collision (Mesh Impostor). 
In blender animations works fine.
I attach file "path_example.zip" 
 
I try "http://www.babylonjs.com/sandbox/" and load "path_example.babylon"
Babylon sendbox doesn't work as it works in blender.
 
Does Oimo.js doesn't support Mesh Impostor ?
Which file implement Impostor or collision? Do babylon.js implemennt this or oimo.js?
 
Is there any other solution to solve this.
 
I would like to rotate path object (rotate throught all axises x, y, z) at runtime in babylon game engine.
It is possible to solve this withouth Mesh-Impostor (Mesh collision shape on Path).
I don't want to have static path. I would like to rotate it and I would like to use physic on ball and path objects.
 
Is there any other possible sollution.
Can I create colider-boxes around path and join this colider-boxes to one collider-object, because I would like
to rotate all box colliders as one model at runtime (I don't want to have seperated collider-boxes and static path!)
 
Pleas help me. 
Can give me any advice or hint?
 
Thanx 
 
 
 
 

path_example.zip

Link to comment
Share on other sites

Hi Ian,

 

Implemented Impostors:

 

Oimo.js:

  • Box
  • Sphere

Cannon.js:

  • Box
  • Sphere
  • Cylinder
  • Plane
  • Hieghtmap

Oimo doesn't support more than that (a new version being developed right now should support cylinders as well. On m TODO list :) )

 

You might be able to implement a path using a few height maps (or one single square one). Or a lot of connected meshes. I haven't checked your exmaple, will do it later this evening and see if i can suggest something better.

Link to comment
Share on other sites

RaananW

Thank you for your time and advices.   
I am grateful to you for any advices. Thank you.

 

Raanan I would like to make game like

perplexus

 

So I would like to make model and one ball. I would like to make model with mash collision (and gravity). I would like to rotate model and I would like that 

mash collision stay like model also after rotation.

So oimo.js doesn't implement mesh collider (impostor). Than I can forget about mash collider (impostor). 

I think that I would make extra boxes for collisions around path, but I have problem with rotation because I can't join this boxes for collisions to be as one model.

Can join collider boxs to one collider model ???

Can you give me any advice how to solve this. Is there any other approach?

Link to comment
Share on other sites

:)  Gruesome challenge!  Hi Ian, welcome to the forum!  (that's the good news)

 

The bad news:  I don't think you will be able to accomplish a Perplexus-like game... with webGL physics or with built-in BabylonJS collision/intersect.  The systems to do that are not in-place or yet plausible.   Your idea is a good one, but there are many things that will cause problems, I think.

 

I am not an expert, so I could be wrong. 

 

Even when cylinder imposters are ready (currently, Oimo "fakes" them with a box imposter, I believe)... they won't work for physics-active ball-carrying "tubes".  The physics are active on the OUTSIDE of the cylinder, but not on the inside.

 

Allow me to demo with some spheres...

 

http://www.babylonjs-playground.com/#8KNKC#11

 

Both spheres are physics-active.  The little sphere is positioned near the center of the big sphere.  The big sphere is created special... with sideOrientation = backside (line 21).  This makes an inside-out sphere, but does not effect the big sphere imposter.  Oimo always puts its physics on the outside of its sphere imposters, no matter what configuring has been done to the mesh they represent.

 

This is why... the big sphere "spits-out" the little sphere, no matter how much little-sphere mass, or how little scene gravity.  Oimo says "Hey, these two sphere imposters are overlapping, and I MUST separate them". 

 

The little sphere will not stay inside the big sphere, no matter what you try.  POSSIBLY by doing some deep modifying to Oimo physics library, a miracle might be available.  Maybe.  Unlikely.  (Sorry).

 

BabylonJS has parametric shapes, and can create path3D-shaped tubes, but the Oimo imposters are not ready for tubes or half-pipes.  Neither are the cubical and spherical bounding boxes or the collision ellipsoids that are used in BabylonJS's built-in colliding/intersecting.  As you have stated, without mesh-shaped imposters, you are bound to try difficult track-tiling imposter methods, which will get CPU-heavy rather quickly, I would think.  I think you would be lucky to get 1/4 the speed of the real life game.

 

I sure don't want to kill your spirit.  It would be EXCELLENT to have a webGL version of Perplexus.  Unfortunately, I think it would take some deep modifications to Oimo, and likely it will be some nasty math.  But, I have been wrong before, often, so there's always hope.  :)  Physics superstars... please keep commenting.  Thx! 

Link to comment
Share on other sites

Hi Wingnut, Thenx to explan and give a sample what happend inside sphere . OK

OK , I don't need sphere or ball outside model. I can remove this for first time.

 

It will be realy good if I will have MeshImpostor !!! I would make model and put this model on scene. I would like to set MashImpostor on this my model.

 

 

Can anybody tell me if there is any MeshImpostor implemented in any physics engine (aimo or cannon or any other javascript engine ????)

I would like to use babylonjs, with some engine wich have implemented MeshImpostor. 

I think that Mash Impostor isn't implemented in aimo or cannon. Can anybody confirmed that? Or can anybody help mi find another engine with Mash Impostor which could I use it with babylonjs?

 

Or is there any other betther engin(s) for collision and physic with three.js?


Is there any other way how can I alone help myself with collision detection ( no colision, enter collision, exit collision, no collision "collision/intersect.") ???

 

 

 

I would create boxes with BoxImpostor and CAN I JOIN THIS BOXES SO THAT I GET ONE MODEL/MASH WHICH I WOULD LIKE TO ROTATE IT ???

 

Thanx

Any advices will be wellcome.

Link to comment
Share on other sites

So!

 

Commited - https://github.com/BabylonJS/Babylon.js/pull/877 . a very simple demo can be found here http://raananweber.com/physics/ . Using Jerome's ExtrudeShape :-)

 

The MeshImpostor will use this implementation from now on. It can be used on all types of meshes. The only catch - it only intersects with spheres. 

Link to comment
Share on other sites

Yep, nice stuff, R-man!  Spacebar to launch the sphere, A/D - turn ramp, i - impluse something.  Unfortunately, due to V-shaped trough, turning the ramp sends the sphere over the sides.  But still, this is a wonderful advancement because... we can now make physics-active basketball rims!  A game of horse, anyone?  :)

 

I think this also allows us to do the launcher trough and curved top for pinball games, too.  YAY!

 

How about the Wall of Death?  Put some axles through your balls, and away you go!  heh

 

Anyone remember a game called Rocketball?  Fun!

Link to comment
Share on other sites

I imported this  model and set cannon's Mesh Impostor to model and Sphere Impostor to ball.

 

Can anyone check this? Did I forget anything? What sould I fix?

 

zip file is attached.

 

 

I get this errors: Ball fall through model (with mash impostor)

 id=Path name=Path
cannon.js:7956 .faceNormals[1] = Vec3(0.16870330525583,0.014404743673082917,0.9855616156057779) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.ConvexPolyhedron.computeNormals @ cannon.js:7956ConvexPolyhedron @ cannon.js:7872t._createConvexPolyhedron @ babylon.js:19t._createShape @ babylon.js:19t.registerMesh @ babylon.js:19t._registerMesh @ babylon.js:15i.setPhysicsState @ babylon.js:5(anonymous function) @ Perplexus.html:156f @ babylon.js:13(anonymous function) @ babylon.js:13e.onreadystatechange @ babylon.js:3
cannon.js:7958 .vertices[3] = Vec3(10.167623343801498,-0.24123703869283197,-1.7518913696408271)
cannon.js:7958 .vertices[5] = Vec3(9.496039395439624,-0.1613202791258693,-1.6381011716127396)
cannon.js:7958 .vertices[4] = Vec3(9.49508403545618,-0.22950322875641285,-1.636941091632843)
cannon.js:7956 .faceNormals[4] = Vec3(0.01345949339645171,0.9997747850362828,-0.016407962797544487) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.ConvexPolyhedron.computeNormals @ cannon.js:7956ConvexPolyhedron @ cannon.js:7872t._createConvexPolyhedron @ babylon.js:19t._createShape @ babylon.js:19t.registerMesh @ babylon.js:19t._registerMesh @ babylon.js:15i.setPhysicsState @ babylon.js:5(anonymous function) @ Perplexus.html:156f @ babylon.js:13(anonymous function) @ babylon.js:13e.onreadystatechange @ babylon.js:3
cannon.js:7958 .vertices[10] = Vec3(10.168578703784942,-0.17305408906228842,-1.7531196896195411)
cannon.js:7958 .vertices[11] = Vec3(10.362107340431212,-0.18833429897949097,-2.525425876235962)
cannon.js:7958 .vertices[9] = Vec3(10.03059742617607,-0.18255093901082872,-2.4449709176301955)
cannon.js:7956 .faceNormals[5] = Vec3(0.013175992894354005,0.9997586951970423,-0.01757681965417143) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.ConvexPolyhedron.computeNormals @ cannon.js:7956ConvexPolyhedron @ cannon.js:7872t._createConvexPolyhedron @ babylon.js:19t._createShape @ babylon.js:19t.registerMesh @ babylon.js:19t._registerMesh @ babylon.js:15i.setPhysicsState @ babylon.js:5(anonymous function) @ Perplexus.html:156f @ babylon.js:13(anonymous function) @ babylon.js:13e.onreadystatechange @ babylon.js:3
cannon.js:7958 .vertices[5] = Vec3(9.496039395439624,-0.1613202791258693,-1.6381011716127396)
cannon.js:7958 .vertices[9] = Vec3(10.03059742617607,-0.18255093901082872,-2.4449709176301955)
cannon.js:7958 .vertices[6] = Vec3(9.36750935766697,-0.1709842190735042,-2.2841292404174802)
cannon.js:7956 .faceNormals[10] = Vec3(0.16863071939806493,0.013335428473084679,0.9855890861929885) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.

example.zip

Link to comment
Share on other sites

  • 3 weeks later...

RaananW I look in your code.

http://raananweber.com/physics/

<script src="http://www.babylonjs.com/cannon.js"></script>

<script src="babylon.max.js"></script>

so I download 2 thinks from

http://www.babylonjs.com/cannon.js

and

http://raananweber.com/physics/babylon.max.js

 

RaananW Can you tell me what did you change. Which file cannon.js or babylon.max.js or both???

Where can I see this, what did you change? 

Can you give me exact url to lattest version on github?

Are now two new version babylon.max.js and cannon.max.js which implement new mesh imposter?

Where can I find this two files?

Some thins works. I did not have time to now. I will try this soon.

greetings

 

 

Link to comment
Share on other sites

The official version should be on

http://www.babylonjs.com/babylon.js

and

http://www.babylonjs.com/babylon.js

Do this two js files on this URL already have your new implementation for mesh impostor ...?? Are your new implemetation already commited on gitub? Where wich directory have

finally js file?

greetings

Link to comment
Share on other sites

RaananW,I try two simple meshes. 1. is plane 2. is path (more complex model).
I tried to use BABYLON.PhysicsEngine.MeshImpostor to path mesh. But Sphere/Ball fall throught path mesh.

I attach zip file with models and code. 
If you uncomment

BABYLON.SceneLoader.ImportMesh("","./assets/","path_pod_kotom.babylon", scene, function( newMeshes ) {

then code will load 2. model. (This model has Mesh Impostor) . And Ball fall throught path.

Can you please take a look and let me know if I miss something?

Why Mesh Impostor on path doesn't stop sphere when sphere fall down?


Thank you 

greetings

Test_MeshImpostor_with_Cannon_Example.zip

Link to comment
Share on other sites

Hi guys.  I did a little testing.

I tried loading ONLY the "path" model, and then I used a sphere and ground made locally.  Sphere physics works fine with ground, but not with path (ball track) model.  (sphere fall-thru)

I AM getting some warnings in the console during the path model load...  lots of them.

I get MANY...  "(normal) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."

hmm.  Also, when I tried to put a non-wireframe material on path model, I get this...

http://urbanproductions.com/wingy/babylon/misc/IanNormals.jpg

The path is black-ish, but my non-imported sphere (which uses the same material)... looks fine and is properly lit.  This could indicate that there is something wrong with the normals on the path model.

SO, Ian, it is MY theory... that Blender has exported the "normals" on your path model... incorrectly.  I suspect that the physics engine meshImposter uses these same normals for its activity.   I am not an expert on Blender, but I read "Edit mode, select all vertices (AKEY), CTRL-N -> "Recalculate normals outside", confirm. "

Not sure if I am correct, but maybe.  :)

Link to comment
Share on other sites

@Wingnut Those errors are related to the old mesh impostor. Are you using the newest version of Babylon?

@ian i used your path as a test object and it worked fine. Was busy all day and couldn't test that, but I'll check your code and see wha what's up pretty soon. An online version would be much more helpful, as I'll able to debug straight away.

Link to comment
Share on other sites

RaananW, I take babylon and cannon from this link, you provide above https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release

Wingnut: I will try on monday: Edit mode, select all vertices (AKEY), CTRL-N -> "Recalculate normals outside",

RaananW: Can you give me true URL of the newest version of Babylon and Cannon?

thanx you both for help for now

greetings

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...