Kaynağa Gözat

Merge pull request #1204 from seanpaultaylor/next

Removes Scene::getLightColor/setLightColor and Scene::getLightDirection/...
Sean Taylor 12 yıl önce
ebeveyn
işleme
9b0edc6695

+ 3 - 0
gameplay/android/jni/Android.mk

@@ -148,6 +148,7 @@ LOCAL_SRC_FILES := \
     lua/lua_ContainerScroll.cpp \
     lua/lua_Control.cpp \
     lua/lua_ControlAlignment.cpp \
+    lua/lua_ControlAutoSize.cpp \
     lua/lua_ControlListener.cpp \
     lua/lua_ControlListenerEventType.cpp \
     lua/lua_ControlState.cpp \
@@ -159,6 +160,7 @@ LOCAL_SRC_FILES := \
     lua/lua_FileSystem.cpp \
     lua/lua_FlowLayout.cpp \
     lua/lua_Font.cpp \
+    lua/lua_FontFormat.cpp \
     lua/lua_FontJustify.cpp \
     lua/lua_FontStyle.cpp \
     lua/lua_FontText.cpp \
@@ -248,6 +250,7 @@ LOCAL_SRC_FILES := \
     lua/lua_RenderStateBlend.cpp \
     lua/lua_RenderStateCullFaceSide.cpp \
     lua/lua_RenderStateDepthFunction.cpp \
+    lua/lua_RenderStateFrontFace.cpp  \
     lua/lua_RenderStateStateBlock.cpp \
     lua/lua_RenderStateStencilFunction.cpp \
     lua/lua_RenderStateStencilOperation.cpp \

+ 1 - 1
gameplay/src/ParticleEmitter.cpp

@@ -889,7 +889,7 @@ void ParticleEmitter::update(float elapsedTime)
         {
             if ((int)_timePerEmission > 0)
             {
-                _emitTime = fmod(_emitTime, (double)_timePerEmission);
+                _emitTime = fmod((double)_emitTime, (double)_timePerEmission);
             }
             emitOnce(emitCount);
         }

+ 0 - 33
gameplay/src/RenderState.cpp

@@ -143,12 +143,6 @@ const char* autoBindingToString(RenderState::AutoBinding autoBinding)
     case RenderState::SCENE_AMBIENT_COLOR:
         return "SCENE_AMBIENT_COLOR";
 
-    case RenderState::SCENE_LIGHT_COLOR:
-        return "SCENE_LIGHT_COLOR";
-
-    case RenderState::SCENE_LIGHT_DIRECTION:
-        return "SCENE_LIGHT_DIRECTION";
-
     default:
         return "";
     }
@@ -304,14 +298,6 @@ void RenderState::applyAutoBinding(const char* uniformName, const char* autoBind
         {
             param->bindValue(this, &RenderState::autoBindingGetAmbientColor);
         }
-        else if (strcmp(autoBinding, "SCENE_LIGHT_COLOR") == 0)
-        {
-            param->bindValue(this, &RenderState::autoBindingGetLightColor);
-        }
-        else if (strcmp(autoBinding, "SCENE_LIGHT_DIRECTION") == 0)
-        {
-            param->bindValue(this, &RenderState::autoBindingGetLightDirection);
-        }
         else
         {
             bound = false;
@@ -397,25 +383,6 @@ const Vector3& RenderState::autoBindingGetAmbientColor() const
     return scene ? scene->getAmbientColor() : Vector3::zero();
 }
 
-const Vector3& RenderState::autoBindingGetLightColor() const
-{
-    Scene* scene = _nodeBinding ? _nodeBinding->getScene() : NULL;
-    return scene ? scene->getLightColor() : Vector3::one();
-}
-
-const Vector3& RenderState::autoBindingGetLightDirection() const
-{
-    static Vector3 down(0, -1, 0);
-    Scene* scene = _nodeBinding ? _nodeBinding->getScene() : NULL;
-    if (scene) {
-        static Vector3 lightDirection;
-        lightDirection.set(scene->getLightDirection());
-        _nodeBinding->getViewMatrix().transformVector(&lightDirection);
-        return lightDirection;
-    }
-    return down;
-}
-
 void RenderState::bind(Pass* pass)
 {
     GP_ASSERT(pass);

+ 1 - 15
gameplay/src/RenderState.h

@@ -91,21 +91,7 @@ public:
         /**
          * Binds the current scene's ambient color (Vector3).
          */
-        SCENE_AMBIENT_COLOR,
-
-        /**
-         * Binds the current scene's light color (Vector3).
-         *
-         * This is typically used for the main directional light in a scene, such as the Sun.
-         */
-        SCENE_LIGHT_COLOR,
-
-        /**
-         * Binds the current scene's light direction (Vector3).
-         *
-         * This is typically used for the main directional light in a scene, such as the Sun.
-         */
-        SCENE_LIGHT_DIRECTION
+        SCENE_AMBIENT_COLOR
     };
 
     /**

+ 1 - 22
gameplay/src/Scene.cpp

@@ -60,8 +60,7 @@ static bool endsWith(const char* str, const char* suffix, bool ignoreCase)
 
 
 Scene::Scene(const char* id)
-    : _id(id ? id : ""), _activeCamera(NULL), _firstNode(NULL), _lastNode(NULL), _nodeCount(0), 
-    _lightColor(1,1,1), _lightDirection(0,-1,0), _bindAudioListenerToCamera(true), _debugBatch(NULL)
+    : _id(id ? id : ""), _activeCamera(NULL), _firstNode(NULL), _lastNode(NULL), _nodeCount(0), _bindAudioListenerToCamera(true), _debugBatch(NULL)
 {
     __sceneList.push_back(this);
 }
@@ -383,26 +382,6 @@ void Scene::setAmbientColor(float red, float green, float blue)
     _ambientColor.set(red, green, blue);
 }
 
-const Vector3& Scene::getLightColor() const
-{
-    return _lightColor;
-}
-
-void Scene::setLightColor(float red, float green, float blue)
-{
-    _lightColor.set(red, green, blue);
-}
-
-const Vector3& Scene::getLightDirection() const
-{
-    return _lightDirection;
-}
-
-void Scene::setLightDirection(const Vector3& direction)
-{
-    _lightDirection = direction;
-}
-
 static Material* createDebugMaterial()
 {
     // Vertex shader for drawing colored lines.

+ 1 - 49
gameplay/src/Scene.h

@@ -181,55 +181,7 @@ public:
      * @see getAmbientColor()
      */
     void setAmbientColor(float red, float green, float blue);
-
-    /**
-     * Returns the light color of the scene.
-     *
-     * The default light color is white (1,1,1).
-     *
-     * This color is typically used to represent the color of the main directional light (i.e. the Sun) in a scene.
-     * The corresponding direction can be queried using Scene::getLightDirection().
-     *
-     * This value can be bound to materials using the SCENE_LIGHT_COLOR auto binding.
-     *
-     * @return The scene's light color.
-     */
-    const Vector3& getLightColor() const;
-
-    /**
-     * Sets the scene's light color.
-     *
-     * @param red The red channel between 0.0 and 1.0.
-     * @param green The green channel between 0.0 and 1.0.
-     * @param blue The blue channel between 0.0 and 1.0.
-     *
-     * @see getLightColor()
-     */
-    void setLightColor(float red, float green, float blue);
-
-    /**
-     * Returns the current light direction for the scene.
-     *
-     * The default value is (0,-1,0), which is a pointing directly down the Y-axis.
-     *
-     * This value is typically used to represent the the main directional lihgt (i.e. the Sun) in a scene.
-     * The corresponding light color can be queried using Scene::getLightColor().
-     *
-     * This value can be bound to materials using the SCENE_LIGHT_DIRECTION auto binding.
-     *
-     * @return The scene's light direction.
-     */
-    const Vector3& getLightDirection() const;
-
-    /**
-     * Sets the scene's light direction.
-     *
-     * @param direction The new light direction.
-     *
-     * @see getLightDirection()
-     */
-    void setLightDirection(const Vector3& direction);
-
+    
     /**
      * Visits each node in the scene and calls the specified method pointer.
      *

+ 0 - 4
gameplay/src/SceneLoader.cpp

@@ -113,10 +113,6 @@ Scene* SceneLoader::loadInternal(const char* url)
     Vector3 vec3;
     if (sceneProperties->getVector3("ambientColor", &vec3))
         _scene->setAmbientColor(vec3.x, vec3.y, vec3.z);
-    if (sceneProperties->getVector3("lightColor", &vec3))
-        _scene->setLightColor(vec3.x, vec3.y, vec3.z);
-    if (sceneProperties->getVector3("lightDirection", &vec3))
-        _scene->setLightDirection(vec3);
 
     // Create animations for scene
     createAnimations();

+ 2 - 20
gameplay/src/TerrainPatch.cpp

@@ -487,8 +487,8 @@ bool TerrainPatch::updateMaterial()
         else
             material->getParameter("u_normalMatrix")->bindValue(_terrain, &Terrain::getNormalMatrix);
         material->getParameter("u_ambientColor")->bindValue(this, &TerrainPatch::getAmbientColor);
-        material->getParameter("u_lightColor")->bindValue(this, &TerrainPatch::getLightColor);
-        material->getParameter("u_lightDirection")->bindValue(this, &TerrainPatch::getLightDirection);
+        material->getParameter("u_lightColor")->setValue(Vector3::one());
+        material->getParameter("u_lightDirection")->setValue(Vector3(0, -1, 0));
         if (_layers.size() > 0)
             material->getParameter("u_samplers")->setValue((const Texture::Sampler**)&_samplers[0], (unsigned int)_samplers.size());
 
@@ -602,24 +602,6 @@ const Vector3& TerrainPatch::getAmbientColor() const
     return scene ? scene->getAmbientColor() : Vector3::zero();
 }
 
-const Vector3& TerrainPatch::getLightColor() const
-{
-    Scene* scene = _terrain->_node ? _terrain->_node->getScene() : NULL;
-    return scene ? scene->getLightColor() : Vector3::one();
-}
-
-const Vector3& TerrainPatch::getLightDirection() const
-{
-    Scene* scene = _terrain->_node ? _terrain->_node->getScene() : NULL;
-    if (!scene)
-    {
-        static Vector3 down(0, -1, 0);
-        return down;
-    }
-
-    return scene->getLightDirection();
-}
-
 size_t TerrainPatch::computeLOD(Camera* camera, const BoundingBox& worldBounds) const
 {
     if (!_terrain->isFlagSet(Terrain::LEVEL_OF_DETAIL) || _levels.size() == 0)

+ 0 - 4
gameplay/src/TerrainPatch.h

@@ -138,10 +138,6 @@ private:
 
     const Vector3& getAmbientColor() const;
 
-    const Vector3& getLightColor() const;
-
-    const Vector3& getLightDirection() const;
-
     Terrain* _terrain;
     std::vector<Level*> _levels;
     unsigned int _row;

+ 0 - 2
gameplay/src/lua/lua_Global.cpp

@@ -750,8 +750,6 @@ void luaRegister_lua_Global()
         gameplay::ScriptUtil::registerConstantString("CAMERA_VIEW_POSITION", "CAMERA_VIEW_POSITION", scopePath);
         gameplay::ScriptUtil::registerConstantString("MATRIX_PALETTE", "MATRIX_PALETTE", scopePath);
         gameplay::ScriptUtil::registerConstantString("SCENE_AMBIENT_COLOR", "SCENE_AMBIENT_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCENE_LIGHT_COLOR", "SCENE_LIGHT_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCENE_LIGHT_DIRECTION", "SCENE_LIGHT_DIRECTION", scopePath);
     }
 
     // Register enumeration RenderState::Blend.

+ 0 - 10
gameplay/src/lua/lua_RenderStateAutoBinding.cpp

@@ -19,8 +19,6 @@ static const char* luaEnumString_RenderStateAutoBinding_CAMERA_WORLD_POSITION =
 static const char* luaEnumString_RenderStateAutoBinding_CAMERA_VIEW_POSITION = "CAMERA_VIEW_POSITION";
 static const char* luaEnumString_RenderStateAutoBinding_MATRIX_PALETTE = "MATRIX_PALETTE";
 static const char* luaEnumString_RenderStateAutoBinding_SCENE_AMBIENT_COLOR = "SCENE_AMBIENT_COLOR";
-static const char* luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_COLOR = "SCENE_LIGHT_COLOR";
-static const char* luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_DIRECTION = "SCENE_LIGHT_DIRECTION";
 
 RenderState::AutoBinding lua_enumFromString_RenderStateAutoBinding(const char* s)
 {
@@ -50,10 +48,6 @@ RenderState::AutoBinding lua_enumFromString_RenderStateAutoBinding(const char* s
         return RenderState::MATRIX_PALETTE;
     if (strcmp(s, luaEnumString_RenderStateAutoBinding_SCENE_AMBIENT_COLOR) == 0)
         return RenderState::SCENE_AMBIENT_COLOR;
-    if (strcmp(s, luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_COLOR) == 0)
-        return RenderState::SCENE_LIGHT_COLOR;
-    if (strcmp(s, luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_DIRECTION) == 0)
-        return RenderState::SCENE_LIGHT_DIRECTION;
     return RenderState::NONE;
 }
 
@@ -85,10 +79,6 @@ const char* lua_stringFromEnum_RenderStateAutoBinding(RenderState::AutoBinding e
         return luaEnumString_RenderStateAutoBinding_MATRIX_PALETTE;
     if (e == RenderState::SCENE_AMBIENT_COLOR)
         return luaEnumString_RenderStateAutoBinding_SCENE_AMBIENT_COLOR;
-    if (e == RenderState::SCENE_LIGHT_COLOR)
-        return luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_COLOR;
-    if (e == RenderState::SCENE_LIGHT_DIRECTION)
-        return luaEnumString_RenderStateAutoBinding_SCENE_LIGHT_DIRECTION;
     return enumStringEmpty;
 }
 

+ 0 - 178
gameplay/src/lua/lua_Scene.cpp

@@ -28,8 +28,6 @@ void luaRegister_Scene()
         {"getAmbientColor", lua_Scene_getAmbientColor},
         {"getFirstNode", lua_Scene_getFirstNode},
         {"getId", lua_Scene_getId},
-        {"getLightColor", lua_Scene_getLightColor},
-        {"getLightDirection", lua_Scene_getLightDirection},
         {"getNodeCount", lua_Scene_getNodeCount},
         {"getRefCount", lua_Scene_getRefCount},
         {"release", lua_Scene_release},
@@ -38,8 +36,6 @@ void luaRegister_Scene()
         {"setActiveCamera", lua_Scene_setActiveCamera},
         {"setAmbientColor", lua_Scene_setAmbientColor},
         {"setId", lua_Scene_setId},
-        {"setLightColor", lua_Scene_setLightColor},
-        {"setLightDirection", lua_Scene_setLightDirection},
         {"visit", lua_Scene_visit},
         {NULL, NULL}
     };
@@ -589,94 +585,6 @@ int lua_Scene_getId(lua_State* state)
     return 0;
 }
 
-int lua_Scene_getLightColor(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Scene* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getLightColor());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Scene_getLightColor - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Scene_getLightDirection(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Scene* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getLightDirection());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Scene_getLightDirection - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Scene_getNodeCount(lua_State* state)
 {
     // Get the number of parameters.
@@ -975,92 +883,6 @@ int lua_Scene_setId(lua_State* state)
     return 0;
 }
 
-int lua_Scene_setLightColor(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 4:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                float param1 = (float)luaL_checknumber(state, 2);
-
-                // Get parameter 2 off the stack.
-                float param2 = (float)luaL_checknumber(state, 3);
-
-                // Get parameter 3 off the stack.
-                float param3 = (float)luaL_checknumber(state, 4);
-
-                Scene* instance = getInstance(state);
-                instance->setLightColor(param1, param2, param3);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Scene_setLightColor - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Scene_setLightDirection(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector3'.");
-                    lua_error(state);
-                }
-
-                Scene* instance = getInstance(state);
-                instance->setLightDirection(*param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Scene_setLightDirection - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Scene_static_create(lua_State* state)
 {
     // Get the number of parameters.

+ 0 - 4
gameplay/src/lua/lua_Scene.h

@@ -15,8 +15,6 @@ int lua_Scene_getActiveCamera(lua_State* state);
 int lua_Scene_getAmbientColor(lua_State* state);
 int lua_Scene_getFirstNode(lua_State* state);
 int lua_Scene_getId(lua_State* state);
-int lua_Scene_getLightColor(lua_State* state);
-int lua_Scene_getLightDirection(lua_State* state);
 int lua_Scene_getNodeCount(lua_State* state);
 int lua_Scene_getRefCount(lua_State* state);
 int lua_Scene_release(lua_State* state);
@@ -25,8 +23,6 @@ int lua_Scene_removeNode(lua_State* state);
 int lua_Scene_setActiveCamera(lua_State* state);
 int lua_Scene_setAmbientColor(lua_State* state);
 int lua_Scene_setId(lua_State* state);
-int lua_Scene_setLightColor(lua_State* state);
-int lua_Scene_setLightDirection(lua_State* state);
 int lua_Scene_static_create(lua_State* state);
 int lua_Scene_static_getScene(lua_State* state);
 int lua_Scene_static_load(lua_State* state);

+ 3 - 2
samples/browser/res/common/duck.material

@@ -13,8 +13,9 @@ material duck
             u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX
             u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
             u_cameraPosition = CAMERA_WORLD_POSITION
-            u_ambientColor = 0.2, 0.2, 0.2
-            u_lightColor = 0.75, 0.75, 0.75
+            u_ambientColor = SCENE_AMBIENT_COLOR
+            u_lightColor = 1, 1, 1
+            u_lightDirection = 0, -1, 0
             u_specularExponent = 50
             
             // samplers

+ 3 - 0
samples/browser/res/common/sample.material

@@ -9,6 +9,9 @@ material colored
 
             u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX
             u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
+            u_ambientColor = SCENE_AMBIENT_COLOR
+            u_lightColor = 1, 1, 1
+            u_lightDirection = 0, -1, 0
             
             renderState
             {

+ 0 - 2
samples/browser/res/common/terrain/sample.scene

@@ -43,8 +43,6 @@ scene terrainSampleScene
 
 	// Basic scene lighting properties
 	ambientColor = 0.2, 0.2, 0.2
-	lightColor = 1, 1, 1
-	lightDirection = -1, -0.75, -0.75
 
 	// Set active camera
 	activeCamera = camera

+ 4 - 7
samples/browser/src/LoadSceneSample.cpp

@@ -6,7 +6,7 @@
 #endif
 
 LoadSceneSample::LoadSceneSample()
-    : _font(NULL), _scene(NULL), _lightNode(NULL), _wireFrame(false)
+    : _font(NULL), _scene(NULL), _wireFrame(false)
 {
     
 }
@@ -18,13 +18,8 @@ void LoadSceneSample::initialize()
 
     _scene = Scene::load("res/common/sample.scene");
 
-    // Find the light node
-    _lightNode = _scene->findNode("directionalLight");
-
     // Update the aspect ratio for our scene's camera to match the current device resolution
     _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
-
-    _scene->visit(this, &LoadSceneSample::bindLights);
 }
 
 void LoadSceneSample::finalize()
@@ -90,6 +85,7 @@ bool LoadSceneSample::drawScene(Node* node)
     return true;
 }
 
+/*
 bool LoadSceneSample::bindLights(Node* node)
 {
     Model* model = node->getModel();
@@ -119,4 +115,5 @@ bool LoadSceneSample::bindLights(Node* node)
         }
     }
     return true;
-}
+}
+*/

+ 0 - 3
samples/browser/src/LoadSceneSample.h

@@ -33,11 +33,8 @@ private:
 
     bool drawScene(Node* node);
 
-    bool bindLights(Node* node);
-
     Font* _font;
     Scene* _scene;
-    Node* _lightNode;
     bool _wireFrame;
 };
 

+ 1 - 37
samples/browser/src/SceneRendererSample.cpp

@@ -5,7 +5,7 @@
     ADD_SAMPLE("Scene", "SceneRenderer", SceneRendererSample, 3);
 #endif
 
-SceneRendererSample::SceneRendererSample() : _font(NULL), _scene(NULL), _visibleSet(NULL), _lightNode(NULL)
+SceneRendererSample::SceneRendererSample() : _font(NULL), _scene(NULL), _visibleSet(NULL)
 {
 }
 
@@ -18,12 +18,7 @@ void SceneRendererSample::initialize()
     _visibleSet = VisibleSetDefault::create(_scene);
     _renderer = SceneRendererForward::create();
 
-    // Find the light node
-    _lightNode = _scene->findNode("directionalLight");
-
     _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
-
-    _scene->visit(this, &SceneRendererSample::bindLights);
 }
 
 void SceneRendererSample::finalize()
@@ -65,35 +60,4 @@ void SceneRendererSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsign
 
 void SceneRendererSample::keyEvent(Keyboard::KeyEvent evt, int key)
 {
-}
-
-bool SceneRendererSample::bindLights(Node* node)
-{
-    Model* model = node->getModel();
-    if (model)
-    {
-        Material* material = model->getMaterial();
-        if (material)
-        {
-            MaterialParameter* ambientColorParam = material->getParameter("u_ambientColor");
-            if (ambientColorParam)
-            {
-                ambientColorParam->setValue(_scene->getAmbientColor());
-            }
-            if (_lightNode && _lightNode->getLight())
-            {
-                MaterialParameter* lightDirectionParam = material->getParameter("u_lightDirection");
-                MaterialParameter* lightColorParam = material->getParameter("u_lightColor");
-                if (lightDirectionParam)
-                {
-                    lightDirectionParam->bindValue(_lightNode, &Node::getForwardVectorView);
-                }
-                if (lightColorParam)
-                {
-                    lightColorParam->setValue(_lightNode->getLight()->getColor());
-                }
-            }
-        }
-    }
-    return true;
 }

+ 0 - 3
samples/browser/src/SceneRendererSample.h

@@ -25,11 +25,8 @@ protected:
 
 private:
 
-    bool bindLights(Node* node);
-
     Font* _font;
     Scene* _scene;
-    Node* _lightNode;
     VisibleSet* _visibleSet;
     SceneRenderer* _renderer;
 };

+ 1 - 4
tools/encoder/src/FBXSceneEncoder.cpp

@@ -663,10 +663,7 @@ Material* FBXSceneEncoder::createBaseMaterial(const string& baseMaterialName, Ma
     if (childMaterial->isLit())
     {
         baseMaterial->setLit(true);
-        baseMaterial->setUniform("u_inverseTransposeWorldViewMatrix", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX");
-        // Always use directional light
-        baseMaterial->setUniform("u_lightDirection", "SCENE_LIGHT_DIRECTION");
-        baseMaterial->setUniform("u_lightColor", "SCENE_LIGHT_COLOR");
+        baseMaterial->setUniform("u_inverseTransposeWorldViewMatrix", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX");s
 
         if (childMaterial->isSpecular())
         {

+ 1 - 0
tools/encoder/src/Scene.h

@@ -70,6 +70,7 @@ private:
     std::list<Node*> _nodes;
     Node* _cameraNode;
     float _ambientColor[Light::COLOR_SIZE];
+    Node* _lightNode;
 };
 
 }