Bladeren bron

Add Object::GetTypeName support.

Aster Jian 12 jaren geleden
bovenliggende
commit
8d3d69e134

+ 2 - 5
Bin/Data/LuaScripts/TestScene.lua

@@ -416,13 +416,10 @@ function HandleMouseButtonDown(eventType, eventData)
                         decal = result.drawable:GetNode():CreateDecalSet()
                         decal = result.drawable:GetNode():CreateDecalSet()
                         decal:SetMaterial(cache:GetMaterial("Materials/UrhoDecal.xml"))
                         decal:SetMaterial(cache:GetMaterial("Materials/UrhoDecal.xml"))
                         -- Increase max. vertices/indices if the target is skinned
                         -- Increase max. vertices/indices if the target is skinned
-                        --[[
-                        if result.drawable:GetTypeName() == "AnimatedModel")
-                        {
+                        if result.drawable:GetTypeName() == "AnimatedModel" then
                             decal.maxVertices = 2048
                             decal.maxVertices = 2048
                             decal.maxIndices = 4096
                             decal.maxIndices = 4096
-                        }
-                        --]]
+                        end
                     end
                     end
                     decal:AddDecal(result.drawable, rayHitPos, cameraNode:GetWorldRotation(), 0.5, 1.0, 1.0, Vector2(0, 0), Vector2(1, 1))
                     decal:AddDecal(result.drawable, rayHitPos, cameraNode:GetWorldRotation(), 0.5, 1.0, 1.0, Vector2(0, 0), Vector2(1, 1))
                 end
                 end

+ 2 - 2
CMakeLists.txt

@@ -278,7 +278,7 @@ add_subdirectory (ThirdParty/STB)
 add_subdirectory (ThirdParty/JO)
 add_subdirectory (ThirdParty/JO)
 
 
 # Alternative Lua bindings. Uncomment the following line to enable
 # Alternative Lua bindings. Uncomment the following line to enable
-# set (ENABLE_LUA 1)
+set (ENABLE_LUA 1)
 if (ENABLE_LUA)
 if (ENABLE_LUA)
     add_definitions (-DENABLE_LUA)
     add_definitions (-DENABLE_LUA)
     add_subdirectory (ThirdParty/Lua)
     add_subdirectory (ThirdParty/Lua)
@@ -309,7 +309,7 @@ if (NOT USE_OPENGL)
 endif ()
 endif ()
 
 
 # Urho3D extras. Uncomment to enable
 # Urho3D extras. Uncomment to enable
-# set (ENABLE_EXTRAS 1)
+set (ENABLE_EXTRAS 1)
 if (ENABLE_EXTRAS)
 if (ENABLE_EXTRAS)
     add_subdirectory (Extras/OgreBatchConverter)
     add_subdirectory (Extras/OgreBatchConverter)
     add_subdirectory (Extras/CharacterDemo)
     add_subdirectory (Extras/CharacterDemo)

+ 28 - 0
Extras/LuaScript/pkgs/Core/Object.pkg

@@ -0,0 +1,28 @@
+$#include "Object.h"
+
+class Object : public RefCounted
+{
+public:
+    tolua_outside const char* ObjectGetTypeName @ GetTypeName() const;
+    tolua_outside void ObjectSendEvent @ SendEvent(const char* eventName);
+    tolua_outside void ObjectSendEvent @ SendEvent(const char* eventName, VariantMap& eventData);
+};
+
+${
+
+static const char* ObjectGetTypeName(const Object* object)
+{
+    return object->GetTypeName().CString();
+}
+
+static void ObjectSendEvent(Object* object, const char* eventName)
+{
+    object->SendEvent(StringHash(eventName));
+}
+
+static void ObjectSendEvent(Object* object, const char* eventName, VariantMap& eventData)
+{
+    object->SendEvent(StringHash(eventName), eventData);
+}
+
+$}

+ 1 - 0
Extras/LuaScript/pkgs/CoreLuaAPI.pkg

@@ -1,6 +1,7 @@
 $#define TOLUA_RELEASE
 $#define TOLUA_RELEASE
 
 
 $pfile "Core/Context.pkg"
 $pfile "Core/Context.pkg"
+$pfile "Core/Object.pkg"
 $pfile "Core/ProcessUtils.pkg"
 $pfile "Core/ProcessUtils.pkg"
 $pfile "Core/StringUtils.pkg"
 $pfile "Core/StringUtils.pkg"
 $pfile "Core/Variant.pkg"
 $pfile "Core/Variant.pkg"

+ 1 - 1
Extras/LuaScript/pkgs/Scene/Component.pkg

@@ -1,7 +1,7 @@
 $#include "Component.h"
 $#include "Component.h"
 
 
 /// Base class for components. Components can be created to scene nodes.
 /// Base class for components. Components can be created to scene nodes.
-class Component
+class Component : public Serializable
 {    
 {    
 public:
 public:
     /// Set enabled/disabled state.
     /// Set enabled/disabled state.

+ 6 - 0
Extras/LuaScript/pkgs/Scene/Serializable.pkg

@@ -0,0 +1,6 @@
+$#include "Serializable.h"
+
+class Serializable : public Object
+{
+public:
+};

+ 1 - 0
Extras/LuaScript/pkgs/SceneLuaAPI.pkg

@@ -3,6 +3,7 @@ $#define TOLUA_RELEASE
 $pfile "Scene/Component.pkg"
 $pfile "Scene/Component.pkg"
 $pfile "Scene/Node.pkg"
 $pfile "Scene/Node.pkg"
 $pfile "Scene/Scene.pkg"
 $pfile "Scene/Scene.pkg"
+$pfile "Scene/Serializable.pkg"
 
 
 $using namespace Urho3D;
 $using namespace Urho3D;
 $#pragma warning(disable:4800)
 $#pragma warning(disable:4800)