Horde3D http://horde3d.org/forums/ |
|
Rotating node in local space http://horde3d.org/forums/viewtopic.php?f=2&t=1007 |
Page 1 of 1 |
Author: | EsaK [ 12.11.2009, 20:58 ] |
Post subject: | Rotating node in local space |
I have a car model for which I try to rotate one of it's wheels through h3dSetNodeTransform(). (The wheels are subnodes or actually submeshes in the car model.) But this seems to rotate it in the parent's (car's) local space... I thought this function would rotate the node in it's own local space... Have i misunderstood this function or am I doing something wrong? |
Author: | DarkAngel [ 13.11.2009, 00:59 ] |
Post subject: | Re: Rotating node in local space |
My understanding is that that function *sets the local space* of the wheel. i.e. that function tells the wheel what it's local space is, relative to it's parent. To get the functionality that you want, you may need to insert a group node in between the car and the wheel. e.g. Car -> Parent-to-Local node -> Wheel Then you can modify the wheel's transform, while keeping it in the right position (the intermediate "parent-to-local" node would define the local space of the wheel). |
Author: | EsaK [ 14.11.2009, 20:05 ] |
Post subject: | Re: Rotating node in local space |
I don't get it... I have tried with the following code: H3DRes testRes = h3dAddResource( H3DResTypes::SceneGraph, "models/car/car.scene.xml", 0 ); H3DNode test = h3dAddNodes( H3DRootNode, testRes ); h3dSetNodeTransform( test, 0, 0, 0, 0, 0, 0, 1, 1, 1 ); h3dFindNodes(test, "Cylinder-0", H3DNodeTypes::Mesh); H3DNode tire = h3dGetNodeFindResult(0); h3dSetNodeTransform(tire, 0, 0, 0, 0, 90, 0, 1, 1, 1); ... and then with this code: H3DRes testRes = h3dAddResource( H3DResTypes::SceneGraph, "models/car/car.scene.xml", 0 ); H3DNode parent = h3dAddGroupNode(H3DRootNode, "modelnode"); H3DNode test = h3dAddNodes( parent, testRes ); h3dSetNodeTransform( test, 0, 0, 0, 0, 0, 0, 1, 1, 1 ); h3dFindNodes(test, "Cylinder-0", H3DNodeTypes::Mesh); H3DNode tire = h3dGetNodeFindResult(0); h3dSetNodeTransform(tire, 0, 0, 0, 0, 90, 0, 1, 1, 1); But I don't get the correct rotation in local space for the wheel (tire)... Any help here would be highly appreciated. |
Author: | Volker [ 15.11.2009, 09:19 ] |
Post subject: | Re: Rotating node in local space |
EsaK wrote: H3DRes testRes = h3dAddResource( H3DResTypes::SceneGraph, "models/car/car.scene.xml", 0 );
H3DNode test = h3dAddNodes( H3DRootNode, testRes ); h3dSetNodeTransform( test, 0, 0, 0, 0, 0, 0, 1, 1, 1 ); h3dFindNodes(test, "Cylinder-0", H3DNodeTypes::Mesh); H3DNode tire = h3dGetNodeFindResult(0); // Get parent of tire to transform the tire H3DNode tireParent = h3dGetNodeParent( tire ); h3dSetNodeTransform(tireParent, 0, 0, 0, 0, 90, 0, 1, 1, 1); |
Author: | EsaK [ 15.11.2009, 20:36 ] |
Post subject: | Re: Rotating node in local space |
That didn't work for me. I think the problem in my case is the model I use... the model (scene-file) that gets generated for me by colladaconv contains just a lot of meshes (for the different parts of the car), without any tx/ty/tz, rx/ry/rz and sx/sy/sz. I did a little test by creating a new car model, without one tire, and then a second model with just the tire centered around x and z-axes. When displaying these two models in horde3d and rotating the tire 90 degrees around the y-axis it works correctly. The problem in this case is positioning (translating) the tire to the correct place relative rest of the car. As you probably already guessed I'm a total newbie to 3D modelling... so my question now is what I'm doing wrong in the car model? ... I guess the tires of the car somehow needs to be placed relatively to the center point of the car, but I have no clue how this is done... btw, I'm using Wings3D (which I find relatively newbie-friendly). |
Author: | marciano [ 17.11.2009, 13:20 ] |
Post subject: | Re: Rotating node in local space |
I guess you need to set the pivot of the tires correctly in your modeling tool, so that it is at the center of the tire. |
Author: | EsaK [ 17.11.2009, 21:45 ] |
Post subject: | Re: Rotating node in local space |
marciano wrote: I guess you need to set the pivot of the tires correctly in your modeling tool, so that it is at the center of the tire. Is pivot a general term in modeling tools? ... I can't find it in Wings3D... |
Author: | swiftcoder [ 17.11.2009, 22:03 ] |
Post subject: | Re: Rotating node in local space |
EsaK wrote: marciano wrote: I guess you need to set the pivot of the tires correctly in your modeling tool, so that it is at the center of the tire. Is pivot a general term in modeling tools? ... I can't find it in Wings3D... |
Author: | DarkAngel [ 18.11.2009, 01:25 ] |
Post subject: | Re: Rotating node in local space |
If your modelling tool doesn't let you set the pivot/origin, then you can do it by inserting a dummy object/node in the hierarchy between the car body and the wheel. Place the dummy object where you want the wheel to be attached to the body, then place the wheel on top of the dummy object. Make sure the hierarchy is: car <- dummy <- wheel, and the wheel is at the same location as the dummy. Then in your game, when Horde moves the wheel, it will move it as if the dummy object is it's origin point. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |