Turn Mesh Around its centermass

Blitz3D Forums/Blitz3D Programming/Turn Mesh Around its centermass

semar(Posted 2005) [#1]
Hi,
I export a model in .x or .3DS format, and load it into Blitz using LoadAnimMesh. The model itself is made by several objects (childs).

I can get all the childs using countchild and getchild from within Blitz.

The problem arises when I want to rotate a single object around an axis, for example the Y one.

In fact, the object does rotate, but the axis refers to the whole model axis, so the object does not turn among its Y axis, instead it follows a rounded path.

So I need to find out the way to rotate it as it where saved as single model, positioned at 0,0,0.

How can I achieve that ?

One way would be to put joints using Milkshape3D, assign the vertex to each joint, then re-export the model in .B3D, and then just find out each joint and turn it - the related vertices will then turn properly.

But this way is not very practical, because each time I modify the model (I use AC3D as modeller, but it has no joint capabilities), I have to re-import it into Mshape, add the joints, and re-export.

Anyone ?

Also, do you know how to turn on a snap-to-grid feature from within Milkshape ? The manual is rather poor..

Sergio.


Skurcey(Posted 2005) [#2]
you have to use loadanimmesh...


Damien Sturdy(Posted 2005) [#3]
Ummm, yep. He already stated he is..... o.O?


KuRiX(Posted 2005) [#4]
I think the problem is not the mesh orientation but the child initial orientation.

If you want to rotate a child over his own axis (global), put a ,1 parameter at the end of the rotate command.

RotateEntity child,rx,ry,rz,1


semar(Posted 2005) [#5]
Thanks KuRiX, but it does not work either.

If you want to try for yourself:
- build a model made of a cube and a cylinder; move the cylinder away from the axis origin (0,0,0)
- load the model from within blitz
- find the child cylinder
- rotate it using Rotateentity or Turnentity with the global parameter set to true as you suggested.

You will notice that the cylinder rotates among the original axis of the whole model, no matter if you set true the global parameter.

(you need an increasing angle if you use RotateEntity though:
angle = (angle + 1) mod 360
RotateEntity 0,angle,0,1
Anyway, thanks for your suggestion, even if it didn't work.
Sergio.


GfK(Posted 2005) [#6]
I had exactly the same problem with 3DS models exported from MS3D. You don't get this with 3DS exported from 3DS Max.

Other than that, I never worked out a solution to this problem.


Damien Sturdy(Posted 2005) [#7]
Semar.. Maybe you could iterate through the vertices, Get an average, "centre" the mesh using fitmesh, then positionentity the mesh back at your retrieved average?


semar(Posted 2005) [#8]
Hi Cygnus,
while I find your one a nice idea, I must confess it's quite unpractical for the results I'm trying to achieve.

After all, a couple of joints would solve the problem - I mean joints in Milkshape ;-) - it's a pity that AC3D does not have this capability.

Or better, just save each single mesh - in my case, a box and a wheel - and then from within Blitz, make 3 copies of the wheel, position at the right places, parent it to the box - done.

Thanks for the inputs though.

Sergio.


KuRiX(Posted 2005) [#9]
Ehh, i have made a basic 3d model, with a box, and a cylinder in the coordinates (10,10,10). Then i have found the child, and turnentity it, and it works!

Don't know the problem... I use 3dsmax


GfK(Posted 2005) [#10]
Don't know the problem... I use 3dsmax
Erm... the problem is he isn't using 3DS Max. Read my reply (above).


Damien Sturdy(Posted 2005) [#11]
hmm, Sorry it didnt do what you wanted. I was thniking of a blitz-side import fix... And for anyone else who reads it, itl be better to not take an average of all the vertices, just the lowest and highest of each x/y and z plane.


Let me know if you get it to work. i will find it useful at some point!


DQ(Posted 2005) [#12]
i did something similar, but don't know if it would work for you. i use milkshape3d (which doesn't really do the whole parent/child thing). the only 'children' that blitz3d will recognize from a model made in ms3d are the joints. so what i do is make a lone joint and then assign the verts of that model part to that joint, and then when i look for the child in blitz3d it will find the joint as a 'child'. weird, huh? anywho, i can place the joints to make the parts rotate on the axis i want. like i said, don't know if that will help, but thats all i got.

EDIT: or better yet, make a model joint(or tiny cube or something) as another child where you want the axis to be. then when you load the model in make that spot a pivot and then remove (or hide?) the model part (if it was a cube). would this even be worth it?


semar(Posted 2005) [#13]
@DQ,
thanks, I've tryed both the technique.

The joint solution is the one which works.

The second solution (the one in the [EDIT] section) does not work, because the 'tiny cube' will rotate too among the main model axis, so it would be affected by the same behaviour.

So far, the unique solution I've found is to use Joint. What a pity that AC3D does not have it natively - that is, I have to export the model, re-import in Milkshape, assign the joints, then export the model for Blitz.

Sometime I wonder why 3D modelling should be so complicated.

As far as I know, there's no software capable of doing all the 3D modelling tasks in a good way.

The software that does modelling is not good for joints/animation, the one for texturing is not good for modelling, the one which does a fine job with animation is not good for texturing, the other which can be used for applying joints is a nightmare at modelling,...

Sergio.