Horde3D Tutorial
This small sample shows how easy it is to load an animated character with Horde3D.
NodeHandle model = 0; void initGame() { // Initialize engine Horde3D::init( "pipeline.xml" ); // Add model resource ResHandle modelRes = Horde3D::addResource( ResourceTypes::SceneGraph, "character.scene.xml", 0 ); // Add animation resource ResHandle animRes = Horde3D::addResource( ResourceTypes::Animation, "walk.anim.xml", 0 ); // Load added resources Horde3DUtils::loadResourcesFromDisk( "" ); // Add model to scene model = Horde3D::addNodes( RootNode, modelRes ); // Apply animation Horde3D::setupModelAnimStage( model, 0, animRes, "" ); // Add light source NodeHandle light = Horde3D::addLightNode( RootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" ); // Set light position and radius Horde3D::setNodeTransform( light, 0, 20, 0, 0, 0, 0, 1, 1, 1 ); Horde3D::setLightParam( light, LightNodeParams::Radius, 50.0f ); } void gameLoop() { static float t = 0; // Increase animation time t = t + 0.1f; // Play animation Horde3D::setModelAnimParams( model, 0, t, 1.0f ); // Set new model position Horde3D::setNodeTransform( model, t * 10, 0, 0, // Translation 0, 0, 0, // Rotation 1, 1, 1 ); // Scale } void releaseGame() { // Free engine Horde3D::release(); }
The sample above loads a character model together with a proper animation and adds the model
to the scene. Afterwards a light source is placed in the scene. In the main loop, the animation
sequence is played and the model is displaced a bit.
The sample assumes that OpenGL is already initialized. If you don't want to init OpenGL manually, you
can use the Horde3D utility function initOpenGL at the beginning and call releaseOpenGL when destroying
your application.
Copyright © 2006-2007 Nicolas Schulz