Difference between revisions of "Tutorial - Setup Horde with SDL"
From Horde3D Wiki
(make it work) |
(Updated the code to work with Beta4 and SVN trunk.) |
||
Line 14: | Line 14: | ||
using namespace std; | using namespace std; | ||
− | + | H3DNode model = 0, cam = 0; | |
int main(int argc, char* args[]){ | int main(int argc, char* args[]){ | ||
Line 39: | Line 39: | ||
//Inits Horde3D | //Inits Horde3D | ||
− | + | h3dInit(); | |
//Sizes the Horde3D View | //Sizes the Horde3D View | ||
− | + | h3dResize( 0, 0, 800, 600 ); | |
// Add pipeline resource | // Add pipeline resource | ||
− | + | H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "standard.pipeline.xml", 0 ); | |
// Add model resource | // Add model resource | ||
− | + | H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "character.scene.xml", 0 ); | |
// Add animation resource | // Add animation resource | ||
− | + | H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "walk.anim.xml", 0 ); | |
// Load added resources | // Load added resources | ||
− | + | h3dutLoadResourcesFromDisk( "" ); | |
// Add model to scene | // Add model to scene | ||
− | model = | + | model = h3dAddNodes( H3DRootNode, modelRes ); |
// Apply animation | // Apply animation | ||
− | + | h3dSetupModelAnimStage( model, 0, animRes, "", false ); | |
// Add light source | // Add light source | ||
− | + | H3DNode light = h3dAddLightNode( H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" ); | |
// Set light position and radius | // Set light position and radius | ||
− | + | h3dSetNodeTransform( light, 0, 20, 0, 0, 0, 0, 1, 1, 1 ); | |
//Sets the lightnodes radius | //Sets the lightnodes radius | ||
− | + | h3dSetNodeParamf( light, H3DLight::RadiusF, 0, 50 ); | |
//Sets the lightnodes Field of view | //Sets the lightnodes Field of view | ||
− | + | h3dSetNodeParamf( light, H3DLight::FovF, 0, 90 ); | |
//Sets the lightnodes ShadowMapCOunt | //Sets the lightnodes ShadowMapCOunt | ||
− | + | h3dSetNodeParami( light, H3DLight::ShadowMapCountI, 0, 3 ); | |
//Sets the lightnodes ShadowSplitLambda | //Sets the lightnodes ShadowSplitLambda | ||
− | + | h3dSetNodeParamf( light, H3DLight::ShadowSplitLambdaF, 0, 0.9f ); | |
//Sets the lightnodes ShadowMapBias | //Sets the lightnodes ShadowMapBias | ||
− | + | h3dSetNodeParamf( light, H3DLight::ShadowMapBiasF, 0, 0.001f ); | |
//Sets the lightnodes red value | //Sets the lightnodes red value | ||
− | + | h3dSetNodeParamf( light, H3DLight::ColorF3, 0, 0.9f ); | |
//Sets the lightnodes green value | //Sets the lightnodes green value | ||
− | + | h3dSetNodeParamf( light, H3DLight::ColorF3, 1, 0.7f ); | |
//Sets the lightnodes blue value | //Sets the lightnodes blue value | ||
− | + | h3dSetNodeParamf( light, H3DLight::ColorF3, 2, 0.75f ); | |
// Add camera | // Add camera | ||
− | cam = | + | cam = h3dAddCameraNode( RootNode, "Camera", pipeRes ); |
// Our While loop | // Our While loop | ||
Line 99: | Line 99: | ||
// Play animation | // Play animation | ||
− | + | h3dSetModelAnimParams( model, 0, t, 1.0f ); | |
// Set new model position | // Set new model position | ||
− | + | h3dSetNodeTransform( model, t * 10, 0, 0, // Translation | |
0, 0, 0, // Rotation | 0, 0, 0, // Rotation | ||
1, 1, 1 ); // Scale | 1, 1, 1 ); // Scale | ||
// Render scene | // Render scene | ||
− | + | h3dRender( cam ); | |
//Swaps the sdl opengl buffers | //Swaps the sdl opengl buffers | ||
Line 112: | Line 112: | ||
} | } | ||
//Releases the Horde3D Engine | //Releases the Horde3D Engine | ||
− | + | h3dRelease(); | |
//Releases SDL and quits the program | //Releases SDL and quits the program | ||
SDL_Quit(); | SDL_Quit(); | ||
} | } | ||
− | |||
− | |||
− | |||
</source> | </source> | ||
}} | }} |
Revision as of 15:27, 28 June 2010
|
|