JTriangleMesh from away3D4Physics plugin

Software: Away3D 4.x

avaTara, Newbie
Posted: 21 October 2011 02:13 PM   Total Posts: 2

Hi all. Got some problem here. I’ve edited the exmaple from jiglib Away3DStackingTest.as. Trying to replace balls with cylinders. Got this code:

coinBody = new Vector.<JTriangleMesh>();
   var 
cylinder:Cylinder;
   for (var 
i:int 015i++)
   
{
   cylinder 
= new Cylinder(materia22224);
   
view.scene.addChild(cylinder);
    
coinBody[i] physics.createMesh(Mesh(cylinder),new Vector3D(),new Matrix3D(),10,10);
    
coinBody[i].moveTo(new Vector3D( -150 Math.random() * 300250 Math.random() * 50, -250 Math.random() * 500));
    
coinBody[i].movable true;
    
coinBody[i].mass 10;
//    coinBody[i].addWorldForce(new Vector3D(10, 10, 10, 2), new Vector3D(100, 0, 0, 0), true);
   
}
   coinBody[0]
.mass 10;
   
physics.getMesh(coinBody[0]).material=new ColorMaterial(0xff8888);
   
physics.getMesh(coinBody[0]).material.lights=[mylight];
   
   
boxBody = new Vector.<RigidBody>();
   for (
015i++)
   
{
    boxBody[i] 
physics.createCube(materia505050 );
    
boxBody[i].moveTo(new Vector3D( -150 Math.random() * 300450 Math.random() * 50, -250 Math.random() * 500));
   

It draws my coins, but they just stay on the initial position. They dont fall, on the ground. Boxes hit them and bounce, so they init as bodies. But even with setting mass and movable they igonre gravity ^^.

   

avaTara, Newbie
Posted: 23 October 2011 03:01 PM   Total Posts: 2   [ # 1 ]

Ok. Got the answer myself. The case is here:

public function set movable(mov:Boolean):void
  {
   
if (_type == "PLANE" || _type == "TERRAIN" || _type == "TRIANGLEMESH")
    return;
   
   
_movable mov;
   
isActive mov;
   
_origMovable mov;
  

This is set function from jiglib’s Rigidbody class. And in Away3dPhysics we init type:

_type "TRIANGLEMESH"
   

lior_hai, Newbie
Posted: 18 July 2013 08:31 AM   Total Posts: 10   [ # 2 ]

I didn’t understand your solution.

I have the same problem where my jTriangleMesh is not compelled by gravity. It is colliding with a cube when I drop it above the mesh but I can’t get it to move, it’s just floating in the air.

I tried every example I managed to find relating this problem but still no success.

I am using Away3d4 and Jiglib for flash player 11.

chas ObjectContainer3D(e.target);
view.scene.addChild(chas);
   
var 
mesh:Mesh;
mesh Mesh(chas.getChildAt(0));
mesh.geometry.scale(2);
mesh.material.lightPicker lightPicker;
   
   
var 
triangleMesh:JTriangleMesh physics.createMesh(mesh,new Vector3D(),new Matrix3D(),10,10);
triangleMesh.moveTo(new Vector3D(0,chas.maxY 250,0));
triangleMesh.mass 9;
triangleMesh.friction 0.9;
triangleMesh.movable true

Any help will be greatly appreciated, I am losing my mind over this…


PS
I changed

public function set movable(mov:Boolean):void
{
if (_type == "PLANE" || _type == "TERRAIN" || _type == "TRIANGLEMESH")
 return;
   
_movable mov;
isActive mov;
_origMovable mov;

to

public function set movable(mov:Boolean):void
{
if (_type == "PLANE" || _type == "TERRAIN")
 return;
   
_movable mov;
isActive mov;
_origMovable mov;

And now gravity works but no collision with ground.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X