enable mesh collision without physics

Software: Away3D 4.x

Avatar
oladitan, Member
Posted: 02 August 2012 02:09 AM   Total Posts: 71

hello. is there a way to enable collisions for one mesh with another without using physics. In this way a mesh will be unable to penetrate another. Is this achieved using a bounding box of bounding sphere, or is there a way to create a collision mesh using the models triangles directly? thank you.

   

Richard Olsson, Administrator
Posted: 02 August 2012 08:04 AM   Total Posts: 1192   [ # 1 ]

If you want to do per-triangle collision, you really should use a physics engine simply for the sake of optimization. If not, you can of course implement it yourself, but there is no feature for that in Away3D (since AwayPhysics takes care of that.)

However, if the shape of your objects allow, you can of course just rely on bounds and implement a simple AABB or bounding sphere collision detection on your own. Again, Away3D does not support any collision detection like that, but you can rely on the existing functionality for bounds calculation and take it from there.

   

Avatar
oladitan, Member
Posted: 04 August 2012 12:12 AM   Total Posts: 71   [ # 2 ]

ok. thank you Richard.

I have created a AxisAlignedBounding box from my mesh :

var boundingBox:AxisAlignedBoundingBox = new AxisAlignedBoundingBox()
boundingBox.fromGeometry(mesh.geometry); 

in have basic movement control for my mesh on all three axis. I have a scene mesh called sceneMesh. How do I make my mesh stop when it hits sceneMesh using boundingBox? thank you.

   

Richard Olsson, Administrator
Posted: 04 August 2012 08:05 AM   Total Posts: 1192   [ # 3 ]

You don’t have to create your own bounding box. All meshes already have one assigned to their “bounds” property (Mesh.bounds).

Just use regular AABB (Axis-aligned bounding box) collision. You should be able to google “AABB collision”. It’s basically a matter of comparing the max values of one box with the min values of the other, and vice versa, thereby making sure that the two don’t overlap. It’s a fairly simple programming problem (and not exclusive to Away3D or even 3D, since it can be done in 2D as well) so I urge you for your own sake to try and solve it yourself first. It’s a good exercise.

   

Avatar
oladitan, Member
Posted: 05 August 2012 01:50 AM   Total Posts: 71   [ # 4 ]

ok. I have made the bounding box for my mesh visable. currently the mesh bounding box stays put no matter how or where my mesh moves. I would like the bounds to change dynamically with my character. I thought the way to do this would be to call

mesh.updateBounds(); 

within the onEnterFrame method.

I am unable to call the updateBounds method for my mesh. when i try I get this error

ErrorAttempted access of inaccessible method updateBounds through a reference with static type away3d.entities:Mesh

thank you.

 

   

Richard Olsson, Administrator
Posted: 05 August 2012 08:07 AM   Total Posts: 1192   [ # 5 ]

What do you mean by “made it visible”? Did you set the showBounds property to true? In that case, the bounds should move with the mesh and you don’t have to call any methods. Just change the transform properties (i.e. x, y, z, scaleX, rotationX et c) on the mesh.

   

Avatar
oladitan, Member
Posted: 07 August 2012 03:23 AM   Total Posts: 71   [ # 6 ]

yes. i mean that i set showBounds to true. I have applied two separate rotations to my mesh

mesh.rotate(new Vector3D(010), 90);
mesh.rotate(new Vector3D(100), 180); 

the bounding box follows the first one but not the second.

also my mesh is an md5 mesh with animation applied. the bounding box does not change to accomadate the animation. only the static non animated mesh. Is there a way to make the bounding box be affected by the mesh animation?

   

Richard Olsson, Administrator
Posted: 07 August 2012 08:53 AM   Total Posts: 1192   [ # 7 ]

If the visual bounds do not update correctly as your object moves around, that sounds like a bug. Please file it through the GitHub issue tracker.

There is currently no way to have the bounds update with animation, because it would be much too heavy. We are thinking about ways to solve this, e.g. using an optional pre-processing step for when it is deemed necessary.

   

Avatar
oladitan, Member
Posted: 10 August 2012 06:39 AM   Total Posts: 71   [ # 8 ]

ok. https://github.com/away3d/away3d-core-fp11/issues/385 Issue #385.
thanks

   
   
‹‹ Custom shaders

X

Away3D Forum

Member Login

Username

Password

Remember_me



X