ulao wrote:
like Volker said "you could add the scene file directly using addResource and addNodes. This way it would take the transformation of the root node." but I cant figure that out?
It works exactly the same as in the Knight sample, except you have to use findNodes to get handles to the objects within the scene.
First you use addResource/loadResourcesFromDisk to load your XML file into horde, then you use addNodes to actually create the nodes which are described within the XML file.
A "scene.xml" file can just load a model (like in the knight sample) but they can also load any other kind of scene-nodes (group, model, joint, light, camera, etc....). In your example file, the root XML tag is a "<Group>" tag, so when you call addNodes using that resource, then a group node will be created:
Code:
//add the scene file
ResHandle mySceneRes = Horde3D::addResource( ResourceTypes::SceneGraph, "myScene.scene.xml", 0 );
//load it from disk
Horde3DUtils::loadResourcesFromDisk( "content" );
//use the resource to create some scene nodes
NodeHandle sceneRoot = Horde3D::addNodes( RootNode, mySceneRes );
sceneRoot should be a "group node" named "MyScene". It will have a camera node, light node, terrain node, etc as children.
To get handles to these child-nodes, you can search for them by name, like this:
Code:
//Starting at "sceneRoot", look through all children for a light node named "Sun"
int numResults = findNodes( sceneRoot, "Sun", SceneNodeTypes::Light );
assert( numResults == 1 )//there should be one result
NodeHandle lightNode = getNodeFindResult(0);//get the first result (i.e. 0th result)
assert( lightNode != 0 )//the result should be valid