Strange displacement [SOLVED]

Prophet

25-08-2008 16:24:47

Okay, I've basically asked this before in the pivot-thread, but it's different now.
I create Actor and Node with this code//Create actor
NxOgre::Actor* t = mScene->createActor("Box", new NxOgre::Cube (size), Vector3(0, 1000, 0), "mass: 1");

//Create scenenode
SceneNode* tn = mgr->getRootSceneNode()->createChildSceneNode(names.str(), t->getGlobalPositionAsOgreVector3());
//Create entity
Entity* te = mgr->createEntity(names.str(), "Box01.mesh");
//Attatch
tn->attachObject(te);
and sets the position each frame withtn->setPosition(a->getGlobalPositionAsOgreVector3());
tn->setOrientation(a->getGlobalOrientationAsOgreQuaternion());
but the node is half the size of the mesh up in y-axis. I made the mesh i 3ds Max and exported with oFusion. I've made sure it's the right size (the variable size is set to the exact same values as I had in 3ds Max and my experimenting shows it is). Don't think it makes a difference, but the box was placed on the "ground" in 3ds Max.
I'm quite confused, it worked so fine just a few hours ago!

Solution last post!

Prophet

27-08-2008 10:45:29

Okay, I've tried creating new meshes with new sizes and it's still the same problem. I printed the position of the actor and the node and they're both at the same coordinates.
However, loading an animated node with oFusion and then set the actors position to the nodes position works.
What gives?

betajaen

27-08-2008 10:56:50

Hmm. I don't know 3DsMax at all, but are you certain that the box is absolutely centered?

Say the box is 1m^3 in size, the upper right vertex of the box is 0.5 0.5 0.5? and not 0.5 1 0.5?

Prophet

27-08-2008 11:15:45

I create it with the base on the ground, so I guess it is 0.5 1 0.5, but it works for all other models, since oFusion only saves the mesh, regardless of where it's positioned.
I tested it though, and still the same thing.

betajaen

27-08-2008 11:27:09

Hmm. Would you try and move it down - just in case.

Prophet

27-08-2008 11:28:38

That's what I did. Still the same thing. Sorry if I was a bit unclear. :)

xadh00m

27-08-2008 12:49:14

We have a lot problems with placing objects in 3dsMax right.
You can use the "BoxTrick" to ensure you have all XForm and history stuff
out of your mesh before exporting it. Ofusion also recommends this technique.

BoxTrick:
Place your object where you want it in the result.
Create a new box and set position and rotation to zero.
Select EditMesh modifier of this box and attach your object to this box.
Now select the box (still in mesh modifier) and delete it. Now you have to
rename your object (because it is still named box_xx or so).
Every previous transformation is gone and you have a clean mesh in terms of transformation.

Prophet

27-08-2008 13:08:44

I'll be damned, that works! Thought it didn't matter as I didn't use the .osm file. Thanks a heap!

Rasengan

27-08-2008 13:17:27

What about "Reset Transform" option from XForm modifier in 3DS?
Also, MeshMagick can reset position (x|y|z|align = center), no?

Prophet

27-08-2008 13:20:51

I first tried with Rest Xform, but that didn't work (and from xadh00m's post I guessed it wouldn't). Didn't try MeshMagic, but I'll try it when I stumble on this problem again. But this isn't really NxOgre. :)

betajaen

27-08-2008 13:36:47

Post if you come up with a solution. Someones bound to have the same thing, and most likely come up with this thread.

Prophet

27-08-2008 14:09:34

Okay, results:
Reset X-form: Does not work.
MeshMagick: Works! Use "transform -(x/y/z)align=center <meshname>" (without quotes), where x/y/z is the axis to align with. Thank you Rasengan!
Boxtrick: Works! Thanks xadh00m!
BoxTrick:
Place your object where you want it in the result.
Create a new box and set position and rotation to zero.
Select EditMesh modifier of this box and attach your object to this box.
Now select the box (still in mesh modifier) and delete it. Now you have to
rename your object (because it is still named box_xx or so).
Every previous transformation is gone and you have a clean mesh in terms of transformation.


Edit: I did some additional research and it appears that this is only an issue when using shapes created by NxOgre (NxOgre::Cube, NxOgre::Sphere). If you create a box in 3ds Max, export it and the use Flour to convert it to a .nxs and load the shape from that file, the problem vanishes.
Hopefully someone will find this useful...

betajaen

27-08-2008 14:42:50

I'm glad you've got it fixed.

mcaden

27-08-2008 15:36:46

I'm pretty sure it has to do with local coordinates VS global coordinates.

The mesh .nxs would work of course because it would go off the coordinates in the .mesh file no matter what.