Browse Source

Added some @script{create} tags.
Changed ScriptController to warn instead of error when a script errors.
Added methods that take 3 or 4 floats instead of a Vector3 or Vector4 so that Lua scripts can call them without having to create a Vector.

Darryl Gough 13 năm trước cách đây
mục cha
commit
69fc8b07c0

+ 1 - 0
gameplay/src/Animation.h

@@ -59,6 +59,7 @@ public:
      * @param end The time (in milliseconds) that the AnimationClip will end.
      * @param end The time (in milliseconds) that the AnimationClip will end.
      * 
      * 
      * @return The newly created AnimationClip; NULL if an AnimationClip already exists with the same ID.
      * @return The newly created AnimationClip; NULL if an AnimationClip already exists with the same ID.
+     * @script{create}
      */
      */
     AnimationClip* createClip(const char* id, unsigned long start, unsigned long end);
     AnimationClip* createClip(const char* id, unsigned long start, unsigned long end);
     
     

+ 16 - 0
gameplay/src/AudioListener.cpp

@@ -41,6 +41,11 @@ void AudioListener::setPosition(const Vector3& position)
     _position = position;
     _position = position;
 }
 }
 
 
+void AudioListener::setPosition(float x, float y, float z)
+{
+    _position.set(x, y, z);
+}
+
 const Vector3& AudioListener::getVelocity() const 
 const Vector3& AudioListener::getVelocity() const 
 { 
 { 
     return _velocity; 
     return _velocity; 
@@ -51,6 +56,11 @@ void AudioListener::setVelocity(const Vector3& velocity)
     _velocity = velocity;
     _velocity = velocity;
 }
 }
 
 
+void AudioListener::setVelocity(float x, float y, float z)
+{
+    _velocity.set(x, y, z);
+}
+
 const float* AudioListener::getOrientation() const
 const float* AudioListener::getOrientation() const
 {
 {
     return (const float*)&_orientation[0];
     return (const float*)&_orientation[0];
@@ -77,6 +87,12 @@ void AudioListener::setOrientation(const Vector3& forward, const Vector3& up)
     _orientation[1].z = up.z;
     _orientation[1].z = up.z;
 }
 }
 
 
+void AudioListener::setOrientation(float forwardX, float forwardY, float forwardZ, float upX, float upY, float upZ)
+{
+    _orientation[0].set(forwardX, forwardY, forwardZ);
+    _orientation[1].set(upX, upY, upZ);
+}
+
 Camera* AudioListener::getCamera() const
 Camera* AudioListener::getCamera() const
 {
 {
     return _camera;
     return _camera;

+ 30 - 0
gameplay/src/AudioListener.h

@@ -40,6 +40,15 @@ public:
      */
      */
     void setPosition(const Vector3& position);
     void setPosition(const Vector3& position);
 
 
+    /**
+     * Sets the position of the audio source.
+     * 
+     * @param x The x coordinate of the position.
+     * @param y The y coordinate of the position.
+     * @param z The z coordinate of the position.
+     */
+    void setPosition(float x, float y, float z);
+
     /**
     /**
      * Returns the gain of the audio listener.
      * Returns the gain of the audio listener.
      *
      *
@@ -68,6 +77,15 @@ public:
      */
      */
     void setVelocity(const Vector3& velocity);
     void setVelocity(const Vector3& velocity);
 
 
+    /**
+     * Sets the velocity of the audio source
+     * 
+     * @param x The x coordinate of the velocity.
+     * @param y The y coordinate of the velocity.
+     * @param z The z coordinate of the velocity.
+     */
+    void setVelocity(float x, float y, float z);
+
     /**
     /**
      * Gets the float pointer to the orientation of the audio listener.
      * Gets the float pointer to the orientation of the audio listener.
      * Orientation is represented as 6 floats. (forward.x, forward.y, forward.z, up.x, up.y, up.z).
      * Orientation is represented as 6 floats. (forward.x, forward.y, forward.z, up.x, up.y, up.z).
@@ -99,6 +117,18 @@ public:
      */
      */
     void setOrientation(const Vector3& forward, const Vector3& up);
     void setOrientation(const Vector3& forward, const Vector3& up);
 
 
+    /**
+     * Sets the orientation of the audio listener.
+     * 
+     * @param forwardX The x coordinate of the forward vector.
+     * @param forwardY The y coordinate of the forward vector.
+     * @param forwardZ The z coordinate of the forward vector.
+     * @param upX The x coordinate of the up vector.
+     * @param upY The y coordinate of the up vector.
+     * @param upZ The z coordinate of the up vector.
+     */
+    void setOrientation(float forwardX, float forwardY, float forwardZ, float upX, float upY, float upZ);
+
     /**
     /**
      * Gets the camera currently associated with the audio listener.
      * Gets the camera currently associated with the audio listener.
      *
      *

+ 5 - 0
gameplay/src/AudioSource.cpp

@@ -233,6 +233,11 @@ void AudioSource::setVelocity(const Vector3& velocity)
     _velocity = velocity;
     _velocity = velocity;
 }
 }
 
 
+void AudioSource::setVelocity(float x, float y, float z)
+{
+    setVelocity(Vector3(x, y, z));
+}
+
 Node* AudioSource::getNode() const
 Node* AudioSource::getNode() const
 {
 {
     return _node;
     return _node;

+ 9 - 0
gameplay/src/AudioSource.h

@@ -141,6 +141,15 @@ public:
      */
      */
     void setVelocity(const Vector3& velocity);
     void setVelocity(const Vector3& velocity);
 
 
+    /**
+     * Sets the velocity of the audio source.
+     *
+     * @param x The x coordinate of the velocity.
+     * @param y The y coordinate of the velocity.
+     * @param z The z coordinate of the velocity.
+     */
+    void setVelocity(float x, float y, float z);
+
     /**
     /**
      * Gets the node that this source is attached to.
      * Gets the node that this source is attached to.
      * 
      * 

+ 11 - 0
gameplay/src/BoundingBox.cpp

@@ -15,6 +15,11 @@ BoundingBox::BoundingBox(const Vector3& min, const Vector3& max)
     set(min, max);
     set(min, max);
 }
 }
 
 
+BoundingBox::BoundingBox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
+{
+    set(minX, minY, minZ, maxX, maxY, maxZ);
+}
+
 BoundingBox::BoundingBox(const BoundingBox& copy)
 BoundingBox::BoundingBox(const BoundingBox& copy)
 {
 {
     set(copy);
     set(copy);
@@ -247,6 +252,12 @@ void BoundingBox::set(const Vector3& min, const Vector3& max)
     this->max = max;
     this->max = max;
 }
 }
 
 
+void BoundingBox::set(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
+{
+    min.set(minX, minY, minZ);
+    max.set(maxX, maxY, maxZ);
+}
+
 static void updateMinMax(Vector3* point, Vector3* min, Vector3* max)
 static void updateMinMax(Vector3* point, Vector3* min, Vector3* max)
 {
 {
     GP_ASSERT(point);
     GP_ASSERT(point);

+ 24 - 0
gameplay/src/BoundingBox.h

@@ -36,6 +36,18 @@ public:
      */
      */
     BoundingBox(const Vector3& min, const Vector3& max);
     BoundingBox(const Vector3& min, const Vector3& max);
 
 
+    /**
+     * Constructs a new bounding box from the specified values.
+     * 
+     * @param minX The x coordinate of the minimum point of the bounding box.
+     * @param minY The y coordinate of the minimum point of the bounding box.
+     * @param minZ The z coordinate of the minimum point of the bounding box.
+     * @param maxX The x coordinate of the maximum point of the bounding box.
+     * @param maxY The y coordinate of the maximum point of the bounding box.
+     * @param maxZ The z coordinate of the maximum point of the bounding box.
+     */
+    BoundingBox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ);
+
     /**
     /**
      * Constructs a new bounding box from the given bounding box.
      * Constructs a new bounding box from the given bounding box.
      *
      *
@@ -163,6 +175,18 @@ public:
      */
      */
     void set(const Vector3& min, const Vector3& max);
     void set(const Vector3& min, const Vector3& max);
 
 
+    /**
+     * Sets this bounding box to the specified values.
+     * 
+     * @param minX The x coordinate of the minimum point of the bounding box.
+     * @param minY The y coordinate of the minimum point of the bounding box.
+     * @param minZ The z coordinate of the minimum point of the bounding box.
+     * @param maxX The x coordinate of the maximum point of the bounding box.
+     * @param maxY The y coordinate of the maximum point of the bounding box.
+     * @param maxZ The z coordinate of the maximum point of the bounding box.
+     */
+    void set(float minX, float minY, float minZ, float maxX, float maxY, float maxZ);
+
     /**
     /**
      * Sets this bounding box to the specified bounding box.
      * Sets this bounding box to the specified bounding box.
      *
      *

+ 5 - 0
gameplay/src/Font.cpp

@@ -541,6 +541,11 @@ void Font::drawText(const char* text, int x, int y, const Vector4& color, unsign
     }
     }
 }
 }
 
 
+void Font::drawText(const char* text, int x, int y, float red, float green, float blue, float alpha, unsigned int size, bool rightToLeft)
+{
+    drawText(text, x, y, Vector4(red, green, blue, alpha), size, rightToLeft);
+}
+
 void Font::drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size, Justify justify, bool wrap, bool rightToLeft, const Rectangle* clip)
 void Font::drawText(const char* text, const Rectangle& area, const Vector4& color, unsigned int size, Justify justify, bool wrap, bool rightToLeft, const Rectangle* clip)
 {
 {
     GP_ASSERT(text);
     GP_ASSERT(text);

+ 15 - 0
gameplay/src/Font.h

@@ -128,6 +128,21 @@ public:
      */
      */
     void drawText(const char* text, int x, int y, const Vector4& color, unsigned int size = 0, bool rightToLeft = false);
     void drawText(const char* text, int x, int y, const Vector4& color, unsigned int size = 0, bool rightToLeft = false);
 
 
+    /**
+     * Draws the specified text in a solid color, with a scaling factor.
+     * 
+     * @param text The text to draw.
+     * @param x The viewport x position to draw text at.
+     * @param y The viewport y position to draw text at.
+     * @param red The red channel of the text color.
+     * @param green The green channel of the text color.
+     * @param blue The blue channel of the text color.
+     * @param alpha The alpha channel of the text color.
+     * @param size The size to draw text (0 for default size).
+     * @param rightToLeft Whether to draw text from right to left.
+     */
+    void drawText(const char* text, int x, int y, float red, float green, float blue, float alpha, unsigned int size = 0, bool rightToLeft = false);
+
     /**
     /**
      * Draws the specified text within a rectangular area, with a specified alignment and scale.
      * Draws the specified text within a rectangular area, with a specified alignment and scale.
      * Clips text outside the viewport. Optionally wraps text to fit within the width of the viewport.
      * Clips text outside the viewport. Optionally wraps text to fit within the width of the viewport.

+ 5 - 0
gameplay/src/Frustum.cpp

@@ -93,6 +93,11 @@ bool Frustum::intersects(const Vector3& point) const
     return true;
     return true;
 }
 }
 
 
+bool Frustum::intersects(float x, float y, float z) const
+{
+    return intersects(Vector3(x, y, z));
+}
+
 bool Frustum::intersects(const BoundingSphere& sphere) const
 bool Frustum::intersects(const BoundingSphere& sphere) const
 {
 {
     return sphere.intersects(*this);
     return sphere.intersects(*this);

+ 11 - 0
gameplay/src/Frustum.h

@@ -122,6 +122,17 @@ public:
      */
      */
     bool intersects(const Vector3& point) const;
     bool intersects(const Vector3& point) const;
 
 
+    /**
+     * Tests whether this frustum instersects the specified point.
+     *
+     * @param x The x coordinate.
+     * @param y The y coordinate.
+     * @param z The z coordinate.
+     *
+     * @return true if the specified point intersects this frustum; false otherwise.
+     */
+    bool intersects(float x, float y, float z) const;
+
     /**
     /**
      * Tests whether this frustum intersects the specified bounding sphere.
      * Tests whether this frustum intersects the specified bounding sphere.
      *
      *

+ 5 - 0
gameplay/src/Game.cpp

@@ -408,6 +408,11 @@ void Game::clear(ClearFlags flags, const Vector4& clearColor, float clearDepth,
     glClear(bits);
     glClear(bits);
 }
 }
 
 
+void Game::clear(ClearFlags flags, float red, float green, float blue, float alpha, float clearDepth, int clearStencil)
+{
+    clear(flags, Vector4(red, green, blue, alpha), clearDepth, clearStencil);
+}
+
 AudioListener* Game::getAudioListener()
 AudioListener* Game::getAudioListener()
 {
 {
     if (_audioListener == NULL)
     if (_audioListener == NULL)

+ 13 - 0
gameplay/src/Game.h

@@ -196,6 +196,19 @@ public:
      */
      */
     void clear(ClearFlags flags, const Vector4& clearColor, float clearDepth, int clearStencil);
     void clear(ClearFlags flags, const Vector4& clearColor, float clearDepth, int clearStencil);
 
 
+    /**
+     * Clears the specified resource buffers to the specified clear values. 
+     * 
+     * @param flags The flags indicating which buffers to be cleared.
+     * @param red The red channel.
+     * @param green The green channel.
+     * @param blue The blue channel.
+     * @param alpha The alpha channel.
+     * @param clearDepth The depth value to clear to when the flags includes the color buffer.
+     * @param clearStencil The stencil value to clear to when the flags includes the color buffer.
+     */
+    void clear(ClearFlags flags, float red, float green, float blue, float alpha, float clearDepth, int clearStencil);
+
     /**
     /**
      * Gets the audio controller for managing control of audio
      * Gets the audio controller for managing control of audio
      * associated with the game.
      * associated with the game.

+ 20 - 0
gameplay/src/Light.cpp

@@ -47,16 +47,31 @@ Light* Light::createDirectional(const Vector3& color)
     return new Light(DIRECTIONAL, color);
     return new Light(DIRECTIONAL, color);
 }
 }
 
 
+Light* Light::createDirectional(float red, float green, float blue)
+{
+    return new Light(DIRECTIONAL, Vector3(red, green, blue));
+}
+
 Light* Light::createPoint(const Vector3& color, float range)
 Light* Light::createPoint(const Vector3& color, float range)
 {
 {
     return new Light(POINT, color, range);
     return new Light(POINT, color, range);
 }
 }
 
 
+Light* Light::createPoint(float red, float green, float blue, float range)
+{
+    return new Light(POINT, Vector3(red, green, blue), range);
+}
+
 Light* Light::createSpot(const Vector3& color, float range, float innerAngle, float outerAngle)
 Light* Light::createSpot(const Vector3& color, float range, float innerAngle, float outerAngle)
 {
 {
     return new Light(SPOT, color, range, innerAngle, outerAngle);
     return new Light(SPOT, color, range, innerAngle, outerAngle);
 }
 }
 
 
+Light* Light::createSpot(float red, float green, float blue, float range, float innerAngle, float outerAngle)
+{
+    return new Light(SPOT, Vector3(red, green, blue), range, innerAngle, outerAngle);
+}
+
 Light::Type Light::getLightType() const
 Light::Type Light::getLightType() const
 {
 {
     return _type;
     return _type;
@@ -115,6 +130,11 @@ void Light::setColor(const Vector3& color)
     }
     }
 }
 }
 
 
+void Light::setColor(float red, float green, float blue)
+{
+    setColor(Vector3(red, green, blue));
+}
+
 float Light::getRange()  const
 float Light::getRange()  const
 {
 {
     GP_ASSERT(_type != DIRECTIONAL);
     GP_ASSERT(_type != DIRECTIONAL);

+ 52 - 0
gameplay/src/Light.h

@@ -35,9 +35,22 @@ public:
      * @param color Color of the light.
      * @param color Color of the light.
      * 
      * 
      * @return The new directional light.
      * @return The new directional light.
+     * @script{create}
      */
      */
     static Light* createDirectional(const Vector3& color);
     static Light* createDirectional(const Vector3& color);
 
 
+    /**
+     * Creates a directional light.
+     * 
+     * @param red The red channel.
+     * @param green The green channel.
+     * @param blue The blue channel.
+     * 
+     * @return The new directional light.
+     * @script{create}
+     */
+    static Light* createDirectional(float red, float green, float blue);
+
     /**
     /**
      * Creates a point light.
      * Creates a point light.
      * 
      * 
@@ -45,9 +58,23 @@ public:
      * @param range The light's range.
      * @param range The light's range.
      * 
      * 
      * @return The new point light.
      * @return The new point light.
+     * @script{create}
      */
      */
     static Light* createPoint(const Vector3& color, float range);
     static Light* createPoint(const Vector3& color, float range);
 
 
+    /**
+     * Creates a point light.
+     * 
+     * @param red The red channel.
+     * @param green The green channel.
+     * @param blue The blue channel.
+     * @param range The light's range.
+     * 
+     * @return The new point light.
+     * @script{create}
+     */
+    static Light* createPoint(float red, float green, float blue, float range);
+
     /**
     /**
      * Creates a spot light.
      * Creates a spot light.
      * 
      * 
@@ -57,9 +84,25 @@ public:
      * @param outerAngle The light's outer angle (in radians).
      * @param outerAngle The light's outer angle (in radians).
      * 
      * 
      * @return The new spot light.
      * @return The new spot light.
+     * @script{create}
      */
      */
     static Light* createSpot(const Vector3& color, float range, float innerAngle, float outerAngle);
     static Light* createSpot(const Vector3& color, float range, float innerAngle, float outerAngle);
 
 
+    /**
+     * Creates a spot light.
+     * 
+     * @param red The red channel.
+     * @param green The green channel.
+     * @param blue The blue channel.
+     * @param range The light's range.
+     * @param innerAngle The light's inner angle (in radians).
+     * @param outerAngle The light's outer angle (in radians).
+     * 
+     * @return The new spot light.
+     * @script{create}
+     */
+    static Light* createSpot(float red, float green, float blue, float range, float innerAngle, float outerAngle);
+
     /**
     /**
      * Destructor.
      * Destructor.
      */
      */
@@ -91,6 +134,15 @@ public:
      */
      */
     void setColor(const Vector3& color);
     void setColor(const Vector3& color);
 
 
+    /**
+     * Sets the light color.
+     * 
+     * @param red The red channel.
+     * @param green The green channel.
+     * @param blue The blue channel.
+     */
+    void setColor(float red, float green, float blue);
+
     /**
     /**
      * Returns the node associated with this light.
      * Returns the node associated with this light.
      * 
      * 

+ 19 - 19
gameplay/src/Material.cpp

@@ -127,25 +127,6 @@ Material* Material::create(const char* vshPath, const char* fshPath, const char*
     return material;
     return material;
 }
 }
 
 
-Material* Material::clone(NodeCloneContext &context) const
-{
-    Material* material = new Material();
-    RenderState::cloneInto(material, context);
-
-    for (std::vector<Technique*>::const_iterator it = _techniques.begin(); it != _techniques.end(); ++it)
-    {
-        const Technique* technique = *it;
-        GP_ASSERT(technique);
-        Technique* techniqueClone = technique->clone(material, context);
-        material->_techniques.push_back(techniqueClone);
-        if (_currentTechnique == technique)
-        {
-            material->_currentTechnique = techniqueClone;
-        }
-    }
-    return material;
-}
-
 unsigned int Material::getTechniqueCount() const
 unsigned int Material::getTechniqueCount() const
 {
 {
     return _techniques.size();
     return _techniques.size();
@@ -187,6 +168,25 @@ void Material::setTechnique(const char* id)
     }
     }
 }
 }
 
 
+Material* Material::clone(NodeCloneContext &context) const
+{
+    Material* material = new Material();
+    RenderState::cloneInto(material, context);
+
+    for (std::vector<Technique*>::const_iterator it = _techniques.begin(); it != _techniques.end(); ++it)
+    {
+        const Technique* technique = *it;
+        GP_ASSERT(technique);
+        Technique* techniqueClone = technique->clone(material, context);
+        material->_techniques.push_back(techniqueClone);
+        if (_currentTechnique == technique)
+        {
+            material->_currentTechnique = techniqueClone;
+        }
+    }
+    return material;
+}
+
 bool Material::loadTechnique(Material* material, Properties* techniqueProperties)
 bool Material::loadTechnique(Material* material, Properties* techniqueProperties)
 {
 {
     GP_ASSERT(material);
     GP_ASSERT(material);

+ 11 - 9
gameplay/src/Material.h

@@ -24,6 +24,7 @@ class Material : public RenderState
     friend class Pass;
     friend class Pass;
     friend class RenderState;
     friend class RenderState;
     friend class Node;
     friend class Node;
+    friend class Model;
 
 
 public:
 public:
 
 
@@ -77,15 +78,6 @@ public:
      */
      */
     static Material* create(const char* vshPath, const char* fshPath, const char* defines = NULL);
     static Material* create(const char* vshPath, const char* fshPath, const char* defines = NULL);
 
 
-    /**
-     * Clones this material.
-     * 
-     * @param context The clone context.
-     * 
-     * @return The newly created material.
-     */
-    Material* clone(NodeCloneContext &context) const;
-
     /**
     /**
      * Returns the number of techniques in the material.
      * Returns the number of techniques in the material.
      *
      *
@@ -142,6 +134,16 @@ private:
      */
      */
     ~Material();
     ~Material();
 
 
+    /**
+     * Clones this material.
+     * 
+     * @param context The clone context.
+     * 
+     * @return The newly created material.
+     * @script{create}
+     */
+    Material* clone(NodeCloneContext &context) const;
+
     /**
     /**
      * Loads a technique from the given properties object into the specified material.
      * Loads a technique from the given properties object into the specified material.
      */
      */

+ 6 - 0
gameplay/src/Mesh.h

@@ -55,6 +55,7 @@ public:
      * @param dynamic true if the mesh is dynamic; false otherwise.
      * @param dynamic true if the mesh is dynamic; false otherwise.
      * 
      * 
      * @return The created mesh.
      * @return The created mesh.
+     * @script{create}
      */
      */
     static Mesh* createMesh(const VertexFormat& vertexFormat, unsigned int vertexCount, bool dynamic = false);
     static Mesh* createMesh(const VertexFormat& vertexFormat, unsigned int vertexCount, bool dynamic = false);
 
 
@@ -71,6 +72,7 @@ public:
      * @param p4 The fourth point.
      * @param p4 The fourth point.
      * 
      * 
      * @return The created mesh.
      * @return The created mesh.
+     * @script{create}
      */
      */
     static Mesh* createQuad(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4);
     static Mesh* createQuad(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4);
 
 
@@ -83,6 +85,7 @@ public:
      * @param height The height of the quad.
      * @param height The height of the quad.
      * 
      * 
      * @return The newly created mesh.
      * @return The newly created mesh.
+     * @script{create}
      */
      */
     static Mesh* createQuad(float x, float y, float width, float height);
     static Mesh* createQuad(float x, float y, float width, float height);
 
 
@@ -96,6 +99,7 @@ public:
      * normalized device coordinates for vertex positions.
      * normalized device coordinates for vertex positions.
      * 
      * 
      * @return The newly created mesh.
      * @return The newly created mesh.
+     * @script{create}
      */
      */
     static Mesh* createQuadFullscreen();
     static Mesh* createQuadFullscreen();
 
 
@@ -109,6 +113,7 @@ public:
      * @param pointCount The number of points.
      * @param pointCount The number of points.
      * 
      * 
      * @return The newly created mesh.
      * @return The newly created mesh.
+     * @script{create}
      */
      */
     static Mesh* createLines(Vector3* points, unsigned int pointCount);
     static Mesh* createLines(Vector3* points, unsigned int pointCount);
 
 
@@ -120,6 +125,7 @@ public:
      * @param box The BoundingBox that will be used to create the mesh.
      * @param box The BoundingBox that will be used to create the mesh.
      * 
      * 
      * @return The newly created bounding box mesh.
      * @return The newly created bounding box mesh.
+     * @script{create}
      */
      */
     static Mesh* createBoundingBox(const BoundingBox& box);
     static Mesh* createBoundingBox(const BoundingBox& box);
 
 

+ 1 - 0
gameplay/src/Node.h

@@ -578,6 +578,7 @@ public:
      * Clones the node and all of its child nodes.
      * Clones the node and all of its child nodes.
      * 
      * 
      * @return A new node.
      * @return A new node.
+     * @script{create}
      */
      */
     Node* clone() const;
     Node* clone() const;
 
 

+ 5 - 0
gameplay/src/PhysicsCharacter.cpp

@@ -202,6 +202,11 @@ void PhysicsCharacter::setVelocity(const Vector3& velocity)
     _moveVelocity.setValue(velocity.x, velocity.y, velocity.z);
     _moveVelocity.setValue(velocity.x, velocity.y, velocity.z);
 }
 }
 
 
+void PhysicsCharacter::setVelocity(float x, float y, float z)
+{
+    _moveVelocity.setValue(x, y, z);
+}
+
 void PhysicsCharacter::rotate(const Vector3& axis, float angle)
 void PhysicsCharacter::rotate(const Vector3& axis, float angle)
 {
 {
     GP_ASSERT(_node);
     GP_ASSERT(_node);

+ 14 - 0
gameplay/src/PhysicsCharacter.h

@@ -97,6 +97,20 @@ public:
      */
      */
     void setVelocity(const Vector3& velocity);
     void setVelocity(const Vector3& velocity);
 
 
+    /**
+     * Sets the velocity of the character.
+     *
+     * Calling this function sets the velocity (speed and direction) for the character.
+     * The velocity is maintained until this method is called again. The final velocity
+     * of the character is determined by product of the current velocity, right and
+     * forward vectors.
+     * 
+     * @param x The x coordinate of the velocity vector.
+     * @param y The y coordinate of the velocity vector.
+     * @param z The z coordinate of the velocity vector.
+     */
+    void setVelocity(float x, float y, float z);
+
     /**
     /**
      * Rotates the character.
      * Rotates the character.
      *
      *

+ 36 - 0
gameplay/src/PhysicsRigidBody.h

@@ -168,6 +168,15 @@ public:
      */
      */
     inline void setLinearVelocity(const Vector3& velocity);
     inline void setLinearVelocity(const Vector3& velocity);
 
 
+    /**
+     * Sets the rigid body's linear velocity.
+     * 
+     * @param x The x coordinate of the linear velocity vector.
+     * @param y The y coordinate of the linear velocity vector.
+     * @param z The z coordinate of the linear velocity vector.
+     */
+    inline void setLinearVelocity(float x, float y, float z);
+
     /**
     /**
      * Gets the rigid body's angular velocity.
      * Gets the rigid body's angular velocity.
      * 
      * 
@@ -182,6 +191,15 @@ public:
      */
      */
     inline void setAngularVelocity(const Vector3& velocity);
     inline void setAngularVelocity(const Vector3& velocity);
 
 
+    /**
+     * Sets the rigid body's angular velocity.
+     * 
+     * @param x The x coordinate of the angular velocity vector.
+     * @param y The y coordinate of the angular velocity vector.
+     * @param z The z coordinate of the angular velocity vector.
+     */
+    inline void setAngularVelocity(float x, float y, float z);
+
     /**
     /**
      * Gets the rigid body's anisotropic friction.
      * Gets the rigid body's anisotropic friction.
      * 
      * 
@@ -196,6 +214,15 @@ public:
      */
      */
     inline void setAnisotropicFriction(const Vector3& friction);
     inline void setAnisotropicFriction(const Vector3& friction);
 
 
+    /**
+     * Sets the rigid body's anisotropic friction.
+     * 
+     * @param x The x coordinate of the anisotropic friction.
+     * @param y The y coordinate of the anisotropic friction.
+     * @param z The z coordinate of the anisotropic friction.
+     */
+    inline void setAnisotropicFriction(float x, float y, float z);
+
     /**
     /**
      * Gets the gravity that affects the rigid body (this can
      * Gets the gravity that affects the rigid body (this can
      * be different from the global gravity; @see setGravity(Vector3)).
      * be different from the global gravity; @see setGravity(Vector3)).
@@ -211,6 +238,15 @@ public:
      */
      */
     inline void setGravity(const Vector3& gravity);
     inline void setGravity(const Vector3& gravity);
 
 
+    /**
+     * Sets the rigid body's gravity (this overrides the global gravity for this rigid body).
+     * 
+     * @param x The x coordinate of the gravity vector.
+     * @param y The y coordinate of the gravity vector.
+     * @param z The z coordinate of the gravity vector.
+     */
+    inline void setGravity(float x, float y, float z);
+
     /**
     /**
      * Sets whether the rigid body is a kinematic rigid body or not.
      * Sets whether the rigid body is a kinematic rigid body or not.
      * 
      * 

+ 24 - 0
gameplay/src/PhysicsRigidBody.inl

@@ -64,6 +64,12 @@ inline void PhysicsRigidBody::setLinearVelocity(const Vector3& velocity)
     _body->setLinearVelocity(BV(velocity));
     _body->setLinearVelocity(BV(velocity));
 }
 }
 
 
+inline void PhysicsRigidBody::setLinearVelocity(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setLinearVelocity(btVector3(x, y, z));
+}
+
 inline Vector3 PhysicsRigidBody::getAngularVelocity() const
 inline Vector3 PhysicsRigidBody::getAngularVelocity() const
 {
 {
     GP_ASSERT(_body);
     GP_ASSERT(_body);
@@ -77,6 +83,12 @@ inline void PhysicsRigidBody::setAngularVelocity(const Vector3& velocity)
     _body->setAngularVelocity(BV(velocity));
     _body->setAngularVelocity(BV(velocity));
 }
 }
 
 
+inline void PhysicsRigidBody::setAngularVelocity(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setAngularVelocity(btVector3(x, y, z));
+}
+
 inline Vector3 PhysicsRigidBody::getAnisotropicFriction() const
 inline Vector3 PhysicsRigidBody::getAnisotropicFriction() const
 {
 {
     GP_ASSERT(_body);
     GP_ASSERT(_body);
@@ -90,6 +102,12 @@ inline void PhysicsRigidBody::setAnisotropicFriction(const Vector3& friction)
     _body->setAnisotropicFriction(BV(friction));
     _body->setAnisotropicFriction(BV(friction));
 }
 }
 
 
+inline void PhysicsRigidBody::setAnisotropicFriction(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setAnisotropicFriction(btVector3(x, y, z));
+}
+
 inline Vector3 PhysicsRigidBody::getGravity() const
 inline Vector3 PhysicsRigidBody::getGravity() const
 {
 {
     GP_ASSERT(_body);
     GP_ASSERT(_body);
@@ -103,6 +121,12 @@ inline void PhysicsRigidBody::setGravity(const Vector3& gravity)
     _body->setGravity(BV(gravity));
     _body->setGravity(BV(gravity));
 }
 }
 
 
+inline void PhysicsRigidBody::setGravity(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setGravity(btVector3(x, y, z));
+}
+
 inline bool PhysicsRigidBody::isStatic() const
 inline bool PhysicsRigidBody::isStatic() const
 {
 {
     GP_ASSERT(_body);
     GP_ASSERT(_body);

+ 11 - 0
gameplay/src/Plane.cpp

@@ -18,6 +18,11 @@ Plane::Plane(const Vector3& normal, float distance)
     set(normal, distance);
     set(normal, distance);
 }
 }
 
 
+Plane::Plane(float normalX, float normalY, float normalZ, float distance)
+{
+    set(Vector3(normalX, normalY, normalZ), distance);
+}
+
 Plane::Plane(const Plane& copy)
 Plane::Plane(const Plane& copy)
 {
 {
     set(copy);
     set(copy);
@@ -38,6 +43,12 @@ void Plane::setNormal(const Vector3& normal)
     normalize();
     normalize();
 }
 }
 
 
+void Plane::setNormal(float x, float y, float z)
+{
+    _normal.set(x, y, z);
+    normalize();
+}
+
 float Plane::getDistance() const
 float Plane::getDistance() const
 {
 {
     return _distance;
     return _distance;

+ 19 - 0
gameplay/src/Plane.h

@@ -49,6 +49,16 @@ public:
      */
      */
     Plane(const Vector3& normal, float distance);
     Plane(const Vector3& normal, float distance);
 
 
+    /**
+     * Constructs a new plane from the specified values.
+     * 
+     * @param normalX The x coordinate of the normal.
+     * @param normalY The y coordinate of the normal.
+     * @param normalZ The z coordinate of the normal.
+     * @param distance The distance from this plane along its (unit) normal to the origin.
+     */
+    Plane(float normalX, float normalY, float normalZ, float distance);
+
     /**
     /**
      * Constructs a new plane from the given plane.
      * Constructs a new plane from the given plane.
      *
      *
@@ -75,6 +85,15 @@ public:
      */
      */
     void setNormal(const Vector3& normal);
     void setNormal(const Vector3& normal);
 
 
+    /**
+     * Sets the plane's normal.
+     * 
+     * @param x The x coordinate of the normal.
+     * @param y The y coordinate of the normal.
+     * @param z The z coordinate of the normal.
+     */
+    void setNormal(float x, float y, float z);
+
     /**
     /**
      * Gets the plane's distance to the origin along its normal.
      * Gets the plane's distance to the origin along its normal.
      *
      *

+ 16 - 0
gameplay/src/Ray.cpp

@@ -18,6 +18,11 @@ Ray::Ray(const Vector3& origin, const Vector3& direction)
     set(origin, direction);
     set(origin, direction);
 }
 }
 
 
+Ray::Ray(float originX, float originY, float originZ, float dirX, float dirY, float dirZ)
+{
+    set(Vector3(originX, originY, originZ), Vector3(dirX, dirY, dirZ));
+}
+
 Ray::Ray(const Ray& copy)
 Ray::Ray(const Ray& copy)
 {
 {
     set(copy);
     set(copy);
@@ -37,6 +42,11 @@ void Ray::setOrigin(const Vector3& origin)
     _origin = origin;
     _origin = origin;
 }
 }
 
 
+void Ray::setOrigin(float x, float y, float z)
+{
+    _origin.set(x, y, z);
+}
+
 const Vector3& Ray::getDirection() const
 const Vector3& Ray::getDirection() const
 {
 {
     return _direction;
     return _direction;
@@ -48,6 +58,12 @@ void Ray::setDirection(const Vector3& direction)
     normalize();
     normalize();
 }
 }
 
 
+void Ray::setDirection(float x, float y, float z)
+{
+    _direction.set(x, y, z);
+    normalize();
+}
+
 float Ray::intersects(const BoundingSphere& sphere) const
 float Ray::intersects(const BoundingSphere& sphere) const
 {
 {
     return sphere.intersects(*this);
     return sphere.intersects(*this);

+ 30 - 0
gameplay/src/Ray.h

@@ -39,6 +39,18 @@ public:
      */
      */
     Ray(const Vector3& origin, const Vector3& direction);
     Ray(const Vector3& origin, const Vector3& direction);
 
 
+    /**
+     * Constructs a new ray initialized to the specified values.
+     * 
+     * @param originX The x coordinate of the origin.
+     * @param originY The y coordinate of the origin.
+     * @param originZ The z coordinate of the origin.
+     * @param dirX The x coordinate of the direction.
+     * @param dirY The y coordinate of the direction.
+     * @param dirZ The z coordinate of the direction.
+     */
+    Ray(float originX, float originY, float originZ, float dirX, float dirY, float dirZ);
+
     /**
     /**
      * Constructs a new ray from the given ray.
      * Constructs a new ray from the given ray.
      *
      *
@@ -65,6 +77,15 @@ public:
      */
      */
     void setOrigin(const Vector3& origin);
     void setOrigin(const Vector3& origin);
 
 
+    /**
+     * Sets the ray's origin.
+     * 
+     * @param x The x coordinate of the origin.
+     * @param y The y coordinate of the origin.
+     * @param z The z coordinate of the origin.
+     */
+    void setOrigin(float x, float y, float z);
+
     /**
     /**
      * Gets the ray's direction.
      * Gets the ray's direction.
      *
      *
@@ -79,6 +100,15 @@ public:
      */
      */
     void setDirection(const Vector3& direction);
     void setDirection(const Vector3& direction);
 
 
+    /**
+     * Sets the ray's direction.
+     * 
+     * @param x The x coordinate of the direction.
+     * @param y The y coordinate of the direction.
+     * @param z The z coordinate of the direction.
+     */
+    void setDirection(float x, float y, float z);
+
     /**
     /**
      * Tests whether this ray intersects the specified bounding sphere.
      * Tests whether this ray intersects the specified bounding sphere.
      *
      *

+ 2 - 0
gameplay/src/Scene.h

@@ -28,6 +28,7 @@ public:
      * Creates a new empty scene.
      * Creates a new empty scene.
      * 
      * 
      * @return The newly created empty scene.
      * @return The newly created empty scene.
+     * @script{create}
      */
      */
     static Scene* createScene();
     static Scene* createScene();
 
 
@@ -37,6 +38,7 @@ public:
      * @param filePath The path to the '.scene' file to load from.
      * @param filePath The path to the '.scene' file to load from.
      * @return The loaded scene or <code>NULL</code> if the scene
      * @return The loaded scene or <code>NULL</code> if the scene
      *      could not be loaded from the given file.
      *      could not be loaded from the given file.
+     * @script{create}
      */
      */
     static Scene* load(const char* filePath);
     static Scene* load(const char* filePath);
 
 

+ 15 - 6
gameplay/src/ScriptController.cpp

@@ -342,7 +342,7 @@ void ScriptController::loadScript(const char* path, bool forceReload)
     {
     {
         const char* scriptContents = FileSystem::readAll(path);
         const char* scriptContents = FileSystem::readAll(path);
         if (luaL_dostring(_lua, scriptContents))
         if (luaL_dostring(_lua, scriptContents))
-            GP_ERROR("Failed to run Lua script with error: '%s'.", lua_tostring(_lua, -1));
+            GP_WARN("Failed to run Lua script with error: '%s'.", lua_tostring(_lua, -1));
 
 
         SAFE_DELETE_ARRAY(scriptContents);
         SAFE_DELETE_ARRAY(scriptContents);
 
 
@@ -516,6 +516,16 @@ void ScriptController::setString(const char* name, const char* v)
     lua_setglobal(_lua, name);
     lua_setglobal(_lua, name);
 }
 }
 
 
+void ScriptController::print(const char* str)
+{
+    printError("%s", str);
+}
+
+void ScriptController::print(const char* str1, const char* str2)
+{
+    printError("%s%s", str1, str2);
+}
+
 ScriptController::ScriptController() : _lua(NULL)
 ScriptController::ScriptController() : _lua(NULL)
 {
 {
     memset(_callbacks, 0, sizeof(std::string*) * CALLBACK_COUNT);
     memset(_callbacks, 0, sizeof(std::string*) * CALLBACK_COUNT);
@@ -530,9 +540,8 @@ ScriptController::~ScriptController()
 }
 }
 
 
 static const char* lua_print_function = 
 static const char* lua_print_function = 
-    "function print(str, ...)\n"
-    "    local arg = {...}\n"
-    "    printError(string.format(str, table.unpack(arg)))\n"
+    "function print(...)\n"
+    "    ScriptController.print(table.concat({...},\"\\t\"), \"\\n\")\n"
     "end\n";
     "end\n";
 
 
 void ScriptController::initialize()
 void ScriptController::initialize()
@@ -739,7 +748,7 @@ void ScriptController::executeFunctionHelper(int resultCount, const char* func,
 
 
     // Perform the function call.
     // Perform the function call.
     if (lua_pcall(_lua, argumentCount, resultCount, 0) != 0)
     if (lua_pcall(_lua, argumentCount, resultCount, 0) != 0)
-        GP_ERROR("Failed to call function '%s' with error '%s'.", func, lua_tostring(_lua, -1));
+        GP_WARN("Failed to call function '%s' with error '%s'.", func, lua_tostring(_lua, -1));
 }
 }
 
 
 void ScriptController::registerCallback(ScriptCallback callback, std::string function)
 void ScriptController::registerCallback(ScriptCallback callback, std::string function)
@@ -1016,4 +1025,4 @@ template<> std::string ScriptController::executeFunction<std::string>(const char
     SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
     SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
 }
 }
 
 
-}
+}

+ 18 - 1
gameplay/src/ScriptController.h

@@ -552,6 +552,23 @@ public:
      */
      */
     template<typename T>void setObjectPointer(const char* type, const char* name, T* v);
     template<typename T>void setObjectPointer(const char* type, const char* name, T* v);
 
 
+    /**
+     * Prints the string to the platform's output stream or log file.
+     * Used for overriding Lua's print function.
+     * 
+     * @param str The string to print.
+     */
+    static void print(const char* str);
+
+    /**
+     * Prints the strings to the platform's output stream or log file.
+     * Used for overriding Lua's print function.
+     * 
+     * @param str1 The first string to print.
+     * @param str2 The second string to print on the same line as str1.
+     */
+    static void print(const char* str1, const char* str2);
+
 private:
 private:
 
 
     /**
     /**
@@ -822,4 +839,4 @@ template<> std::string ScriptController::executeFunction<std::string>(const char
 
 
 #include "ScriptController.inl"
 #include "ScriptController.inl"
 
 
-#endif
+#endif