move OBJ to (0,0,0)

Software: Away3D 4.x

pool338, Jr. Member
Posted: 20 July 2012 07:31 AM   Total Posts: 37   [ # 16 ]

So after the big help of Richard (many Thanks again), I was able to center a loaded model at (0,0,0).

But there is one thing left to do:
When I rotate the model, it still rotates along its original center and not around the stages center. My workaround till now is to move the camera around the model, looking at (0,0,0), but I would like to rotate the model instead.

Is there a possability to set the models center to a different point (0,0,0 for example)?

   

Richard Olsson, Administrator
Posted: 20 July 2012 10:23 AM   Total Posts: 1192   [ # 17 ]

When you say “model”, are you talking about a container (e.g. a Loader3D) or a mesh? From the rest of the thread, it seems like you have several meshes in a container. So the easiest solution to your problem would be to just move the meshes within the container, instead of moving your container. Then you can rotate the container.

Otherwise, take a look at moving the pivot point of a mesh, using the pivotPoint property or movePivot() method on the mesh.

   

pool338, Jr. Member
Posted: 20 July 2012 10:34 AM   Total Posts: 37   [ # 18 ]

U are right, I moved a Loader3D Container till now. Moving each Mesh sure is a possabilaty, but computing the postion where to move tha mesh isn’t as easy as computing it for the complete container i think !?

Just tried to use your formula, which works perfectly on the container, for each mesh and the result is a completely destroyed modell.

Bounds.getMeshBounds(mesh);
     
min_x Bounds.minX;
      
min_y Bounds.minY;
      
min_z Bounds.minZ;
      
      
max_x Bounds.maxX;
      
max_y Bounds.maxY;
      
max_z Bounds.maxZ;
     
mesh.moveTo(( -(max_x min_x) / 2) - min_x, ( -(max_y min_y) / 2) - min_y, ( -(max_z min_z) / 2) - min_z); 
   

Richard Olsson, Administrator
Posted: 20 July 2012 10:42 AM   Total Posts: 1192   [ # 19 ]

You should still calculate the distance using the bounds of the container, and then just apply the translation (the same as you would to the container) to each of the meshes. The meshes should all be moved the same amount as the container would have.

   

pool338, Jr. Member
Posted: 20 July 2012 11:23 AM   Total Posts: 37   [ # 20 ]

Sure…You are always right wink

Now it works like a charm.

Thanks again.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X