Explorar el Código

Adds smoothing functions and updates the racer sample to use them.

Ken Whatmough hace 13 años
padre
commit
361a72fb8c

+ 1 - 0
gameplay/gameplay.vcxproj

@@ -220,6 +220,7 @@
     <ClCompile Include="src\lua\lua_VertexFormatUsage.cpp" />
     <ClCompile Include="src\lua\lua_VerticalLayout.cpp" />
     <ClCompile Include="src\Material.cpp" />
+    <ClCompile Include="src\MathUtil.cpp" />
     <ClCompile Include="src\MeshBatch.cpp" />
     <ClCompile Include="src\Pass.cpp" />
     <ClCompile Include="src\MaterialParameter.cpp" />

+ 3 - 0
gameplay/gameplay.vcxproj.filters

@@ -804,6 +804,9 @@
     <ClCompile Include="src\lua\lua_PhysicsVehicleWheel.cpp">
       <Filter>lua</Filter>
     </ClCompile>
+    <ClCompile Include="src\MathUtil.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\Animation.h">

+ 29 - 0
gameplay/src/MathUtil.cpp

@@ -0,0 +1,29 @@
+#include "Base.h"
+#include "MathUtil.h"
+
+namespace gameplay
+{
+
+void MathUtil::smooth(float* x, float target, float elapsedTime, float responseTime)
+{
+    GP_ASSERT(x);
+
+    if (elapsedTime > 0)
+    {
+        *x += (target - *x) * elapsedTime / (elapsedTime + responseTime);
+    }
+}
+
+void MathUtil::smooth(float* x, float target, float elapsedTime, float riseTime, float fallTime)
+{
+    GP_ASSERT(x);
+
+    float delta;
+    if (elapsedTime > 0)
+    {
+        delta = target - *x;
+        *x += delta * elapsedTime / (elapsedTime + (delta > 0 ? riseTime : fallTime));
+    }
+}
+
+}

+ 31 - 0
gameplay/src/MathUtil.h

@@ -11,6 +11,37 @@ class MathUtil
     friend class Matrix;
     friend class Vector3;
 
+public:
+
+    /**
+     * Updates the given scalar towards the given target using a smoothing function.
+     * The given response time determines the amount of smoothing (lag). A longer
+     * response time yields a smoother result and more lag. To force the scalar to
+     * follow the target closely, provide a response time that is very small relative
+     * to the given elapsed time.
+     *
+     * @param x the scalar to update.
+     * @param target target value.
+     * @param elapsedTime elapsed time between calls.
+     * @param responseTime response time (in the same units as elapsedTime).
+     */
+    static void smooth(float* x, float target, float elapsedTime, float responseTime);
+
+    /**
+     * Updates the given scalar towards the given target using a smoothing function.
+     * The given rise and fall times determine the amount of smoothing (lag). Longer
+     * rise and fall times yield a smoother result and more lag. To force the scalar to
+     * follow the target closely, provide rise and fall times that are very small relative
+     * to the given elapsed time.
+     *
+     * @param x the scalar to update.
+     * @param target target value.
+     * @param elapsedTime elapsed time between calls.
+     * @param riseTime response time for rising slope (in the same units as elapsedTime).
+     * @param fallTime response time for falling slope (in the same units as elapsedTime).
+     */
+    static void smooth(float* x, float target, float elapsedTime, float riseTime, float fallTime);
+
 private:
 
     inline static void addMatrix(const float* m, float scalar, float* dst);

+ 5 - 8
gameplay/src/PhysicsVehicleWheel.cpp

@@ -210,16 +210,13 @@ void PhysicsVehicleWheel::update(float elapsedTime)
     Vector3 commandedPosition(pos.x(), pos.y(), pos.z());
     Vector3 wheelPos = _initialOffset;
     _host->_node->getMatrix().transformPoint(&wheelPos);
+    commandedPosition -= wheelPos;
 
     // Filter out noise from Bullet
-    if (elapsedTime > 0.0f)
-    {
-        float dt = elapsedTime / 1000.0f;
-        Vector3 delta = commandedPosition - wheelPos - _positionDelta;
-        float threshold = getStrutRestLength() * 2.0f;
-        float tau = (delta.lengthSquared() > threshold*threshold) ? 0 : 0.06f;
-        _positionDelta += (commandedPosition - wheelPos - _positionDelta) * (dt / (dt + tau));
-    }
+    Vector3 delta(_positionDelta, commandedPosition);
+    float threshold = getStrutRestLength() * 2.0f;
+    float responseTime = (delta.lengthSquared() > threshold*threshold) ? 0 : 60;
+    _positionDelta.smooth(commandedPosition, elapsedTime, responseTime);
 }
 
 bool PhysicsVehicleWheel::isFront() const

+ 9 - 0
gameplay/src/Transform.cpp

@@ -577,6 +577,15 @@ void Transform::translateForward(float amount)
     translate(forward);
 }
 
+void Transform::translateSmooth(const Vector3& target, float elapsedTime, float responseTime)
+{
+    if (elapsedTime > 0)
+    {
+        _translation += (target - _translation) * (elapsedTime / (elapsedTime + responseTime));
+        dirty(DIRTY_TRANSLATION);
+    }
+}
+
 void Transform::transformPoint(Vector3* point)
 {
     getMatrix();

+ 13 - 0
gameplay/src/Transform.h

@@ -688,6 +688,19 @@ public:
      */
     void translateForward(float amount);
 
+    /**
+     * Translates the camera towards the given target using a smoothing function.
+     * The given response time determines the amount of smoothing (lag). A longer
+     * response time yields a smoother result and more lag. To force the camera to
+     * follow the target closely, provide a response time that is very small relative
+     * to the given elapsed time.
+     *
+     * @param target target value.
+     * @param elapsedTime elapsed time between calls.
+     * @param responseTime response time (in the same units as elapsedTime).
+     */
+    void translateSmooth(const Vector3& target, float elapsedTime, float responseTime);
+
     /**
      * Transforms the specified point and stores the
      * result in the original point.

+ 8 - 0
gameplay/src/Vector2.cpp

@@ -269,4 +269,12 @@ void Vector2::subtract(const Vector2& v1, const Vector2& v2, Vector2* dst)
     dst->y = v1.y - v2.y;
 }
 
+void Vector2::smooth(const Vector2& target, float elapsedTime, float responseTime)
+{
+    if (elapsedTime > 0)
+    {
+        *this += (target - *this) * (elapsedTime / (elapsedTime + responseTime));
+    }
+}
+
 }

+ 13 - 0
gameplay/src/Vector2.h

@@ -317,6 +317,19 @@ public:
      */
     static void subtract(const Vector2& v1, const Vector2& v2, Vector2* dst);
 
+    /**
+     * Updates this vector towards the given target using a smoothing function.
+     * The given response time determines the amount of smoothing (lag). A longer
+     * response time yields a smoother result and more lag. To force this vector to
+     * follow the target closely, provide a response time that is very small relative
+     * to the given elapsed time.
+     *
+     * @param target target value.
+     * @param elapsedTime elapsed time between calls.
+     * @param responseTime response time (in the same units as elapsedTime).
+     */
+    void smooth(const Vector2& target, float elapsedTime, float responseTime);
+
     /**
      * Calculates the sum of this vector with the given vector.
      * 

+ 8 - 0
gameplay/src/Vector3.cpp

@@ -307,4 +307,12 @@ void Vector3::subtract(const Vector3& v1, const Vector3& v2, Vector3* dst)
     dst->z = v1.z - v2.z;
 }
 
+void Vector3::smooth(const Vector3& target, float elapsedTime, float responseTime)
+{
+    if (elapsedTime > 0)
+    {
+        *this += (target - *this) * (elapsedTime / (elapsedTime + responseTime));
+    }
+}
+
 }

+ 13 - 0
gameplay/src/Vector3.h

@@ -347,6 +347,19 @@ public:
      */
     static void subtract(const Vector3& v1, const Vector3& v2, Vector3* dst);
 
+    /**
+     * Updates this vector towards the given target using a smoothing function.
+     * The given response time determines the amount of smoothing (lag). A longer
+     * response time yields a smoother result and more lag. To force this vector to
+     * follow the target closely, provide a response time that is very small relative
+     * to the given elapsed time.
+     *
+     * @param target target value.
+     * @param elapsedTime elapsed time between calls.
+     * @param responseTime response time (in the same units as elapsedTime).
+     */
+    void smooth(const Vector3& target, float elapsedTime, float responseTime);
+
     /**
      * Calculates the sum of this vector with the given vector.
      * 

+ 1 - 0
gameplay/src/gameplay.h

@@ -9,6 +9,7 @@
 #include "Gamepad.h"
 #include "FileSystem.h"
 #include "Bundle.h"
+#include "MathUtil.h"
 
 // Math
 #include "Rectangle.h"

+ 47 - 0
gameplay/src/lua/lua_Joint.cpp

@@ -142,6 +142,7 @@ void luaRegister_Joint()
         {"translate", lua_Joint_translate},
         {"translateForward", lua_Joint_translateForward},
         {"translateLeft", lua_Joint_translateLeft},
+        {"translateSmooth", lua_Joint_translateSmooth},
         {"translateUp", lua_Joint_translateUp},
         {"translateX", lua_Joint_translateX},
         {"translateY", lua_Joint_translateY},
@@ -6372,6 +6373,52 @@ int lua_Joint_translateLeft(lua_State* state)
     return 0;
 }
 
+int lua_Joint_translateSmooth(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                // 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);
+
+                Joint* instance = getInstance(state);
+                instance->translateSmooth(*param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Joint_translateSmooth - 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_Joint_translateUp(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Joint.h

@@ -135,6 +135,7 @@ int lua_Joint_transformVector(lua_State* state);
 int lua_Joint_translate(lua_State* state);
 int lua_Joint_translateForward(lua_State* state);
 int lua_Joint_translateLeft(lua_State* state);
+int lua_Joint_translateSmooth(lua_State* state);
 int lua_Joint_translateUp(lua_State* state);
 int lua_Joint_translateX(lua_State* state);
 int lua_Joint_translateY(lua_State* state);

+ 88 - 1
gameplay/src/lua/lua_MathUtil.cpp

@@ -1,6 +1,7 @@
 #include "Base.h"
 #include "ScriptController.h"
 #include "lua_MathUtil.h"
+#include "Base.h"
 #include "MathUtil.h"
 
 namespace gameplay
@@ -12,7 +13,11 @@ void luaRegister_MathUtil()
     {
         {NULL, NULL}
     };
-    const luaL_Reg* lua_statics = NULL;
+    const luaL_Reg lua_statics[] = 
+    {
+        {"smooth", lua_MathUtil_static_smooth},
+        {NULL, NULL}
+    };
     std::vector<std::string> scopePath;
 
     ScriptUtil::registerClass("MathUtil", lua_members, NULL, lua_MathUtil__gc, lua_statics, scopePath);
@@ -65,4 +70,86 @@ int lua_MathUtil__gc(lua_State* state)
     return 0;
 }
 
+int lua_MathUtil_static_smooth(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_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(1);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 4 off the stack.
+                float param4 = (float)luaL_checknumber(state, 4);
+
+                MathUtil::smooth(param1, param2, param3, param4);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_MathUtil_static_smooth - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        case 5:
+        {
+            if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER &&
+                lua_type(state, 5) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(1);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 4 off the stack.
+                float param4 = (float)luaL_checknumber(state, 4);
+
+                // Get parameter 5 off the stack.
+                float param5 = (float)luaL_checknumber(state, 5);
+
+                MathUtil::smooth(param1, param2, param3, param4, param5);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_MathUtil_static_smooth - 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 or 5).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 }

+ 1 - 0
gameplay/src/lua/lua_MathUtil.h

@@ -6,6 +6,7 @@ namespace gameplay
 
 // Lua bindings for MathUtil.
 int lua_MathUtil__gc(lua_State* state);
+int lua_MathUtil_static_smooth(lua_State* state);
 
 void luaRegister_MathUtil();
 

+ 47 - 0
gameplay/src/lua/lua_Node.cpp

@@ -140,6 +140,7 @@ void luaRegister_Node()
         {"translate", lua_Node_translate},
         {"translateForward", lua_Node_translateForward},
         {"translateLeft", lua_Node_translateLeft},
+        {"translateSmooth", lua_Node_translateSmooth},
         {"translateUp", lua_Node_translateUp},
         {"translateX", lua_Node_translateX},
         {"translateY", lua_Node_translateY},
@@ -6392,6 +6393,52 @@ int lua_Node_translateLeft(lua_State* state)
     return 0;
 }
 
+int lua_Node_translateSmooth(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                // 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);
+
+                Node* instance = getInstance(state);
+                instance->translateSmooth(*param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Node_translateSmooth - 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_Node_translateUp(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Node.h

@@ -135,6 +135,7 @@ int lua_Node_transformVector(lua_State* state);
 int lua_Node_translate(lua_State* state);
 int lua_Node_translateForward(lua_State* state);
 int lua_Node_translateLeft(lua_State* state);
+int lua_Node_translateSmooth(lua_State* state);
 int lua_Node_translateUp(lua_State* state);
 int lua_Node_translateX(lua_State* state);
 int lua_Node_translateY(lua_State* state);

+ 47 - 0
gameplay/src/lua/lua_Transform.cpp

@@ -70,6 +70,7 @@ void luaRegister_Transform()
         {"translate", lua_Transform_translate},
         {"translateForward", lua_Transform_translateForward},
         {"translateLeft", lua_Transform_translateLeft},
+        {"translateSmooth", lua_Transform_translateSmooth},
         {"translateUp", lua_Transform_translateUp},
         {"translateX", lua_Transform_translateX},
         {"translateY", lua_Transform_translateY},
@@ -3627,6 +3628,52 @@ int lua_Transform_translateLeft(lua_State* state)
     return 0;
 }
 
+int lua_Transform_translateSmooth(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                // 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);
+
+                Transform* instance = getInstance(state);
+                instance->translateSmooth(*param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Transform_translateSmooth - 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_Transform_translateUp(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Transform.h

@@ -76,6 +76,7 @@ int lua_Transform_transformVector(lua_State* state);
 int lua_Transform_translate(lua_State* state);
 int lua_Transform_translateForward(lua_State* state);
 int lua_Transform_translateLeft(lua_State* state);
+int lua_Transform_translateSmooth(lua_State* state);
 int lua_Transform_translateUp(lua_State* state);
 int lua_Transform_translateX(lua_State* state);
 int lua_Transform_translateY(lua_State* state);

+ 47 - 0
gameplay/src/lua/lua_Vector2.cpp

@@ -25,6 +25,7 @@ void luaRegister_Vector2()
         {"rotate", lua_Vector2_rotate},
         {"scale", lua_Vector2_scale},
         {"set", lua_Vector2_set},
+        {"smooth", lua_Vector2_smooth},
         {"subtract", lua_Vector2_subtract},
         {"x", lua_Vector2_x},
         {"y", lua_Vector2_y},
@@ -872,6 +873,52 @@ int lua_Vector2_set(lua_State* state)
     return 0;
 }
 
+int lua_Vector2_smooth(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector2> param1 = ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true);
+
+                // 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);
+
+                Vector2* instance = getInstance(state);
+                instance->smooth(*param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Vector2_smooth - 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_Vector2_static_add(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Vector2.h

@@ -21,6 +21,7 @@ int lua_Vector2_normalize(lua_State* state);
 int lua_Vector2_rotate(lua_State* state);
 int lua_Vector2_scale(lua_State* state);
 int lua_Vector2_set(lua_State* state);
+int lua_Vector2_smooth(lua_State* state);
 int lua_Vector2_static_add(lua_State* state);
 int lua_Vector2_static_angle(lua_State* state);
 int lua_Vector2_static_clamp(lua_State* state);

+ 47 - 0
gameplay/src/lua/lua_Vector3.cpp

@@ -26,6 +26,7 @@ void luaRegister_Vector3()
         {"normalize", lua_Vector3_normalize},
         {"scale", lua_Vector3_scale},
         {"set", lua_Vector3_set},
+        {"smooth", lua_Vector3_smooth},
         {"subtract", lua_Vector3_subtract},
         {"x", lua_Vector3_x},
         {"y", lua_Vector3_y},
@@ -888,6 +889,52 @@ int lua_Vector3_set(lua_State* state)
     return 0;
 }
 
+int lua_Vector3_smooth(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                // 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);
+
+                Vector3* instance = getInstance(state);
+                instance->smooth(*param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Vector3_smooth - 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_Vector3_static_add(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Vector3.h

@@ -21,6 +21,7 @@ int lua_Vector3_negate(lua_State* state);
 int lua_Vector3_normalize(lua_State* state);
 int lua_Vector3_scale(lua_State* state);
 int lua_Vector3_set(lua_State* state);
+int lua_Vector3_smooth(lua_State* state);
 int lua_Vector3_static_add(lua_State* state);
 int lua_Vector3_static_angle(lua_State* state);
 int lua_Vector3_static_clamp(lua_State* state);