Horde3D

Next-Generation Graphics Engine
It is currently 29.09.2024, 00:20

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: scene mgmt?
PostPosted: 24.01.2009, 02:45 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
I'm trying to get my application to use my scene references. Few questions...

One) why do scene files always appear in the models folder? Should a scene not be in the scene folder? ( nit pick I know but just seem a bit strange )

two) How do you load a scene file in an application.

For example I have myScene.scene.xml

I can see from the examples how you load a reference
ResHandle knightRes = Horde3D::addResource( ResourceTypes::SceneGraph, "knight.scene.xml", 0 );

but If I move my night in the editor, say up 10. The application will not know about it, unless it knows about the myScene.scene.xml? Which makes the edit worthless, LOL.. Now I know its not intended this way, but non of the examples seem to show how this is done. Surly you need to load the main scene file, as it has all of the location information in it, right? And if that is the case you should not really have to load everything else, there should be a simple loadScene() and since the info is all right there in the myScene.scene.xml why not just load the assets. no?

I asked for a tutorial once and was told to see the Knight samples ( app.cpp line 83 ). but all that does is loads a reference. Any tutorials for loading a scene? The xml files that contains the "<Group name="myScene" >" ?


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 24.01.2009, 03:46 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
You must load resources from disk after adding them to scene. It's too simple, just call this : Horde3DUtils::loadResourcesFromDisk(&contentDir)
Code:
knight sample > app.cpp : line 90
   // Load resources
   Horde3DUtils::loadResourcesFromDisk( _contentDir.c_str() );
For more infos about H3DUtils have a lOOk @ Utility Library API Reference in Docs.

Hoping that this helps my friend :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 24.01.2009, 23:56 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
Thx Siavash, It looks like this function loads all of the added resource. Though it still does not know where to put the resource if it never opened the main scene file.

For example my main scene files is..
Code:
<!DOCTYPE HordeSceneGraph>
<Group name="MyScene" >
    <Camera pipeline="forward.pipeline.xml" topPlane="0.0414214" bottomPlane="-0.0414214" rx="-20"....
    <Light sy="1" lightingContext="LIGHTING" sz="1" col_B="1" name="Sun" col_G="1" tx="40" ty="40" ....
    <Reference tx="0" sx="6.13373" ty="-13.1884" sy="6.13373" tz="16.5886" rx="0" sceneGraph="../....
    <Reference tx="0" sx="100" ty="0" sy="100" tz="0" sceneGraph="../scene/skybox.scene.xml" ....
    <Terrain tx="-76.1167" sx="300" ty="-88.1834" sy="300" tz="-93.3721" sz="300" ....
</Group>

I would assume the tx,ty,tz are translations. But when the reference is added it puts it at 0,0,0 when the files clearly says 0,-13,16.5886.



That file has all of the placement vars in it, how do I tell the engine to look at that file for placement.

The way of thinking is I can just change the tx for one of my references and the translation of x will reflect in the game. Like wise if I move my reference in the editor up 10 the ty should subtract 10 and when loading my game the reference will now be 10 units higher.. At least that is what a level editor is to me, I could be the odd ball.


I hope I'm over looking the obvious here ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 09:27 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I'm not sure if I understood you correctly, but if you wanted to say, that the translation is not stored in the referenced file, but in the main scene file, that's done deliberately. The reason for that is that you can have the same file referenced more than one time. So if you would store the transformation in the e.g. knight.scene.xml file, each knight instance would be translated instead of the one you may wanted to translate.
That's why the transformation of the root node in referenced files will be overwritten by the one in the Reference node.
But you could add the scene file directly using addResource and addNodes. This way it would take the transformation of the root node.

If I misunderstood you, can you concretize your problem a bit?


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 11:45 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Volker wrote:
The reason for that is that you can have the same file referenced more than one time. So if you would store the transformation in the e.g. knight.scene.xml file, each knight instance would be translated instead of the one you may wanted to translate.
That's why the transformation of the root node in referenced files will be overwritten by the one in the Reference node.
This is a little offtopic : Then how to access them [instances of referenced file] in game ? I think that we can access them using findResource(ResourceTypes::Listtype, const char *name) function and *name is that predefined name in reference tag, and we must use different names for those instances. Another question : I'm not sure but would using same name for all of instances [in reference tag] make a conflict later in code ?

Thanks for your time.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 11:59 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Horde3D internally only uses dynamically assigned IDs (Handles) so it won't be a problem if one scene node has the same name as another one.
The name of the referenced instance is also set to the one defined in the Reference node ( all properties that can be defined in the reference node will be used in the instantiated node). So if you search for a concrete instance, you should set the name attribute in the reference node that creates this instance to a unique one.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 13:01 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
You mean that we must use this :
Code:
<!DOCTYPE HordeSceneGraph>
<Group name="funGroup" >

...

<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="unique1" />
<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="unique2" />
<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="unique3" />
...

</Group>
instead of : [incorrect one]
Code:
<!DOCTYPE HordeSceneGraph>
<Group name="funGroup" >

...

<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="same" />
<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="same" />
<Reference tx=0.1 ... sceneGraph="funModel.scene.xml" name="same" />
...

</Group>
to avoid conflicts. Then accessing them like this :
Code:
ResHandle uniqueRes1=findResource(SceneGraph, "unique1");
ResHandle uniqueRes2=findResource(SceneGraph, "unique2");
ResHandle uniqueRes3=findResource(SceneGraph, "unique3");
Thanks for help.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 13:45 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
You can do it this way, but you can also use the same name and iterate over the search results when calling findNodes and getNodeFindResult.
As already mentioned, a conflict can only occur on the application programmers side, not within Horde3D, since Horde3D does not care about the used name.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 25.01.2009, 22:06 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
Quote:
I'm not sure if I understood you correctly, but if you wanted to say, that the translation is not stored in the referenced file, but in the main scene file, that's done deliberately. The reason for that is that you can have the same file referenced more than one time. So if you would store the transformation in the e.g. knight.scene.xml file, each knight instance would be translated instead of the one you may wanted to translate.
That's why the transformation of the root node in referenced files will be overwritten by the one in the Reference node.


If I misunderstood you, can you concretize your problem a bit?


Well no I was not saying that rather I think the way you designed it is correct.. And I tink you answered my question.. by saying

Quote:
But you could add the scene file directly using addResource and addNodes. This way it would take the transformation of the root node.
This is what i cant find an example of. This is also the way it is done from what I know. The knight example does not do that, as far as I can see? Heck it does not even have a scn file root node...The only files that would resemble that is the "knight.scene.xml" and that is a geometry file. It never loads the root node as you call it. I need that root xml info some how, can I see an example.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 04:18 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
ulao wrote:
This is what i cant find an example of. This is also the way it is done from what I know. The knight example does not do that, as far as I can see? Heck it does not even have a scn file root node...The only files that would resemble that is the "knight.scene.xml" and that is a geometry file. It never loads the root node as you call it. I need that root xml info some how, can I see an example.
Everything has been xplained clearly in samples. If you have a closer lOOk at app.cpp [knight sample] Application::init() has been exactly placed there to load resources and place them in your scene [we call it root node] and every thing has been commented very well [both of chicago and knight]. Every thing that you must do is this :

1.Set paths for resources : Horde3DUtils::setResourcePath
2.Add resources : Horde3D::addResource
3.Load them : Horde3DUtils::loadResourcesFromDisk
4.Add scene nodes : Horde3D::addNodes, addCameraNode, addLightNode
5.Configure the scene : Horde3D::setNodeTransform, setNodeParam, setupModelAnimStage, ...
6.Enjoy your game

It's too easy my friend, just follow these lines [line : 45-128 / app.cpp] and never forget to ask your questions.

@Volker : correct me if I'm wrong somewhere :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 13:31 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Volker wrote:
You can do it this way, but you can also use the same name and iterate over the search results when calling findNodes and getNodeFindResult.
How to identify references/resources with same name [of one file]?


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 13:39 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Resource names have to be unique ( at least when the type is equal ), so identifying them can be done using findResource.

Scenegraph node names don't have to be unique, so you can iterate over nodes with equal names using findNodes and getNodeFindResult or you have to give them a unique name if you want to identify a reference node within the scene graph in a non-ambiguous way.


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 19:35 
Offline

Joined: 01.01.2009, 21:09
Posts: 54
Quote:
5.Configure the scene : Horde3D::setNodeTransform,
- I Dont want this?? I want it to load the translations from a file? This is what I'm asking. I have a perfectly good file that contains the transformation data, why would I want to set it in the engine if its all in a file ?

Quote:
and never forget to ask your questions
Perhaps I'm not think the same way you are. Here are some question that would help me..

1) Can I see an example that loads the transformation from a file.

2) Volker's statement. "But you could add the scene file directly using addResource and addNodes. This way it would take the transformation of the root node." - Can I see this example?

This is how I understand in the knight file. And it does what you said.

Add resources, has..
Pipelines ( ok I get that ) Add the pipeline
Font ( self explanatory )
Logo ( self explanatory )

Environment ( adds the sphere model )
Knight ( adds the knight model ) and then his animation.
Particle ( adds the partical model )

Load resources ( simply goes out to the content path and loads the above. )

THEN!!

// Add environment
NodeHandle env = Horde3D::addNodes( RootNode, envRes ); //adds the resource to a handle
Horde3D::setNodeTransform( env, 0, -20, 0, 0, 0, 0, 20, 20, 20 );//( POSITIONS the sphere, does not load the position from a file....)

// Add knight
_knight = Horde3D::addNodes( RootNode, knightRes );//adds the resource to a handle
Horde3D::setNodeTransform( _knight, 0, 0, 0, 0, 180, 0, 0.1f, 0.1f, 0.1f );//( POSITIONS the knight, does not load the position from a file....)


So my point? it sets the transformation in the game? If I open up the knight.scn ( that does not exit) and move the knight up 10 units, the engine would not reflect that. The engine should go out to a file and get the position data..


Siavash, I do appreciate your help, but I dont think we and understand each other. I hope to get this mystery solved. There has got to be a way to get the transformation data from a file..


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 20:16 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
So, if I understand you correctly, you want an example of how to directly load the .scn file as saved by the Scene Editor?

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: scene mgmt?
PostPosted: 26.01.2009, 22:26 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
ulao wrote:
So my point? it sets the transformation in the game? If I open up the knight.scn ( that does not exit) and move the knight up 10 units, the engine would not reflect that. The engine should go out to a file and get the position data..

You can store an initial transformation for the model in the scene graph file but you are free to overwrite that in your application (we are doing that in the Knight sample). If you really want to do that depends on your application.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 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