Best way to create Physics object that matches a graphics object

Software: Away3D 4.x

Andrew R, Newbie
Posted: 16 September 2011 04:07 PM   Total Posts: 11

If I build a graphics object in 3ds, what’s the best way to create a matching set of Away3D Physics objects?  Can I do it programmatically?

   

Avatar
Alejandro Santander, Administrator
Posted: 16 September 2011 04:23 PM   Total Posts: 414   [ # 1 ]

Hey Andrew,

Can you specify a bit better what you want to do? Are you trying to apply physics to an individual object or an entire scene?

   

Andrew R, Newbie
Posted: 16 September 2011 04:38 PM   Total Posts: 11   [ # 2 ]

First, thanks for moving this to the right forum.

I’m creating a scene that will have some background scenery that will be ignored by the physics, but there will be a number of objects that are moderately complicated that need to have realistic shapes for other things to bounce off of.  Imagine if I were to create a boulder that has a shape that is a bit irregular.  Then I want a ball to bounce off this object.  My graphics guy will create the object and will distort it into a web of meshes.  It will look pretty cool on the rendering side.  But now I need a physics object that will bounce the ball off of it in realistic directions.  I don’t want it to just be a cylinder or rectangle.  If a ball were to hit it on a rounded corner, it should be somewhat realistic about bouncing off in a reasonable direction.

Is there a way to have this object be imported into the physics world and then have the obvious properties like mass applied to it?  I’d need the whole thing to act as a single object when it comes to motion, etc…

   

Avatar
Alejandro Santander, Administrator
Posted: 16 September 2011 04:48 PM   Total Posts: 414   [ # 3 ]

We are working on a set of tools regarding this kind of situations. Some of these tools were briefly exposed at FOTB.

What we are beginning to play with is a plugin for different 3D editors in which you can tag your meshes with type, collider shape, etc. Once imported into a parser, this parser creates the appropriate colliders for the physics of the scene. For instance, if a tree’s trunk is marked as a collider of shape cylinder, a physics cylinder collider will be associated with such mesh. Or if a terrain is marked as a static collider of shape triangle-mesh, a physics triangle mesh will be associated with it.

For now, these tools are in a phase too young to be released, but you can use the same logic in your code on the mean time. Rest assured that any news we have on this matter will be communicated to everyone as soon as possible!

   

Avatar
80prozent, Sr. Member
Posted: 16 September 2011 05:12 PM   Total Posts: 430   [ # 4 ]

hi alejandro

is cinema 4d one of the 3d-editors your planning your plugIn for?
c4d has a physics module (dynamics) thats working like this allready (applying tags to objects that defines them as rigid/soft bodys).
i strongly believe one could write a parser that uses this existing module and convert it to away3d physics.

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Alejandro Santander, Administrator
Posted: 16 September 2011 05:20 PM   Total Posts: 414   [ # 5 ]

For the moment, focus is being set on Blender and Maya. This doesn’t mean that others wont be targeted. In fact, there will be an open source project for that, in case anyone wants to add support for other editors. We are experimenting with those two for now. We will keep c4d in mind tho =)

   

Andrew R, Newbie
Posted: 16 September 2011 06:18 PM   Total Posts: 11   [ # 6 ]

Is AWPBvhTriangleMeshShape the best shape to use when creating a physics mesh from a graphics mesh?

Can I just directly use the top level mesh object from the file load and pass it into the constructor?

   

Avatar
Alejandro Santander, Administrator
Posted: 16 September 2011 07:54 PM   Total Posts: 414   [ # 7 ]

You should always try to use the simplest shape possible for physics. Of course, you can use a triangle mesh shape for a tree trunk but it will be a bit overkill. Performance would be much better in that case if you use a regular cylinder shape.

Regarding AWPBvhTriangleMeshShape, you need to pass it a mesh with no children since it looks for the first sub geometry in the geometry of such mesh. That is, the shape does not support nested containers.

You cannot do this:

var material:ColorMaterial = new ColorMaterial(0xFF0000);
   
material.lights [cameraPointLight];

   var 
spherePrimitive:Sphere = new Sphere(material);

   var 
container:Mesh = new Mesh();
   
view.scene.addChild(container);

   var 
sph1:Mesh spherePrimitive.clone() as Mesh;
   
sph1.= -50;
   
container.addChild(sph1);

   var 
sph2:Sphere = new Sphere(material);
   
sph2.50;
   
container.addChild(sph2);

   var 
shape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(container);
   var 
body:AWPRigidBody = new AWPRigidBody(shapecontainer0.1);
   
physicsWorld.addRigidBody(body); 
   

Avatar
80prozent, Sr. Member
Posted: 16 September 2011 09:08 PM   Total Posts: 430   [ # 8 ]

so to build a collider mesh for a mesh with different materials/submeshes applied, i would have to create different meshes (each with only 1 submesh), and build a collider mesh for each ?

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Alejandro Santander, Administrator
Posted: 16 September 2011 09:45 PM   Total Posts: 414   [ # 9 ]

Lets call geometries that have 1 sub geometry “leafs”. These are eligible for triangle mesh colliders. It doesn’t matter how you organize your leafs or your node hierarchy for that matter, as long as you identify the leafs and apply the colliders to them and only them.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X