Need some feedback on rotating a mesh method

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Rat
Posts: 51
Joined: Wed Mar 10, 2004 7:05 am

Need some feedback on rotating a mesh method

Post by Rat »

As the title says, I need some feedback on rotating a mesh that I have put into my scene. Some of you may have seen the castle I have created, and it has doors. I am currently opening them by using the mouse with the door being an animated mesh. Well this works, but, for all intents and purposes isnt good in terms of memory cost, and collosion wise.

Now comes the problem, I can load the mesh like I do now, and have created a totaly differnt skeleton setup than I originaly had made where I was using a template of my scene with a joint for the base, and other joints spawning off of it to be connections for doors, and other things. I would simply create the entire level, and group meshes according to thier use, like doors. Then when ready to export, I would delete all the interaction items, and export what is left as a X file. Then I would individually export the interactive items with the same joints, and have them animated.

I got to thinking later that I may want to just use something that I read about Milkshape 3D meshes, and just attaching the object as a child, so I recreted them using thier own skeleton system, and would attach them to base joints that were ready for them from the scene, e.g. Door-base-joint1 and attach the door1's Door1-hinge joint as a child to the scenes joint ready made for it. Then set the frames for it.

Ok I never got around to this idea, and it sounded possiable, but when I set up this arrangement, and tested some things by loading all these objects without implementing the above idea in code, I found that the meshes load perfectly aligned without even using setposition, (Which come to think of it, it should!). So at present all I have to do is to set the proper frames to open and close the doors, no muss no fuss with attaching it as a child.

So now I decided that I want to just plain rotate the door without animation, so I fire up the code to rotate the puppys when I get to the point to open the door by using:

Code: Select all

    // do a little dance, make a little love, get down tonight! :D
    // old code when I animated the door
    //doornode1->setFrameLoop(0, 13);
    //doornode1->setAnimationSpeed(5);
    doornode1->setRotation(core::vector3df(0,-90,0));

    // turn off the use of the mouse opening the door
    mouse_left = 0;
The above code seems to take the door and spin it about either the worlds 0,0,0 axis or the base joint of the scene mesh, instead of the base joint of the door. As I have said, I have completly made a new skeleton for the door.

I may be misunderstanding the use of the setRotation function :oops: as it has
core::vector3df as a param. Do I need to use something else to rotate the mesh on its own axis?
tomato

Post by tomato »

i don't know if i got you completely, but it seems that your door mesh sould have vertecis with coordinates that in some way or the other touch the rotation axis.

if i'm not completely wrong then the rotation irrlicht does is always in respect to the point (0,0,0) of the scenenode you rotate! that is
setRotation(Vector3(10,20,30)) rotates 30 degrees around (1,0,0) 20 degrees around (0,1,0) and 30 degrees around (0,0,1)

ok, what this all leads to is the following:
1 ) build door models of their own.

2 ) if you want to open the door (rotate) it would be a good idea to have the axis (0,1,0) as one side of the door (in the mesh!) and do rotations with setRotation(0,ANGLE,0)

3 ) place your doors in the level at the correct place with setPosition(...)

hope that helps
the tomato
Rat
Posts: 51
Joined: Wed Mar 10, 2004 7:05 am

Post by Rat »

I thought I put in the information above that these doors are seperate mesh or models on thier own, and loaded on thier own. Apparently using the setRotation funtion works off the coordinates of the scene, and I get this from reading the h file defintion where it says relative position. That is why I am asking how to set it absolutly on its own axis from the skeleton joint that was created for this purpose. I have read where you can attach a joint that is a milkshape 3d mesh, and mine is a .x file.
Post Reply