BvhTriangleMesh of 3DS Model not detecting collision

Software: Away3D 4.x

Dasher, Newbie
Posted: 14 October 2011 08:14 PM   Total Posts: 8

I have a cube like 3DS model that is used to create a BvhTriangelMesh object. Its mass is set to 0 to make it static. But it is not detecting collision with any objects. If I use some Boxshape etc to make the cube like object it works fine. What could be the problem with BvhTriangleMesh physics objects?

Thanks for the help.

   

Dasher, Newbie
Posted: 15 October 2011 07:23 PM   Total Posts: 8   [ # 1 ]

I seem to have the same issue with AWPCompoundShapes too. If I use simple AWPBoxshapes to make the cube as an approximation, the collision works fine. If I make the BoxShape a CompoundShape object (with just one Child which is the BoxShape) I get the problem. Any idea why static bodies made up of CompoundShapes and BvhTriangleMeshes do not detect collisions?

   

m valentin, Newbie
Posted: 17 October 2011 05:59 PM   Total Posts: 10   [ # 2 ]

I think I’m having the same problem. I have made a model in blender and exported it as an obj.
I got no problem loading it into away, but can’t get BvhTriangleMesh working. No collision with other objects? But if I make a simple box (as a floor) in blender and export it, I can get a collision??

(I have found a solution to my problem. I rotated the mesh in away before adding it to RigidBody, and that caused some problems)

   

Yang Li, Administrator
Posted: 18 October 2011 01:29 AM   Total Posts: 80   [ # 3 ]

can you paste your code, how to load the model and create bvhTriangleMesh.
and remember the model must have only one child mesh.

   

Dasher, Newbie
Posted: 18 October 2011 05:35 AM   Total Posts: 8   [ # 4 ]

There is only one SubMesh.

Here is the relevant code. Thanks for the help.

import away3d.loaders.parsers.Max3DSParser;


import awayphysics.collision.shapes.*;
import awayphysics.dynamics.*;


var _loader : Loader3D = new Loader3D(true); 
Loader3D.enableParser(Max3DSParser); 
_loader.load(new URLRequest(”../assets/box.3DS”));
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onBoxLoad);

protected function onBoxLoad( event:away3d.events.LoaderEvent ) : void
{
var container:ObjectContainer3D = event.target as ObjectContainer3D;
var material:ColorMaterial;
var boxMesh:Mesh;
var boxBody : AWPRigidBody;
 
  for (var i : int = 0; i < container.numChildren; ++i)
  {
boxMesh = Mesh(container.getChildAt(i));
material = new ColorMaterial(0x00ff00);
material.lights = [_light];
boxMesh.material = material;
  }
 
  _view.scene.addChild(container);
 

  var boxShape : AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(boxMesh.geometry);
  boxBody = new AWPRigidBody(boxShape, boxMesh, 0);  boxBody.fricti
  _physicsWorld.addRigidBody(boxBody);
}

   

Yang Li, Administrator
Posted: 18 October 2011 08:10 AM   Total Posts: 80   [ # 5 ]

looks it’s 3ds parser problem, I always get 0 numChildren when load the 3ds model.

   

Dasher, Newbie
Posted: 18 October 2011 02:34 PM   Total Posts: 8   [ # 6 ]

The model loads fine. I can see it perfectly in the scene. It is the physics model that is not detecting the collision. I tried it with OBJ model too and I have the same problem.

   

Yang Li, Administrator
Posted: 18 October 2011 03:12 PM   Total Posts: 80   [ # 7 ]

could you send your model? I can’t get the 3ds model work.

   

Dasher, Newbie
Posted: 20 October 2011 09:22 PM   Total Posts: 8   [ # 8 ]

OK. I will create a simple 3DS model that I can send. Thanks.

   

Rayen123, Member
Posted: 13 February 2012 09:44 PM   Total Posts: 70   [ # 9 ]

Hi,
I have the same problem, do you have a solution for this?
Thanks

   

Dasher, Newbie
Posted: 14 February 2012 01:12 AM   Total Posts: 8   [ # 10 ]

Rayen 123,

The main problem was that it had multiple childmeshes. Make sure you collapse/merge all the parts into one model in 3DS before exporting. Hope this helps.

   

Rayen123, Member
Posted: 14 February 2012 06:45 AM   Total Posts: 70   [ # 11 ]

Hi Dasher,
thanks for quick reply, my loaded model has numChildren = 0, so it is that problem maybe, thanks, I will try it. (it has collision only in point(0,0) in my model).
So evening I will try your solution and give you answer if it works

   

Rayen123, Member
Posted: 15 February 2012 04:34 PM   Total Posts: 70   [ # 12 ]

Hi,
I have only 1 cylinder in blender scene, so when I merged it, cylinder was removed.
When I add this .3ds (cylinder) to away3D scene he is showed normaly, but collision (away3d-awayphysics-core-fp11-f0cfb44) is only in point(0,0) in this cylinder (I guess).

this is it
http://webmaking.sk/temp/BallPhysics.html (arrow keys to move ball)
and source is here
http://webmaking.sk/temp/Engine.as.txt

I read example with this:

for (var i:int = 0; i < buildings.geometry.subGeometries.length; i++)
{
var buildingsShape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(buildings,i);
var buildingsRb:AWPRigidBody = new AWPRigidBody(buildingsShape, buildings, 0);
physicsWorld.addRigidBody(buildingsRb);
}

but I cant set which subgeometry it takes to AWPBvhTriangleMeshShape .

I am very confusion with it :(
Thanks for your help.

(cylinder is imported .3ds model)

   

Nina, Newbie
Posted: 25 March 2012 03:24 PM   Total Posts: 3   [ # 13 ]

I tried the same (before in Proscenium from Adobe, this worked, BUT the whole Proscenium thing seems to be pretty unsupported and buggy on top, or let’s say, you can’t tell if it’s buggy or if you’re using it wrong, because it totally lacks any documentation)

This, for Away3D, should have worked, but doesn’t:

var i:int _loaderRoom.numChildren// _loaderRoom contains the loaded Model with all it's Meshes
var compShape:AWPCompoundShape = new AWPCompoundShape();
while (
i--) {
 
var roomMesh:Mesh _loaderRoom.getChildAt(i) as Mesh;
 if (
roomMesh != null// just to be sure...
  
var shape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(roomMesh.geometry);
  
compShape.addChildShape(shape);
  
trace ("added Shape from " roomMesh.originalName " to compound");
 
}
}
_awpRoom 
= new AWPRigidBody(compShape_loaderRoom0); 

and later, eventually do:

_view3D.scene.addChild(_loaderRoom);
_physicsWorld.addRigidBody(_awpRoom); 

Something seems to be broken there.
I already thought about naming all my Meshes like the Shape of their proxy equivalents, i.E. name them “BoxTable”, “SphereDome”, etc. and then, create primitive shapes based on the Names and dimension of the Mesh (where we can just take maxX, maxY and maxZ to measure them)
But that’s not the solution I was looking for, because many forms are not really possible just by using primitive shapes (not even talking about convex hulls and stuff)

   

Nina, Newbie
Posted: 25 March 2012 06:12 PM   Total Posts: 3   [ # 14 ]

Ah I found out that you better apply the transformation of the Mesh to the Mesh itself, before converting it to a AWPBvhTriangleMeshShape like this:

var geo:Geometry roomMesh.geometry.clone();
geo.applyTransformation(roomMesh.transform);
geo.scale(100); // apply the appropiate scaling factor
var shape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(geo); 

(There was an error thrown in the clone method if there was no UVs present for a mesh, I just edited that with a “if (_uvs) {...}”)

Because if you save the model, all Meshes don’t get saved with their absolute vertex positions in the scene, but with their local vertex positions and additional transformation information like scale, position and rotation. You have to actually “move” those vertexes to their world-positions by just applying each mesh’s transformation to itself. To not destroy the visual object, I just created clones of the geometry.

Wouldn’t it be better to pass a whole Mesh-Object with it’s transformation to the AWPBvhTriangleMeshShape constructor instead of just the geometry?

This way, you can also build a CompoundShape of many meshes.
Yay, finally got this working now smile

   

Durrab Khan, Newbie
Posted: 25 June 2013 08:45 PM   Total Posts: 2   [ # 15 ]

I am also facing the same problem - no collision with AWPCompoundShape even I make it static and I am dropping the balls on it but all the balls just fall down.

I tried your solution but it does not work - If I give scalling of any amount then it just shows me the blank screen and if I remove the scaling then same effect - No collision no static body and just balls fall down.

I am looking for a solution - please help me out.

Thanks

Durrab

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X