AWPBvhTriangleMeshShape surface is not smooth

Software: Away3D 4.x

Francesc Garcia, Newbie
Posted: 26 March 2013 03:57 PM   Total Posts: 6

Hi there!

I’m new using Away3D, so maybe I’m asking something stupid. I’m working on a 3D pool game, I’ve managed to load all the elements on my model, when I add an impulse to the white ball it moves wthout any problem… but when the ball reaches the first of the cloth’s shape edges (picture attached to the post) it’s affected by some kind of force that turns it aside from it’s path. When the ball reaches to the edges in the middle of the table, if it’s not moving fast, it loses it’s path completely and is headed directly towards the side holes… the same thing happens to the other balls.

I am using a AWPBvhTriangleMeshShape for the cloth (mesh imported from the 3D model)

material=new ColorMaterial(0x008000);
     
material.lightPicker=_lightPicker;
     
objectMesh=event.asset as Mesh;
     
objectMesh.material=material;
     
_view.scene.addChild(objectMesh);
     
objectShape = new AWPBvhTriangleMeshShape(objectMesh.geometry);
     
objectBody= new AWPRigidBody(objectShapeobjectMesh0);
     
objectBody.friction=0.8;
     
objectBody.contactProcessingThreshold=0.1;
     
_physics.addRigidBody(objectBody); 

And SphereShape for the balls (white ball mesh is a SphereGeometry created in code, and the rest of the balls’ meshes are imported from the model)

material=new ColorMaterial(0xffffff);
     
material.lightPicker=_lightPicker;
     
objectMesh=new Mesh(new SphereGeometry(1.30),material);
     
objectMesh.material=material;
     
_view.scene.addChild(objectMesh);
     
sphereShape = new AWPSphereShape(1.30);
     
whiteBall= new AWPRigidBody(sphereShapeobjectMesh0.194);
     
whiteBall.friction=0.05;
     
whiteBall.restitution=0.95;
     
_physics.addRigidBody(whiteBall); 

How can I avoid that behavior? I need the ball to be affected by friction the same way in all the table surface.

I’ll keep looking for a solution as I wait for your replies. Thank you in advance for your time and help! wink

NOTE: The model is imported from a 3DS file.

 

 

 

   

Francesc Garcia, Newbie
Posted: 27 March 2013 05:07 PM   Total Posts: 6   [ # 1 ]

The problem seems to be that the edges of the TriangleMesh have certain volume and they make the mesh surface irregular, so I’ve changed the title of the post to reflect the issue more accurately. I’ve managed to reduce their impact in x,z axis by setting world physics scale and physics step, but it’s still being annoying in the y axis, as the balls find an obstacle that makes them jump and eventually go out of the table.

Is there any way to make the table surface completely smooth?
Please, I really need help with it, It can sound silly to experienced developers but I’m getting mad with that issue.

 

   

John Brookes, Moderator
Posted: 27 March 2013 07:40 PM   Total Posts: 732   [ # 2 ]

Your using really small values for the shapes / geometry which isnt reccomended.

But even with larger values the internal triangles of bvh seem to catch a sphere (just tested).
No idea why. :(

AWPbox doesnt have this issue and even compound shapes of boxs (think grid) dont.


Maybe try this
Use a box as the table bed (green).
Create a cylinder shape and use it as a ghost object to detect when the ball should drop into the pocket (yellow).
Use collsion filters (https://github.com/away3d/awayphysics-examples-fp11/blob/master/src/CollisionFilterTest.as) and set the ball to drop through the table bed.
You could use a small bvhmesh as the edge of the pocket to make sure the ball doesnt drop straight down.(grey)

 

   

Francesc Garcia, Newbie
Posted: 27 March 2013 09:18 PM   Total Posts: 6   [ # 3 ]

Thak you very much for your response!

I was really losing my mind, as I’ve never worked with 3D before and I didn’t knew if I was trying something beyond tech limitations. I know about issues with small bodies, I’ve read a lot about that in the forum, the wiki and bullet docs, but I couldn’t find anything about the mesh surface imperfections and I was really desperate.

I thought about changing the mesh by a 3Dbox today after lunch, but I’ve been trying so many different things these days, and I was so tired and faithless towards all of my previous approaches that I gave up and went back to the mesh as soon as I got the first errors.

Now that I know the mesh is not the way, I’ve started to work harder towards the box-based cloth again following your advice, and I can see a glance of light at the end of the tunnel!

Thank you very much, again. You really made my day! LOL

 

   

Francesc Garcia, Newbie
Posted: 02 April 2013 08:01 AM   Total Posts: 6   [ # 4 ]

OK, it works now smile
Thank you very much again!

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X