From ef8f4aad6a1bc2f6d76d055c9307dc1073007f9a Mon Sep 17 00:00:00 2001 From: Mathias Gottschlag Date: Tue, 3 Mar 2009 21:16:40 +0100 Subject: [PATCH] Fixed the sun, added a simple sky box. --- extra/horde3d/shaders/terrain.shader | 7 +++++++ src/eal/horde3d/camera.cc | 6 ++++++ src/eal/horde3d/camera.hh | 11 +++++++++++ src/eal/horde3d/environment.cc | 25 +++++++++++++++---------- src/eal/horde3d/environment.hh | 2 ++ 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/extra/horde3d/shaders/terrain.shader b/extra/horde3d/shaders/terrain.shader index 8e92870..a85e0b5 100644 --- a/extra/horde3d/shaders/terrain.shader +++ b/extra/horde3d/shaders/terrain.shader @@ -13,6 +13,13 @@ + + + + diff --git a/src/eal/horde3d/camera.cc b/src/eal/horde3d/camera.cc index de03e94..1ac1d5e 100644 --- a/src/eal/horde3d/camera.cc +++ b/src/eal/horde3d/camera.cc @@ -40,6 +40,7 @@ namespace eal position[0] = 0; position[1] = 500; position[2] = 500; + sun = 0; } Horde3DCamera::~Horde3DCamera() { @@ -108,5 +109,10 @@ namespace eal position[0] += sinf( degToRad( rotation[0] + 90 ) ) * curVel; position[2] += cosf( degToRad( rotation[0] + 90 ) ) * curVel; } + + // Set sun position + float camx, camz; + Horde3D::getNodeTransform(camera, &camx, 0, &camz, 0, 0, 0, 0, 0, 0); + Horde3D::setNodeTransform(sun, camx, 2000, camz, -90, 0, 0, 1, 1, 1); } } diff --git a/src/eal/horde3d/camera.hh b/src/eal/horde3d/camera.hh index fbae88a..681f85b 100644 --- a/src/eal/horde3d/camera.hh +++ b/src/eal/horde3d/camera.hh @@ -45,10 +45,21 @@ namespace eal getAngles(); void update(float mx, float my, bool w, bool a, bool s, bool d); + + void setSun(int sun) + { + this->sun = sun; + } + + int getSceneNode(void) + { + return camera; + } private: int camera; float rotation[2]; float position[3]; + int sun; }; } diff --git a/src/eal/horde3d/environment.cc b/src/eal/horde3d/environment.cc index ea6d8f9..1931d30 100644 --- a/src/eal/horde3d/environment.cc +++ b/src/eal/horde3d/environment.cc @@ -22,6 +22,7 @@ #include "eal/horde3d/environment.hh" #include "eal/horde3d/engine.hh" #include "eal/horde3d/extensions/extensions.hh" +#include "eal/horde3d/camera.hh" #include #include @@ -158,10 +159,10 @@ namespace eal ResHandle lightMatRes = Horde3D::addResource( ResourceTypes::Material, "materials/light.material.xml", 0 ); ((Horde3DEngine*)Engine::get())->loadResources(); // Create terrain - /*int skybox = Horde3D::addResource(ResourceTypes::SceneGraph, "models/skybox/skybox.scene.xml", 0); + int skybox = Horde3D::addResource(ResourceTypes::SceneGraph, "models/skybox/skybox.scene.xml", 0); ((Horde3DEngine*)Engine::get())->loadResources(); - sky = Horde3D::addNodes(RootNode, skybox); - Horde3D::setNodeTransform(sky, 0, 0, 0, 0, 0, 0, 300, 300, 300);*/ + sky = Horde3D::addNodes(((Horde3DCamera*)Engine::get()->getCamera())->getSceneNode(), skybox); + Horde3D::setNodeTransform(sky, 0, 0, 0, 0, 0, 0, 2000, 2000, 2000); terrain = horde3d::Island::addIslandNode(RootNode, "terrain", terrainsize, terrainsize, material); Horde3D::setNodeTransform(terrain, -32 * terrainsize, -1600, -32 * terrainsize, 0, 0, 0, 64, 3200, 64); @@ -172,12 +173,16 @@ namespace eal Horde3D::setResourceParamItemi(material, MaterialResParams::Sampler, "colormap", colormap); texturename = 0; - NodeHandle light = Horde3D::addLightNode( RootNode, "Light1", lightMatRes, "LIGHTING", "" ); - Horde3D::setNodeTransform( light, 0, 300, 500, -90, 0, 0, 1, 1, 1 ); - Horde3D::setNodeParamf( light, LightNodeParams::Radius, 200 ); - Horde3D::setNodeParamf( light, LightNodeParams::FOV, 90 ); - Horde3D::setNodeParamf( light, LightNodeParams::Col_R, 0.9f ); - Horde3D::setNodeParamf( light, LightNodeParams::Col_G, 0.7f ); - Horde3D::setNodeParamf( light, LightNodeParams::Col_B, 0.75f ); + sun = Horde3D::addLightNode(RootNode, "Light1", lightMatRes, "LIGHTING", ""); + Horde3D::setNodeTransform(sun, 0, 2000, 1000, -90, 0, 0, 1, 1, 1); + Horde3D::setNodeParamf(sun, LightNodeParams::Radius, 3000 ); + Horde3D::setNodeParami(sun, LightNodeParams::ShadowMapCount, 3); + Horde3D::setNodeParamf(sun, LightNodeParams::ShadowSplitLambda, 0.9f); + Horde3D::setNodeParamf(sun, LightNodeParams::ShadowMapBias, 0.001f); + Horde3D::setNodeParamf(sun, LightNodeParams::FOV, 120); + Horde3D::setNodeParamf(sun, LightNodeParams::Col_R, 0.9f); + Horde3D::setNodeParamf(sun, LightNodeParams::Col_G, 0.7f); + Horde3D::setNodeParamf(sun, LightNodeParams::Col_B, 0.75f); + ((Horde3DCamera*)Engine::get()->getCamera())->setSun(sun); } } diff --git a/src/eal/horde3d/environment.hh b/src/eal/horde3d/environment.hh index 6f86a1e..6a37d17 100644 --- a/src/eal/horde3d/environment.hh +++ b/src/eal/horde3d/environment.hh @@ -73,6 +73,8 @@ namespace eal int material; int texturename; + int sun; + int sky; int water; }; -- 2.11.4.GIT