Difference between revisions of "Tutorial - Hello World"
From Horde3D Wiki
m |
|||
Line 45: | Line 45: | ||
The first line of the code above declares two global handles to Horde scene graph nodes. All objects in Horde are accessible via handles, a concept similar to pointers. The first thing we need to do in our initGame function to use Horde3D is initializing the engine. This happens with the function init. After that we tell the engine the size of our rendering window so that it can adjust the viewport. | The first line of the code above declares two global handles to Horde scene graph nodes. All objects in Horde are accessible via handles, a concept similar to pointers. The first thing we need to do in our initGame function to use Horde3D is initializing the engine. This happens with the function init. After that we tell the engine the size of our rendering window so that it can adjust the viewport. | ||
− | The next step is to load the required resources. In Horde resources are data files that are loaded once and can be referenced by several objects for rendering. The function addResource takes the resource type we want to add and the name of the resource (usually the filename) as parameters and returns a handle to the created resource object. In our case we want a model which is represented as a scene graph file in Horde and additionally an animation. Now the resources are created but we still need to load them. Horde supports loading from any sources including encrypted archives or a network but in this case we just want to load our resources from the local hard disk which is done with the utility function loadResourcesFromDisk. Besides our model and animation we also load a pipeline resource. A pipeline defines how the the scene is rendered and can be used to realize post-processing effects or high | + | The next step is to load the required resources. In Horde resources are data files that are loaded once and can be referenced by several objects for rendering. The function addResource takes the resource type we want to add and the name of the resource (usually the filename) as parameters and returns a handle to the created resource object. In our case we want a model which is represented as a scene graph file in Horde and additionally an animation. Now the resources are created but we still need to load them. Horde supports loading from any sources including encrypted archives or a network but in this case we just want to load our resources from the local hard disk which is done with the utility function loadResourcesFromDisk. Besides our model and animation we also load a pipeline resource. A pipeline defines how the the scene is rendered and can be used to realize post-processing effects or high dynamic range rendering. For the beginning you can just use the files that come with the SDK samples. |
After we have loaded the required resources we can finally build up the scene graph. The scene graph represents the objects in our virtual world in a hierarchical tree structure. First we add the model that we have loaded before. We use the function addNodes for doing this which takes a scene graph resource and a parent node. The parent is the scene object to which the new node is attached, in our case just the root node which is the base of the virtual world. Similar to addResource this function also returns a handle to the created scene graph subtree. After that we assign the loaded animation to our model node with the function setupModelAnimStage. Horde allows you to apply several different animations to a model and makes it possible to blend and mix them but for the beginning one should be enough. Now that adding the model is finished we still need a light source. It would be possible to load another scene graph file which contains the light source but we want to add it manually by using the addLightNode function. This function requires several parameters specifying the shaders used for rendering. More information on this can be found in other sections of the manual. The next step is to set the position and orientation which is done with setNodeTransform. After that we specify the light radius which defines the zone of influence using setLightParam. Finally we still need a camera which represents the viewer. It is added with the function addCameraNode and takes our loaded pipeline resource as parameter. | After we have loaded the required resources we can finally build up the scene graph. The scene graph represents the objects in our virtual world in a hierarchical tree structure. First we add the model that we have loaded before. We use the function addNodes for doing this which takes a scene graph resource and a parent node. The parent is the scene object to which the new node is attached, in our case just the root node which is the base of the virtual world. Similar to addResource this function also returns a handle to the created scene graph subtree. After that we assign the loaded animation to our model node with the function setupModelAnimStage. Horde allows you to apply several different animations to a model and makes it possible to blend and mix them but for the beginning one should be enough. Now that adding the model is finished we still need a light source. It would be possible to load another scene graph file which contains the light source but we want to add it manually by using the addLightNode function. This function requires several parameters specifying the shaders used for rendering. More information on this can be found in other sections of the manual. The next step is to set the position and orientation which is done with setNodeTransform. After that we specify the light radius which defines the zone of influence using setLightParam. Finally we still need a camera which represents the viewer. It is added with the function addCameraNode and takes our loaded pipeline resource as parameter. |