Răsfoiți Sursa

Add transform functions for Urho2D.

aster2013 11 ani în urmă
părinte
comite
49d9856dd5

+ 1 - 0
Source/Engine/LuaScript/pkgs/Math/Quaternion.pkg

@@ -6,6 +6,7 @@ class Quaternion
     Quaternion(const Quaternion& quat);
     Quaternion(float w, float x, float y, float z);
     Quaternion(float angle, const Vector3& axis);
+    Quaternion(float angle);
     Quaternion(float x, float y, float z);
     Quaternion(const Vector3& start, const Vector3& end);
     Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);

+ 2 - 0
Source/Engine/LuaScript/pkgs/Math/Vector3.pkg

@@ -5,7 +5,9 @@ class Vector3
     Vector3();
     Vector3(const Vector3& vector);
     Vector3(const Vector2& vector, float z);
+    Vector3(const Vector2& vector);
     Vector3(float x, float y, float z);
+    Vector3(float x, float y);
     ~Vector3();
     
     bool operator == (const Vector3& rhs) const;

+ 18 - 0
Source/Engine/LuaScript/pkgs/Scene/Node.pkg

@@ -26,9 +26,11 @@ class Node : public Animatable
     void SetName(const String name);
     
     void SetPosition(const Vector3& position);
+    void SetPosition(const Vector2& position);
     tolua_outside void NodeSetPositionXYZ @ SetPositionXYZ(float x, float y, float z);
     
     void SetRotation(const Quaternion& rotation);
+    void SetRotation(float rotation);
     tolua_outside void NodeSetRotationXYZ @ SetRotationXYZ(float x, float y, float z);
     
     void SetDirection(const Vector3& direction);
@@ -36,16 +38,22 @@ class Node : public Animatable
     
     void SetScale(float scale);
     void SetScale(const Vector3& scale);
+    void SetScale(const Vector2& scale);
     tolua_outside void NodeSetScaleXYZ @ SetScaleXYZ(float x, float y, float z);
     
     void SetTransform(const Vector3& position, const Quaternion& rotation);
+    void SetTransform(const Vector2& position, float rotation);
     void SetTransform(const Vector3& position, const Quaternion& rotation, float scale);
+    void SetTransform(const Vector2& position, float rotation, float scale);
     void SetTransform(const Vector3& position, const Quaternion& rotation, const Vector3& scale);
+    void SetTransform(const Vector2& position, float rotation, const Vector2& scale);
     
     void SetWorldPosition(const Vector3& position);
+    void SetWorldPosition(const Vector2& position);
     tolua_outside void NodeSetWorldPositionXYZ @ SetWorldPositionXYZ(float x, float y, float z);
     
     void SetWorldRotation(const Quaternion& rotation);
+    void SetWorldRotation(float rotation);
     tolua_outside void NodeSetWorldRotationXYZ @ SetWorldRotationXYZ(float x, float y, float z);
     
     void SetWorldDirection(const Vector3& direction);
@@ -53,19 +61,26 @@ class Node : public Animatable
     
     void SetWorldScale(float scale);
     void SetWorldScale(const Vector3& scale);
+    void SetWorldScale(const Vector2& scale);
     tolua_outside void NodeSetWorldScaleXYZ @ SetWorldScaleXYZ(float x, float y, float z);
 
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation);
+    void SetWorldTransform(const Vector2& position, float rotation);
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation, float scale);
+    void SetWorldTransform(const Vector2& position, float rotation, float scale);
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation, const Vector3& scale);
+    void SetWorldTransform(const Vector2& position, float rotation, const Vector3& scale);
     
     void Translate(const Vector3& delta, TransformSpace space = TS_LOCAL);
+    void Translate(const Vector2& delta, TransformSpace space = TS_LOCAL);
     tolua_outside void NodeTranslateXYZ @ TranslateXYZ(float x, float y, float z, TransformSpace space = TS_LOCAL);
 
     void Rotate(const Quaternion& delta, TransformSpace space = TS_LOCAL);
+    void Rotate(float delta, TransformSpace space = TS_LOCAL);
     tolua_outside void NodeRotateXYZ @ RotateXYZ(float x, float y, float z, TransformSpace space = TS_LOCAL);
 
     void RotateAround(const Vector3& point, const Quaternion& delta, TransformSpace space = TS_LOCAL);
+    void RotateAround(const Vector2& point, float delta, TransformSpace space = TS_LOCAL);
     tolua_outside void NodeRotateAroundXYZ @ RotateAroundXYZ(float pX, float pY, float pZ, float dX, float dY, float dZ, TransformSpace space = TS_LOCAL);
 
     void Pitch(float angle, TransformSpace space = TS_LOCAL);
@@ -77,6 +92,7 @@ class Node : public Animatable
 
     void Scale(float scale);
     void Scale(const Vector3& scale);
+    void Scale(const Vector2& scale);
     tolua_outside void NodeScaleXYZ @ ScaleXYZ(float x, float y, float z);
     
     void SetEnabled(bool enable);
@@ -165,8 +181,10 @@ class Node : public Animatable
     const Matrix3x4& GetWorldTransform() const;
     Vector3 LocalToWorld(const Vector3& position) const;
     Vector3 LocalToWorld(const Vector4& vector) const;
+    Vector2 LocalToWorld(const Vector2& vector) const;
     Vector3 WorldToLocal(const Vector3& position) const;
     Vector3 WorldToLocal(const Vector4& vector) const;
+    Vector2 WorldToLocal(const Vector2& vector) const;
     bool IsDirty() const;
 
     unsigned GetNumChildren(bool recursive = false) const;

+ 6 - 0
Source/Engine/Math/Quaternion.h

@@ -72,6 +72,12 @@ public:
     {
         FromAngleAxis(angle, axis);
     }
+
+    /// Construct from an angle (in degrees, for Urho2D).
+    Quaternion(float angle)
+    {
+        FromAngleAxis(angle, Vector3::FORWARD);
+    }
     
     /// Construct from Euler angles (in degrees.)
     Quaternion(float x, float y, float z)

+ 16 - 0
Source/Engine/Math/Vector3.h

@@ -54,6 +54,14 @@ public:
         z_(z)
     {
     }
+
+    /// Construct from a two-dimensional vector (for Urho2D).
+    Vector3(const Vector2& vector) :
+        x_(vector.x_),
+        y_(vector.y_),
+        z_(0.0f)
+    {
+    }
     
     /// Construct from coordinates.
     Vector3(float x, float y, float z) :
@@ -62,6 +70,14 @@ public:
         z_(z)
     {
     }
+
+    /// Construct from two-dimensional coordinates (for Urho2D).
+    Vector3(float x, float y) :
+        x_(x),
+        y_(y),
+        z_(0.0f)
+    {
+    }
     
     /// Construct from a float array.
     Vector3(const float* data) :

+ 12 - 0
Source/Engine/Scene/Node.cpp

@@ -881,6 +881,12 @@ Vector3 Node::LocalToWorld(const Vector4& vector) const
     return GetWorldTransform() * vector;
 }
 
+Vector2 Node::LocalToWorld(const Vector2& vector) const
+{
+    Vector3 result = LocalToWorld(Vector3(vector));
+    return Vector2(result.x_, result.y_);
+}
+
 Vector3 Node::WorldToLocal(const Vector3& position) const
 {
     return GetWorldTransform().Inverse() * position;
@@ -891,6 +897,12 @@ Vector3 Node::WorldToLocal(const Vector4& vector) const
     return GetWorldTransform().Inverse() * vector;
 }
 
+Vector2 Node::WorldToLocal(const Vector2& vector) const
+{
+    Vector3 result = WorldToLocal(Vector3(vector));
+    return Vector2(result.x_, result.y_);
+}
+
 unsigned Node::GetNumChildren(bool recursive) const
 {
     if (!recursive)

+ 36 - 0
Source/Engine/Scene/Node.h

@@ -90,42 +90,72 @@ public:
     void SetName(const String& name);
     /// Set position in parent space. If the scene node is on the root level (is child of the scene itself), this is same as world space.
     void SetPosition(const Vector3& position);
+    /// Set position in parent space (for Urho2D).
+    void SetPosition(const Vector2& position) { SetPosition(Vector3(position)); }
     /// Set rotation in parent space.
     void SetRotation(const Quaternion& rotation);
+    /// Set rotation in parent space (for Urho2D).
+    void SetRotation(float rotation) { SetRotation(Quaternion(rotation)); }
     /// Set forward direction in parent space. Positive Z axis equals identity rotation.
     void SetDirection(const Vector3& direction);
     /// Set uniform scale in parent space.
     void SetScale(float scale);
     /// Set scale in parent space.
     void SetScale(const Vector3& scale);
+    /// Set scale in parent space (for Urho2D).
+    void SetScale(const Vector2& scale) { SetScale(Vector3(scale, 1.0f)); }
     /// Set both position and rotation in parent space as an atomic operation. This is faster than setting position and rotation separately.
     void SetTransform(const Vector3& position, const Quaternion& rotation);
+    /// Set both position and rotation in parent space as an atomic operation (for Urho2D).
+    void SetTransform(const Vector2& position, float rotation) { SetTransform(Vector3(position), Quaternion(rotation)); }
     /// Set both position, rotation and uniform scale in parent space as an atomic operation.
     void SetTransform(const Vector3& position, const Quaternion& rotation, float scale);
+    /// Set both position, rotation and uniform scale in parent space as an atomic operation (for Urho2D).
+    void SetTransform(const Vector2& position, float rotation, float scale) { SetTransform(Vector3(position), Quaternion(rotation), scale); }
     /// Set both position, rotation and scale in parent space as an atomic operation.
     void SetTransform(const Vector3& position, const Quaternion& rotation, const Vector3& scale);
+    /// Set both position, rotation and scale in parent space as an atomic operation (for Urho2D).
+    void SetTransform(const Vector2& position, float rotation, const Vector2& scale)  { SetTransform(Vector3(position), Quaternion(rotation), Vector3(scale, 1.0f)); }
     /// Set position in world space.
     void SetWorldPosition(const Vector3& position);
+    /// Set position in world space (for Urho2D).
+    void SetWorldPosition(const Vector2& position) { SetWorldPosition(Vector3(position)); }
     /// Set rotation in world space.
     void SetWorldRotation(const Quaternion& rotation);
+    /// Set rotation in world space (for Urho2D).
+    void SetWorldRotation(float rotation) { SetWorldRotation(Quaternion(rotation)); }
     /// Set forward direction in world space.
     void SetWorldDirection(const Vector3& direction);
     /// Set uniform scale in world space.
     void SetWorldScale(float scale);
     /// Set scale in world space.
     void SetWorldScale(const Vector3& scale);
+    /// Set scale in world space (for Urho2D).
+    void SetWorldScale(const Vector2& scale) { SetWorldScale(Vector3(scale, 1.0f)); }
     /// Set both position and rotation in world space as an atomic operation.
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation);
+    /// Set both position and rotation in world space as an atomic operation (for Urho2D).
+    void SetWorldTransform(const Vector2& position, float rotation) { SetWorldTransform(Vector3(position), Quaternion(rotation)); }
     /// Set both position, rotation and uniform scale in world space as an atomic operation.
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation, float scale);
+    /// Set both position, rotation and uniform scale in world space as an atomic operation (for Urho2D).
+    void SetWorldTransform(const Vector2& position, float rotation, float scale) { SetWorldTransform(Vector3(position), Quaternion(rotation), scale); }
     /// Set both position, rotation and scale in world space as an atomic opration.
     void SetWorldTransform(const Vector3& position, const Quaternion& rotation, const Vector3& scale);
+    /// Set both position, rotation and scale in world space as an atomic opration (for Urho2D).
+    void SetWorldTransform(const Vector2& position, float rotation, const Vector2& scale) { SetWorldTransform(Vector3(position), Quaternion(rotation), Vector3(scale, 1.0f)); }
     /// Move the scene node in the chosen transform space.
     void Translate(const Vector3& delta, TransformSpace space = TS_LOCAL);
+    /// Move the scene node in the chosen transform space (for Urho2D).
+    void Translate(const Vector2& delta, TransformSpace space = TS_LOCAL) { Translate(Vector3(delta), space); }
     /// Rotate the scene node in the chosen transform space.
     void Rotate(const Quaternion& delta, TransformSpace space = TS_LOCAL);
+    /// Rotate the scene node in the chosen transform space (for Urho2D).
+    void Rotate(float delta, TransformSpace space = TS_LOCAL) { Rotate(Quaternion(delta), space); }
     /// Rotate around a point in the chosen transform space.
     void RotateAround(const Vector3& point, const Quaternion& delta, TransformSpace space = TS_LOCAL);
+    /// Rotate around a point in the chosen transform space (for Urho2D).
+    void RotateAround(const Vector2& point, float delta, TransformSpace space = TS_LOCAL) { RotateAround(Vector3(point), Quaternion(delta), space); }
     /// Rotate around the X axis.
     void Pitch(float angle, TransformSpace space = TS_LOCAL);
     /// Rotate around the Y axis.
@@ -138,6 +168,8 @@ public:
     void Scale(float scale);
     /// Modify scale in parent space.
     void Scale(const Vector3& scale);
+    /// Modify scale in parent space (for Urho3D).
+    void Scale(const Vector2& scale) { Scale(Vector3(scale, 1.0f)); }
     /// Set enabled/disabled state without recursion. Components in a disabled node become effectively disabled regardless of their own enable/disable state.
     void SetEnabled(bool enable);
     /// Set enabled/disabled state with optional recursion.
@@ -284,10 +316,14 @@ public:
     Vector3 LocalToWorld(const Vector3& position) const;
     /// Convert a local space position or rotation to world space.
     Vector3 LocalToWorld(const Vector4& vector) const;
+    /// Convert a local space position or rotation to world space (for Urho2D).
+    Vector2 LocalToWorld(const Vector2& vector) const;
     /// Convert a world space position to local space.
     Vector3 WorldToLocal(const Vector3& position) const;
     /// Convert a world space position or rotation to local space.
     Vector3 WorldToLocal(const Vector4& vector) const;
+    /// Convert a world space position or rotation to local space (for Urho2D).
+    Vector2 WorldToLocal(const Vector2& vector) const;
     /// Return whether transform has changed and world transform needs recalculation.
     bool IsDirty() const { return dirty_; }
     /// Return number of child scene nodes.

+ 25 - 7
Source/Engine/Script/APITemplates.h

@@ -591,22 +591,38 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
 {
     RegisterAnimatable<T>(engine, className);
     RegisterSubclass<Node, T>(engine, "Node", className);
+    engine->RegisterObjectMethod(className, "void SetPosition(const Vector2&in)", asMETHODPR(T, SetPosition, (const Vector2&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetRotation(float)", asMETHODPR(T, SetRotation, (float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetScale(float)", asMETHODPR(T, SetScale, (float), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetScale(const Vector2& in)", asMETHODPR(T, SetScale, (const Vector2&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetTransform(const Vector3&in, const Quaternion&in)", asMETHODPR(T, SetTransform, (const Vector3&, const Quaternion&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetTransform(const Vector2&in, float)", asMETHODPR(T, SetTransform, (const Vector2&, float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetTransform(const Vector3&in, const Quaternion&in, float)", asMETHODPR(T, SetTransform, (const Vector3&, const Quaternion&, float), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetTransform(const Vector2&in, float, float)", asMETHODPR(T, SetTransform, (const Vector2&, float, float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetTransform(const Vector3&in, const Quaternion&in, const Vector3&in)", asMETHODPR(T, SetTransform, (const Vector3&, const Quaternion&, const Vector3&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetTransform(const Vector2&in, float, const Vector2&in)", asMETHODPR(T, SetTransform, (const Vector2&, float, const Vector2&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldPosition(const Vector2&in)", asMETHODPR(T, SetWorldPosition, (const Vector2&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldRotation(float)", asMETHODPR(T, SetWorldRotation, (float), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldScale(const Vector2& in)", asMETHODPR(T, SetWorldScale, (const Vector2&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector3&in, const Quaternion&in)", asMETHODPR(T, SetWorldTransform, (const Vector3&, const Quaternion&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector2&in, float)", asMETHODPR(T, SetWorldTransform, (const Vector2&, float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector3&in, const Quaternion&in, float)", asMETHODPR(T, SetWorldTransform, (const Vector3&, const Quaternion&, float), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector2&in, float, float)", asMETHODPR(T, SetWorldTransform, (const Vector2&, float, float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector3&in, const Quaternion&in, const Vector3&in)", asMETHODPR(T, SetWorldTransform, (const Vector3&, const Quaternion&, const Vector3&), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void Translate(const Vector3&in, TransformSpace space = TS_LOCAL)", asMETHOD(T, Translate), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void Rotate(const Quaternion&in, TransformSpace space = TS_LOCAL)", asMETHOD(T, Rotate), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void RotateAround(const Vector3&in, const Quaternion&in, TransformSpace space = TS_LOCAL)", asMETHOD(T, RotateAround), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetWorldTransform(const Vector2&in, float, const Vector2&in)", asMETHODPR(T, SetWorldTransform, (const Vector2&, float, const Vector2&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void Translate(const Vector3&in, TransformSpace space = TS_LOCAL)", asMETHODPR(T, Translate, (const Vector3&, TransformSpace), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void Translate(const Vector2&in, TransformSpace space = TS_LOCAL)", asMETHODPR(T, Translate, (const Vector2&, TransformSpace), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void Rotate(const Quaternion&in, TransformSpace space = TS_LOCAL)", asMETHODPR(T, Rotate, (const Quaternion&, TransformSpace), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void Rotate(float, TransformSpace space = TS_LOCAL)", asMETHODPR(T, Rotate, (float, TransformSpace), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void RotateAround(const Vector3&in, const Quaternion&in, TransformSpace space = TS_LOCAL)", asMETHODPR(T, RotateAround, (const Vector3&, const Quaternion&, TransformSpace), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void RotateAround(const Vector2&in, float, TransformSpace space = TS_LOCAL)", asMETHODPR(T, RotateAround, (const Vector2&, float, TransformSpace), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Pitch(float, TransformSpace space = TS_LOCAL)", asMETHOD(T, Pitch), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Yaw(float, TransformSpace space = TS_LOCAL)", asMETHOD(T, Yaw), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Roll(float, TransformSpace space = TS_LOCAL)", asMETHOD(T, Roll), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool LookAt(const Vector3&in, const Vector3&in up = Vector3(0, 1, 0), TransformSpace space = TS_WORLD)", asMETHOD(T, LookAt), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Scale(float)", asMETHODPR(T, Scale, (float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Scale(const Vector3&in)", asMETHODPR(T, Scale, (const Vector3&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void Scale(const Vector2&in)", asMETHODPR(T, Scale, (const Vector2&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Node@+ CreateChild(const String&in name = String(), CreateMode mode = REPLICATED, uint id = 0)", asMETHODPR(T, CreateChild, (const String&, CreateMode, unsigned), Node*), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void AddChild(Node@+, uint index = M_MAX_UNSIGNED)", asMETHOD(T, AddChild), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void RemoveChild(Node@+)", asMETHODPR(T, RemoveChild, (Node*), void), asCALL_THISCALL);
@@ -630,11 +646,13 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
     engine->RegisterObjectMethod(className, "bool HasComponent(const String&in) const", asFUNCTION(NodeHasComponent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "Vector3 LocalToWorld(const Vector3&in) const", asMETHODPR(T, LocalToWorld, (const Vector3&) const, Vector3), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 LocalToWorld(const Vector4&in) const", asMETHODPR(T, LocalToWorld, (const Vector4&) const, Vector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 LocalToWorld(const Vector2&in) const", asMETHODPR(T, LocalToWorld, (const Vector2&) const, Vector2), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 WorldToLocal(const Vector3&in) const", asMETHODPR(T, WorldToLocal, (const Vector3&) const, Vector3), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 WorldToLocal(const Vector4&in) const", asMETHODPR(T, WorldToLocal, (const Vector4&) const, Vector3), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void set_position(const Vector3&in)", asMETHOD(T, SetPosition), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 WorldToLocal(const Vector2&in) const", asMETHODPR(T, WorldToLocal, (const Vector2&) const, Vector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_position(const Vector3&in)", asMETHODPR(T, SetPosition, (const Vector3&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "const Vector3& get_position() const", asMETHOD(T, GetPosition), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void set_rotation(const Quaternion&in)", asMETHOD(T, SetRotation), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_rotation(const Quaternion&in)", asMETHODPR(T, SetRotation, (const Quaternion&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "const Quaternion& get_rotation() const", asMETHOD(T, GetRotation), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_direction(const Vector3&in)", asMETHOD(T, SetDirection), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 get_direction() const", asMETHOD(T, GetDirection), asCALL_THISCALL);
@@ -642,9 +660,9 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
     engine->RegisterObjectMethod(className, "Vector3 get_right() const", asMETHOD(T, GetRight), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_scale(const Vector3&in)", asMETHODPR(T, SetScale, (const Vector3&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "const Vector3& get_scale() const", asMETHOD(T, GetScale), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void set_worldPosition(const Vector3&in)", asMETHOD(T, SetWorldPosition), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_worldPosition(const Vector3&in)", asMETHODPR(T, SetWorldPosition, (const Vector3&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 get_worldPosition()", asMETHOD(T, GetWorldPosition), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void set_worldRotation(const Quaternion&in)", asMETHOD(T, SetWorldRotation), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_worldRotation(const Quaternion&in)", asMETHODPR(T, SetWorldRotation, (const Quaternion&in), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Quaternion get_worldRotation()", asMETHOD(T, GetWorldRotation), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_worldDirection(const Vector3&in)", asMETHOD(T, SetWorldDirection), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Vector3 get_worldDirection()", asMETHOD(T, GetWorldDirection), asCALL_THISCALL);

+ 26 - 2
Source/Engine/Script/MathAPI.cpp

@@ -257,11 +257,26 @@ static void ConstructVector3Copy(const Vector3& vector, Vector3* ptr)
     new(ptr) Vector3(vector);
 }
 
-static void ConstructVector3Init(float x, float y, float z, Vector3* ptr)
+static void ConstructVector3Vector2Z(const Vector2& vector, float z, Vector3* ptr)
+{
+    new(ptr) Vector3(vector, z);
+}
+
+static void ConstructVector3Vector2(const Vector2& vector, Vector3* ptr)
+{
+    new(ptr) Vector3(vector);
+}
+
+static void ConstructVector3XYZ(float x, float y, float z, Vector3* ptr)
 {
     new(ptr) Vector3(x, y, z);
 }
 
+static void ConstructVector3XY(float x, float y, Vector3* ptr)
+{
+    new(ptr) Vector3(x, y);
+}
+
 static void ConstructVector3ArrayInit(CScriptArray* data, Vector3* ptr)
 {
     new(ptr) Vector3((static_cast<float*>(data->At(0))));
@@ -277,7 +292,10 @@ static void RegisterVector3(asIScriptEngine* engine)
     engine->RegisterObjectType("Vector3", sizeof(Vector3), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK);
     engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructVector3), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(const Vector3&in)", asFUNCTION(ConstructVector3Copy), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructVector3Init), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(const Vector2&in, float)", asFUNCTION(ConstructVector3Vector2Z), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(const Vector2&in)", asFUNCTION(ConstructVector3Vector2), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructVector3XYZ), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTION(ConstructVector3XY), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Vector3", asBEHAVE_CONSTRUCT, "void f(float[]&)", asFUNCTION(ConstructVector3ArrayInit), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Vector3", "float[]& get_data() const", asFUNCTION(Vector3Data), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Vector3", "Vector3& opAssign(const Vector3&in)", asMETHOD(Vector3, operator =), asCALL_THISCALL);
@@ -398,6 +416,11 @@ static void ConstructQuaternionAngleAxis(float angle, const Vector3& axis, Quate
     new(ptr) Quaternion(angle, axis);
 }
 
+static void ConstructQuaternionAngle(float angle, Quaternion* ptr)
+{
+    new(ptr) Quaternion(angle);
+}
+
 static void ConstructQuaternionEuler(float angleX, float angleY, float angleZ, Quaternion* ptr)
 {
     new(ptr) Quaternion(angleX, angleY, angleZ);
@@ -425,6 +448,7 @@ static void RegisterQuaternion(asIScriptEngine* engine)
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(const Quaternion&in)", asFUNCTION(ConstructQuaternionCopy), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, float, float, float)", asFUNCTION(ConstructQuaternionInit), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, const Vector3&in)", asFUNCTION(ConstructQuaternionAngleAxis), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float)", asFUNCTION(ConstructQuaternionAngle), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(ConstructQuaternionEuler), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(const Vector3&in)", asFUNCTION(ConstructQuaternionEulerVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Quaternion", asBEHAVE_CONSTRUCT, "void f(const Vector3&in, const Vector3&in)", asFUNCTION(ConstructQuaternionRotation), asCALL_CDECL_OBJLAST);