public void init() { // Init random generator _rand = new Random((int)DateTime.Now.Ticks); // Load character with walk animation int characterRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "man.scene.xml", 0); int characterWalkRes = Horde3D.addResource(Horde3D.ResourceTypes.Animation, "man.anim", 0); Horde3DUtils.loadResourcesFromDisk("content"); // Add characters for (int i = 0; i < 100; ++i) { Particle p = new Particle(); // Add character to scene and apply animation p.node = Horde3D.addNodes(Horde3D.RootNode, characterRes); Horde3D.setupModelAnimStage(p.node, 0, characterWalkRes, string.Empty, false); // Characters start in a circle formation p.px = (float)Math.Sin((i / 100.0f) * 6.28f) * 20.0f; p.pz = (float)Math.Cos((i / 100.0f) * 6.28f) * 20.0f; chooseDestination(ref p); Horde3D.setNodeTransform(p.node, p.px, 0.02f, p.pz, 0, 0, 0, 1, 1, 1); _particles.Add(p); } }
public bool init() { // Initialize engine if (!Horde3D.init()) { Horde3DUtils.dumpMessages(); return(false); } // Set paths for resources Horde3D.setResourcePath(Horde3D.ResourceTypes.SceneGraph, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Geometry, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Animation, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Material, "materials"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Code, "shaders"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Shader, "shaders"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Texture2D, "textures"); Horde3D.setResourcePath(Horde3D.ResourceTypes.TextureCube, "textures"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Effect, "effects"); // Load pipeline configuration if (!Horde3D.loadPipelineConfig("pipeline_Knight.xml")) { Horde3DUtils.dumpMessages(); return(false); } // Set options Horde3D.setOption(Horde3D.EngineOptions.LoadTextures, 1); Horde3D.setOption(Horde3D.EngineOptions.TexCompression, 0); Horde3D.setOption(Horde3D.EngineOptions.FastAnimation, 0); Horde3D.setOption(Horde3D.EngineOptions.AnisotropyFactor, 8); Horde3D.setOption(Horde3D.EngineOptions.ShadowMapSize, 2048); // Add resources // Font _fontMatRes = Horde3D.addResource(Horde3D.ResourceTypes.Material, "font.material.xml", 0); // Logo _logoMatRes = Horde3D.addResource(Horde3D.ResourceTypes.Material, "logo.material.xml", 0); // Environment int envRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "scene.scene.xml", 0); // Knight int knightRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "knight.scene.xml", 0); int knightAnim1Res = Horde3D.addResource(Horde3D.ResourceTypes.Animation, "knight_order.anim", 0); int knightAnim2Res = Horde3D.addResource(Horde3D.ResourceTypes.Animation, "knight_attack.anim", 0); // Particle system int particleSysRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "particleSys1.scene.xml", 0); // Load resources Horde3DUtils.loadResourcesFromDisk("content"); // Add scene nodes // Add environment Horde3D.addNodes(Horde3D.RootNode, envRes); // Add knight _knight = Horde3D.addNodes(Horde3D.RootNode, knightRes); Horde3D.setNodeTransform(_knight, 0, 0, 0, 0, 180, 0, 0.1f, 0.1f, 0.1f); Horde3D.setupModelAnimStage(_knight, 0, knightAnim1Res, string.Empty, false); Horde3D.setupModelAnimStage(_knight, 1, knightAnim2Res, string.Empty, false); // Attach particle system to hand joint int hand = Horde3D.getNodeChild(_knight, "Bip01_R_Hand", 0, true); _particleSys = Horde3D.addNodes(hand, particleSysRes); Horde3D.setNodeTransform(_particleSys, 0, 40, 0, 90, 0, 0, 1, 1, 1); // Add light source int light = Horde3D.addLightNode(Horde3D.RootNode, "Light1", 0, "LIGHTING", "SHADOWMAP"); Horde3D.setNodeTransform(light, 0, 1, 15, 30, 0, 0, 1, 1, 1); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Radius, 30); Horde3D.setLightParam(light, Horde3D.LightNodeParams.FOV, 90); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowMapCount, 1); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowMapBias, 0.01f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_R, 1.0f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_G, 0.7f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_B, 0.7f); // Customize post processing effects int matRes = Horde3D.findResource(Horde3D.ResourceTypes.Material, "postHDR.material.xml"); // hdrParams: exposure, brightpass threshold, brightpass offset Horde3D.setMaterialUniform(matRes, "hdrParams", 2.5f, 0.6f, 0.06f, 0); _initialized = true; return(true); }
public bool init() { // Initialize engine if (!Horde3D.init()) { Horde3DUtils.dumpMessages(); return(false); } // Set paths for resources Horde3D.setResourcePath(Horde3D.ResourceTypes.SceneGraph, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Geometry, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Animation, "models"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Material, "materials"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Code, "shaders"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Shader, "shaders"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Texture2D, "textures"); Horde3D.setResourcePath(Horde3D.ResourceTypes.TextureCube, "textures"); Horde3D.setResourcePath(Horde3D.ResourceTypes.Effect, "effects"); // Load pipeline configuration if (!Horde3D.loadPipelineConfig("pipeline_Chicago.xml")) { Horde3DUtils.dumpMessages(); return(false); } // Set options Horde3D.setOption(Horde3D.EngineOptions.LoadTextures, 1); Horde3D.setOption(Horde3D.EngineOptions.TexCompression, 0); Horde3D.setOption(Horde3D.EngineOptions.AnisotropyFactor, 8); Horde3D.setOption(Horde3D.EngineOptions.ShadowMapSize, 2048); Horde3D.setOption(Horde3D.EngineOptions.FastAnimation, 0); // Add resources // Font _fontMatRes = Horde3D.addResource(Horde3D.ResourceTypes.Material, "font.material.xml", 0); // Logo _logoMatRes = Horde3D.addResource(Horde3D.ResourceTypes.Material, "logo.material.xml", 0); // Shader for deferred shading int lightMatRes = Horde3D.addResource(Horde3D.ResourceTypes.Material, "light.material.xml", 0); // Environment int envRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "scene.scene.xml", 0); // Skybox //int skyBoxRes = Horde3D.addResource(Horde3D.ResourceTypes.SceneGraph, "skybox.scene.xml", 0); // Load resources Horde3DUtils.loadResourcesFromDisk("content"); // Add scene nodes // Add environment Horde3D.addNodes(Horde3D.RootNode, envRes); // Add skybox //int sky = Horde3D.addNodes( Horde3D.RootNode, skyBoxRes ); //Horde3D.setNodeTransform(sky, 0, 0, 0, 0, 0, 0, 210, 50, 210); // Add light source int light = Horde3D.addLightNode(Horde3D.RootNode, "Light1", lightMatRes, "LIGHTING", "SHADOWMAP"); Horde3D.setNodeTransform(light, 0, 25, -25, -120, 0, 0, 1, 1, 1); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Radius, 100); Horde3D.setLightParam(light, Horde3D.LightNodeParams.FOV, 90); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowMapCount, 3); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowSplitLambda, 0.95f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_R, 0.98f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_G, 0.6f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_B, 0.5f); // Add light source light = Horde3D.addLightNode(Horde3D.RootNode, "Light2", lightMatRes, "LIGHTING", "SHADOWMAP"); Horde3D.setNodeTransform(light, 0, 25, 30, -60, 0, 0, 1, 1, 1); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Radius, 50); Horde3D.setLightParam(light, Horde3D.LightNodeParams.FOV, 90); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowMapCount, 3); Horde3D.setLightParam(light, Horde3D.LightNodeParams.ShadowSplitLambda, 0.95f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_R, 0.5f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_G, 0.6f); Horde3D.setLightParam(light, Horde3D.LightNodeParams.Col_B, 0.98f); _crowdSim = new CrowdSim(); _crowdSim.init(); _initialized = true; return(true); }