AWPCollisionShape-Position of AWD2-Mesh

Software: Away3D 4.x

Manuel L., Member
Posted: 05 February 2013 02:16 PM   Total Posts: 99

Hey guys, i`m trying a little bit with awayphysics and got a problem with Shape-Position of loaded AWD2.
This .awd-file has got two cubes. a big one thats standing on the ground with position 0,0,0 and one small one thats up in the air at 0,150,0.
now i created the shapes and bodys for awayphysics:

shape1 = new AWPBoxShape(200,200,200);
body1 = new AWPCollisionObject(shape1Mesh(get3dChildByName("big")));
physics.addCollisionObject(body1);

shape2 = new AWPBoxShape(20,20,20);
body2 = new AWPCollisionObject(shape2Mesh(get3dChildByName("small")));
physics.addCollisionObject(body2); 

the shape of the big one fits perfect and is located at 0,0,0, same as the concerning mesh. but the shape of the small one is located at 0,0,0, too, although the concerning mesh is at 0,150,0.

how can i tell the shape to adapt the position of the mesh? do you know what i mean? ^^

   

John Brookes, Moderator
Posted: 05 February 2013 11:38 PM   Total Posts: 732   [ # 1 ]
var mymesh:Mesh Mesh(get3dChildByName("small"))
body2 = new AWPCollisionObject(shape2mymesh );
body2.position mymesh.position;
physics.addCollisionObject(body2); 

Another way is to use the transform.
eg
body2.transform = mymesh.transform.clone();
Then both position and rotation is passed to the collision object
But…
If your mesh has scaling the collsion objects and mesh size doesnt match.
Not sure if thats a bug but can see why it happens in awpcollsionObject.as
keep meaning to test it.

   

Manuel L., Member
Posted: 06 February 2013 08:22 AM   Total Posts: 99   [ # 2 ]

thank you very much john, it works for me when setting:

body2.position get3dChildByName("small")); 

seems like mesh and shape position gets unified only after updating body position for first time.

in debug mode i can see my cube up in the air and the shape of this cube at the bottom. when setting any position-value for the body, mesh and shape get the same values automatically.

why does this not happen automatically when instancing
“new AWPCollisionObject(shape, mesh)” ??

anyway, thank you smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X