OBJ / Box Shape

Software: Away3D 4.x

Avatar
Fabrice Closier, Administrator
Posted: 06 December 2011 04:28 PM   Total Posts: 1265   [ # 16 ]

Have you tried with new update?
You have now a AssetEvent.MESH_COMPLETE. Just keep track of all the meshes that you want to add a rigidBody to. Loop over this array or Vector.<Mesh> and apply on LoaderEvent.RESOURCE_COMPLETE.

   

Avatar
mrpinc, Sr. Member
Posted: 06 December 2011 04:41 PM   Total Posts: 119   [ # 17 ]

I did try with the new code, and the code certainly helps by not reentering the meshes but what I am trying to achieve is to apply the physics bounding box to the loaded OBJ which might have a handful of meshes.  The example I posted just previous does work assuming that there is only 1 mesh as a child of the Loader3D object.

I just got a different approach to work for the loader 3D - here is the code:

Bounds.getObjectContainerBounds(loader3D);
var 
dx:Number = (Bounds.minX+Bounds.maxX)*.5;
 var 
dy:Number = (Bounds.minY+Bounds.maxY)*.5;
var 
dz:Number = (Bounds.minZ+Bounds.maxZ)*.5;
   
applyPositionChangeloader3D, -dx, -dy, -dz);

var 
b:AWPRigidBody = new AWPRigidBodypShapeloader3Dmass); 
b.+= dx;
b.+= dy;
b.+= dz;

private function 
applyPositionChange(renderableContainer:ObjectContainer3Ddx:Numberdy:Numberdz:Number):void 
{
 
var nc:int renderableContainer.numChildren;
 if (
nc 0)
 
{
  
for (var i:int 0nci++) 
  
{
   
var oc3d:ObjectContainer3D renderableContainer.getChildAt);
     
   
applyPositionChange(oc3ddxdydz);
     
   
oc3d.+= dx;
   
oc3d.+= dy;
   
oc3d.+= dz;
  
}    
 }

 

   
   
‹‹ Gravity problem

X

Away3D Forum

Member Login

Username

Password

Remember_me



X