BvhTriangleMeshCarTest with AwawPhysics 1.0

Software: Away3D 4.x

louis87, Jr. Member
Posted: 07 February 2013 09:21 AM   Total Posts: 46

Hello,

I’m trying to test BvhTriangleMeshCarTest with the latest AwayPhysics version on dev branch (1.0), but the car and the cubes fall down through the triangle mesh.

What is happening?

   

Avatar
Luca, Sr. Member
Posted: 07 February 2013 03:20 PM   Total Posts: 230   [ # 1 ]

http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_ShapesCar
smile

skin are a simple mesh… try debug the app. Use:

  debugDraw = new AWPDebugDraw( _view, physicsWorld );
  //debugDraw.debugMode = AWPDebugDraw.DBG_DrawCollisionShapes;
  debugDraw.debugMode = AWPDebugDraw.DBG_NoDebug;

and in the ENTER_FRAME:
debugDraw.debugDrawWorld();

for my software i use this:
for the terrain:
    else if( mesh.name.substr( 0, 2 ) == “t_” )  // TERRAIN
    {
    //
    trace(“Add: ” + mesh.name);
    // mesh.showBounds = true;
    mesh.material = TerrainMat;
   
    var cw:Number = mesh.maxX - mesh.minX;
    var ch:Number = mesh.maxY - mesh.minY;
    var cl:Number = mesh.maxZ - mesh.minZ;
   
    WorldScaleX = 1000 / cw;
    WorldScaleY = 1000 / ch;
    WorldScaleZ = 1000 / cl;
   
   
    // create triangle mesh shape
    var sceneShape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape( mesh.geometry, true );

   
    //
    var sceneBody:AWPRigidBody = new AWPRigidBody( sceneShape, null, 0 );
    sceneBody.restitution = 0.2;
    sceneBody.position = new Vector3D();
    //
    _physics.addRigidBody( sceneBody );

and this for the car - try this:

  //
  var boxShape1:AWPConvexHullShape = new AWPConvexHullShape( CarBoundMesh.geometry );
  // var boxShape1:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape( CarBoundMesh.geometry );

 
  //
  var BBS:Vector3D = new Vector3D(
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxX - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minX,
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxY - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minY,
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxZ - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minZ );

  //var boxShape1:AWPBoxShape = new AWPBoxShape( BBS.x, BBS.y, BBS.z );
 
  //
  bb1Pos = new Vector3D( bbc[0].x, bbc[0].y, bbc[0].z );
 
  bb1Pos.x = 0;
  bb1Pos.y = 0;
  bb1Pos.z = 0;
 
  //
  var carShape:AWPCompoundShape = new AWPCompoundShape();
  // var cs:AWPCollisionShape = new AWPCollisionShape( boxShape1, );
 
  // Shifting the center of mass
  // If you want to shift the center of mass of a PhysicsNode or PhysicsVehicleNode, you will have
  // to create a CompoundCollisionShape and attach the real CollisionShape for the PhysicsNode to it with an offset.
  // CompoundCollisionShape compoundCollisionShape=new CompoundCollisionShape();
  // BoxCollisionShape boxCollisionShape=new BoxCollisionShape(new Vector3f(0.5f,0.5f,0.5f));
  // compound.addChildShape(boxCollisionShape, new Vector3f(0,1,0));

  // effectively shifts the center of mass with respect to the chassis
  carShape.addChildShape( boxShape1, new Vector3D( 0, bb1Pos.y, 0 ), new Vector3D( 0, 0, 0 ) );

 

 
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).visible = false;

 
  //
  return carShape;

The collision shape are one mesh created in max around the vehicle. AND check wheel radius and suspension value….

 

   

Daniel88, Newbie
Posted: 13 February 2013 04:20 AM   Total Posts: 6   [ # 2 ]
Luca - 07 February 2013 03:20 PM

http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_ShapesCar
smile

skin are a simple mesh… try debug the app. Use:

  debugDraw = new AWPDebugDraw( _view, physicsWorld );
  //debugDraw.debugMode = AWPDebugDraw.DBG_DrawCollisionShapes;
  debugDraw.debugMode = AWPDebugDraw.DBG_NoDebug;

and in the ENTER_FRAME:
debugDraw.debugDrawWorld();

for my software i use this:
for the terrain:
    else if( mesh.name.substr( 0, 2 ) == “t_” )  // TERRAIN
    {
    //
    trace(“Add: ” + mesh.name);
    // mesh.showBounds = true;
    mesh.material = TerrainMat;
   
    var cw:Number = mesh.maxX - mesh.minX;
    var ch:Number = mesh.maxY - mesh.minY;
    var cl:Number = mesh.maxZ - mesh.minZ;
   
    WorldScaleX = 1000 / cw;
    WorldScaleY = 1000 / ch;
    WorldScaleZ = 1000 / cl;
   
   
    // create triangle mesh shape
    var sceneShape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape( mesh.geometry, true );

   
    //
    var sceneBody:AWPRigidBody = new AWPRigidBody( sceneShape, null, 0 );
    sceneBody.restitution = 0.2;
    sceneBody.position = new Vector3D();
    //
    _physics.addRigidBody( sceneBody );

and this for the car - try this:

  //
  var boxShape1:AWPConvexHullShape = new AWPConvexHullShape( CarBoundMesh.geometry );
  // var boxShape1:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape( CarBoundMesh.geometry );

 
  //
  var BBS:Vector3D = new Vector3D(
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxX - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minX,
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxY - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minY,
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).maxZ - CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).minZ );

  //var boxShape1:AWPBoxShape = new AWPBoxShape( BBS.x, BBS.y, BBS.z );
 
  //
  bb1Pos = new Vector3D( bbc[0].x, bbc[0].y, bbc[0].z );
 
  bb1Pos.x = 0;
  bb1Pos.y = 0;
  bb1Pos.z = 0;
 
  //
  var carShape:AWPCompoundShape = new AWPCompoundShape();
  // var cs:AWPCollisionShape = new AWPCollisionShape( boxShape1, );
 
  // Shifting the center of mass
  // If you want to shift the center of mass of a PhysicsNode or PhysicsVehicleNode, you will have
  // to create a CompoundCollisionShape and attach the real CollisionShape for the PhysicsNode to it with an offset.
  // CompoundCollisionShape compoundCollisionShape=new CompoundCollisionShape();
  // BoxCollisionShape boxCollisionShape=new BoxCollisionShape(new Vector3f(0.5f,0.5f,0.5f));
  // compound.addChildShape(boxCollisionShape, new Vector3f(0,1,0));

  // effectively shifts the center of mass with respect to the chassis
  carShape.addChildShape( boxShape1, new Vector3D( 0, bb1Pos.y, 0 ), new Vector3D( 0, 0, 0 ) );

 

 
  CarContainer.getChildAt( GetChildByName( CarContainer, “CollisionBB1” ) ).visible = false;

 
  //
  return carShape;

The collision shape are one mesh created in max around the vehicle. AND check wheel radius and suspension value….


The link is broken, you can share to us?

Vietnam travel-Vietnam holiday tours-Paloma cruise Halong

 

 

 

   

Avatar
Luca, Sr. Member
Posted: 13 February 2013 09:26 AM   Total Posts: 230   [ # 3 ]

Oops…. Sry smile

The link is wrong

http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes

 

   

Avatar
Luca, Sr. Member
Posted: 13 February 2013 09:32 AM   Total Posts: 230   [ # 4 ]

But i have misunderstood your problem. To solve your problem use this library:

I have some problems to solve… I’m out of service wink

With 4.1 Alpha i have the same problem. I can see the problem graphically with DBG_DrawCollisionShapes debug option enabled.

Sry again smile

 

File Attachments
Away3D+Physics.7z  (File Size: 1729KB - Downloads: 0)
   

louis87, Jr. Member
Posted: 13 March 2013 07:44 AM   Total Posts: 46   [ # 5 ]

The problem was I use Away3D 4.0 and now with 4.1 all works fine wink

 

   

Avatar
Luca, Sr. Member
Posted: 13 March 2013 03:28 PM   Total Posts: 230   [ # 6 ]

With 4.1, really ?

I have no problem with 4.0.9 gold… or whit this set of libs smile
( not only for physics )

https://github.com/LucaEstiva/GameMaker

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X