Horde3D

Next-Generation Graphics Engine
It is currently 28.11.2024, 21:01

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 12.11.2009, 20:58 
Offline

Joined: 23.10.2009, 19:35
Posts: 23
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?


Top
 Profile  
Reply with quote  
PostPosted: 13.11.2009, 00:59 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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).


Top
 Profile  
Reply with quote  
PostPosted: 14.11.2009, 20:05 
Offline

Joined: 23.10.2009, 19:35
Posts: 23
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.


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2009, 09:19 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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);


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2009, 20:36 
Offline

Joined: 23.10.2009, 19:35
Posts: 23
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).


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2009, 13:20 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2009, 21:45 
Offline

Joined: 23.10.2009, 19:35
Posts: 23
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...


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2009, 22:03 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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...
'pivot' in this instance just means the origin of the tyre's local space.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 18.11.2009, 01:25 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group