AWPCompoundShape from mesh?

Software: Away3D 4.x

dmk, Jr. Member
Posted: 28 August 2014 07:33 AM   Total Posts: 32

Let’s say I have loaded in a mesh that was created via AwayBuilder (via importing from 3ds max)... it’s a relatively simple geometry, but not one I really want to recreate by hand/hard numbers. Like spinning top where a slight difference will make it wobble really differently.

How can I convert that into AwayPhysics (AWPCompoundShapeI think)?

   

John Brookes, Moderator
Posted: 28 August 2014 09:50 AM   Total Posts: 732   [ # 1 ]

There’s no way to just convert a model to a compound made of other shapes. You have to position and choose what shapes you want to use yourself.

You can just create some simple meshes in your 3d app as positions/dimensions for the compound parts and then read those when loading to create your compound shape.

Really If its just a simple model would go for coding the positions/rotations in a class. While using a 3d app to get the setup of position/rotation right.
Just makes it easier to do little tweaks while testing. Rather than having to export an awd every time you change something.

 

   

dmk, Jr. Member
Posted: 28 August 2014 10:30 AM   Total Posts: 32   [ # 2 ]

Will try to do it by hand, but in the meantime-

I actually am not using any 3d modelling software, just bought something from turbosquid and imported into awaybuilder then adjusted from there (basically just deleting the unnecessary objects and replacing textures)

Considering that, is there an easier way of getting the AWPCompoundShape?

 

   

dmk, Jr. Member
Posted: 28 August 2014 10:45 AM   Total Posts: 32   [ # 3 ]

i.e. if AwayBuilder can understand the object as an ObjectContainer3D… is there some sort of easy translation from that to AWPCompoundShape? Maybe an export feature from AwayBuilder to generate it as some actionscript? :D

 

   

John Brookes, Moderator
Posted: 28 August 2014 10:53 AM   Total Posts: 732   [ # 4 ]

Download prefab V2
http://www.closier.nl/prefab/

Open your model in that and just add whatever spheres/box shapes you need to simulate the volume of the model.
Then just use the pos/rot of those shapes. for the compound shapes.

 

   

John Brookes, Moderator
Posted: 28 August 2014 11:02 AM   Total Posts: 732   [ # 5 ]
dmk - 28 August 2014 10:45 AM

i.e. if AwayBuilder can understand the object as an ObjectContainer3D… is there some sort of easy translation from that to AWPCompoundShape? Maybe an export feature from AwayBuilder to generate it as some actionscript? :D

Well thats what I sometimes do.
You can name containers and then add the dimensions to the name.
So
sphere_30
Box_20_30_20

Then just read the name and create you compound shapes.

But you still end up creating the mesh in the 3d app so you can visualize how the shapes make up the volume of the mesh your trying to create.

Basically the compund physics doesn’t want to know about any verts/mesh. All it wants is what type of shape position and rotation.

So if you going to add that to the awd just come up with some sort of way to read it.

 

   

dmk, Jr. Member
Posted: 28 August 2014 11:11 AM   Total Posts: 32   [ # 6 ]

OK - prefab looks like an awesome tool, did not know it existed smile

It seems my “problem” is that the original mesh is one single object, so the program of course can’t break it down into distinct objects, so I guess I’ll need to recreate it by hand using some sort of tool.

Download prefab V2
http://www.closier.nl/prefab/

Open your model in that and just add whatever spheres/box shapes you need to simulate the volume of the model.

I don’t see any options for adding geometries… would AwayBuilder be better for that?

Attached is the AWD I need to recreate if that helps anything…

 

 

File Attachments
dreidel.awd  (File Size: 103KB - Downloads: 487)
   

dmk, Jr. Member
Posted: 28 August 2014 12:29 PM   Total Posts: 32   [ # 7 ]

OK, was able to do this by hand via AwayBuilder to create simple geometries and line them up by eye. Is that the overall approach to physics, just need to get it close enough so that the body pretty much reacts the way we want?

Here’s my actual code (still not sure why it’s not falling over- but that’s a separate thread)

//getAWDAssetsFromLoader() is handled elsewhere really, keeps a reference to each asset as its loaded
//lightPicker, physicsWorld, scene are all elsewhere as well
 
private function init(ldr:Loader3D{
   
var geom:PlaneGeometry
   var 
mesh:Mesh;
   var 
mat:ColorMaterial;
   var 
cylShape:AWPCylinderShape;
   var 
boxShape:AWPBoxShape;
   var 
coneShape:AWPConeShape;
   var 
shapeContainer:AWPCompoundShape;
   var 
body:AWPRigidBody;
   var 
meshContainer:ObjectContainer3D = new ObjectContainer3D();
   var 
assets:Array = getAWDAssetsFromLoader(ldr);
   var 
obj:Object;
   
   
   
   for 
each(obj in assets{
    
if(obj is MaterialBase{
     
if(obj is TextureMaterial{
      
(obj as TextureMaterial).alpha .3;
     
}
     
(obj as MaterialBase).lightPicker lightPicker;
    
else if(obj is Mesh{
     mesh 
obj as Mesh;
     
    
}
   }
   
   mesh
.rotationY = -18;
   
meshContainer.addChild(mesh);
   
   
//Physics
   
shapeContainer = new AWPCompoundShape();
   
   
cylShape = new AWPCylinderShape(1230);
   
boxShape = new AWPBoxShape(70,56,70);
   
coneShape = new AWPConeShape(3528);
   
   
//Flip it upside down
   
coneShape.localScaling = new Vector3D(1,-1,1,1);
   
   
shapeContainer.addChildShape(coneShape, new Vector3D(0,14,0,0));
   
shapeContainer.addChildShape(boxShape, new Vector3D(0,56,0,0));
   
shapeContainer.addChildShape(cylShape, new Vector3D(0,100,0,0));
   
   
body = new AWPRigidBody(shapeContainermeshContainer10);
   
   
body.position = new Vector3D(0,100,0);
   
//body.restitution = .8;
   
body.friction 100;
   
   
body.applyTorque(new Vector3D(010000));
   
   
   
   
physicsWorld.addRigidBody(body);
   
scene.addChild(meshContainer);
  

 

   

John Brookes, Moderator
Posted: 28 August 2014 05:59 PM   Total Posts: 732   [ # 8 ]

Well looking at your model its pivot is at the very bottom.
SO that’s where your compound shape starts from.
But the spinners center of mass will be somewhere more central/higher

Random guess smile

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X