Mesh, Shape and RigidBody in a Physic World

Software: Away3D 4.x

Razorblade, Newbie
Posted: 12 June 2012 08:58 PM   Total Posts: 7

Hi everyone,
I’m doing some experiments with AwayPhysics, with not so good results, this because I have poor knowledge about basic concepts.
I’m going to do lot’s of question here, so I thank you in advance for the patience.

Let’s do an example:

I want to add a simple mesh in the physic world, let’s say a parallelepiped, exported in .OBJ format from a 3D application.

I noticed that the library contains Shapes classes and starting from an imported Mesh a Shape must be created: what is the concept in order to choose the correct class? If the Mesh is not a perfect primitive? What if is a complex Mesh like a spaceship or a car?
What is and what it does a shape in a physic world, isn’t a Mesh already a Shape?

Then, after creating a Shape a RigidBody must be created. A RigidBody from what I understand in an union between a Shape and a Mesh, where the Mesh is like a skin and the Shape is used to manage collisions, is that correct?

Hope someone have the kindness and patience to answer all these noob questions smile

Cheers

   

John Brookes, Moderator
Posted: 12 June 2012 10:44 PM   Total Posts: 732   [ # 1 ]

http://bulletphysics.com/ftp/pub/test/physics/Bullet_User_Manual.pdf
See page 18 of the bullet manual for what type of shape to use.


A shape isnt a mesh.
Think of a shape as more like a bounds that the physics uses to calc stuff smile

Last question: yeah

   

Razorblade, Newbie
Posted: 12 June 2012 10:50 PM   Total Posts: 7   [ # 2 ]

Thank you,
I think that was exactly what I needed!

Cheers

   

Razorblade, Newbie
Posted: 12 June 2012 11:15 PM   Total Posts: 7   [ # 3 ]

Some other questions…

How to get correct width, height and depth of an exported .OBJ?
Can a shape be wireframe rendered within the scene?
What if a shape dimension is bigger than the Mesh skin (or too small)?

Thanks

   

John Brookes, Moderator
Posted: 13 June 2012 12:20 AM   Total Posts: 732   [ # 4 ]

You can get the size of your mesh using mesh.bounds min max
I usually get the values from Maya as sometimes I may want a smaller box sphere etc and just hardcode those. Could also use Prefab.

Yes for debugging use the debugDraw for the physics.
eg
debugDraw = new AWPDebugDraw(view, YourPhysicsWorld);
debugDraw.debugMode = AWPDebugDraw.DBG_DrawCollisionShapes

//enterframe
debugDraw.debugDrawWorld();


If its too small, the skin (mesh) will “seem” to sink into whatever its sat on/ colliding with. Too big it will “seem” to float in the air.
Bad description, easiest way try it. smile

Just a heads up..not used OBJ in the physics for a while and the last time I did the mesh could sometimes have its vertices offset from its pivot point. So if your debug draw doesnt match your mesh position could be that. Again prefab would help with that.

   

Razorblade, Newbie
Posted: 13 June 2012 07:30 AM   Total Posts: 7   [ # 5 ]

Thank you for all your advices,
they are really helpful,
I’ll give it some try and come back again for some more basic questions I think.

Cheers

   

Razorblade, Newbie
Posted: 15 June 2012 10:54 AM   Total Posts: 7   [ # 6 ]

Hello,
I have now a simple box and I can see its shape because I did it bigger voluntarily (and also because I use DBG_DrawCollisionShapes mode).

It is colliding with a ‘road’ plane.

I’m now tryng to make it move using box.moveForward(xx), but it moves only inside its shape and just for a small amount, in practice it does not move, why?

Thanks

   

John Brookes, Moderator
Posted: 16 June 2012 04:18 PM   Total Posts: 732   [ # 7 ]

moveforward works on the mesh not on the rigidbody.
Once a mesh is paired with a rigidbody its transforms are set by the physics.
You need to apply forces or set the velocity of the rigidbody.

look at the demos on Github for the basics.

   

Razorblade, Newbie
Posted: 16 June 2012 04:30 PM   Total Posts: 7   [ # 8 ]

I’m already seeing the demos on Github,
I thought that forces are managed only by the car object example, not all rigid body.

I’ll give it some more try,

thank you!

   

Ekoku, Newbie
Posted: 31 July 2013 09:40 AM   Total Posts: 2   [ # 9 ]

I know it is a bit late but the link is broken and I’m having hard time trying to understand connection between meshes and rigid bodies. Can you help me with a proper guide for this? Thanks for helping a newbie ^^

   

John Brookes, Moderator
Posted: 31 July 2013 02:08 PM   Total Posts: 732   [ # 10 ]

The manual is here (not that helpfull)
http://bullet.googlecode.com/svn/trunk/Bullet_User_Manual.pdf

As for connection between meshes and rigid bodies?
Not sure what you want to know..
The physics just calcs the collsions etc of the rigid bodies and sets a transform.
That transform is then used to position/scale/rotate a mesh.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X