Browse Source

Fixed game template on Windows+Visual Studio.

seanpaultaylor 12 years ago
parent
commit
31fd0f4d94

+ 374 - 376
gameplay/src/Scene.h

@@ -1,376 +1,374 @@
-#ifndef SCENE_H_
-#define SCENE_H_
-
-#include "Node.h"
-#include "MeshBatch.h"
-#include "ScriptController.h"
-#include "Light.h"
-
-namespace gameplay
-{
-
-/**
- * Represents the root container for a hierarchy of nodes.
- */
-class Scene : public Ref
-{
-public:
-
-    /**
-     * Enumeration of supported scene debug flags for debug drawing.
-     */
-    enum DebugFlags
-    {
-        DEBUG_BOXES = 1,
-        DEBUG_SPHERES = 2
-    };
-
-    /**
-     * Creates a new empty scene.
-     *
-     * @param id ID of the new scene, or NULL to use an empty string for the ID (default).
-     *
-     * @return The newly created empty scene.
-     * @script{create}
-     */
-    static Scene* create(const char* id = NULL);
-
-    /**
-     * Loads a scene from the given '.scene' or '.gpb' file.
-     *
-     * @param filePath The path to the '.scene' or '.gpb' file to load from.
-     * @return The loaded scene or <code>NULL</code> if the scene
-     *      could not be loaded from the given file.
-     * @script{create}
-     */
-    static Scene* load(const char* filePath);
-
-    /**
-     * Gets a currently active scene.
-     *
-     * If id is an NULL, the first active scene is returned.
-     *
-     * @param id ID of the scene to retrieve, or NULL to retrieve the first active scene.
-     *
-     * @return The scene that matches the specified ID, or NULL if no matching scene could be found.
-     */
-    static Scene* getScene(const char* id = NULL);
-
-    /**
-     * Gets the identifier for the scene.
-     *
-     * @return The scene identifier.
-     */
-    const char* getId() const;
-
-    /**
-     * Sets the identifier for the scene.
-     *
-     * @param id The identifier to set for the scene.
-     */
-    void setId(const char* id);
-
-    /**
-     * Returns the first node in the scene that matches the given ID.
-     *
-     * @param id The ID of the node to find.
-     * @param recursive true if a recursive search should be performed, false otherwise.
-     * @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
-     *      or false if nodes that start with the given ID are returned.
-     *
-     * @return The first node found that matches the given ID.
-     */
-    Node* findNode(const char* id, bool recursive = true, bool exactMatch = true) const;
-
-    /**
-     * Returns all nodes in the scene that match the given ID.
-     *
-     * @param id The ID of the node to find.
-     * @param nodes Vector of nodes to be populated with matches.
-     * @param recursive true if a recursive search should be performed, false otherwise.
-     * @param exactMatch true if only nodes who's ID exactly matches the specified ID are returned,
-     *      or false if nodes that start with the given ID are returned.
-     *
-     * @return The number of matches found.
-     * @script{ignore}
-     */
-    unsigned int findNodes(const char* id, std::vector<Node*>& nodes, bool recursive = true, bool exactMatch = true) const;
-
-    /**
-     * Creates and adds a new node to the scene.
-     *
-     * @param id An optional node ID.
-     *
-     * @return The new node.
-     */
-    Node* addNode(const char* id = NULL);
-
-    /**
-     * Adds the specified node to the scene.
-     *
-     * @param node The node to be added to the scene.
-     */
-    void addNode(Node* node);
-
-    /**
-     * Removes the specified node from the scene.
-     *
-     * @param node The node to remove.
-     */
-    void removeNode(Node* node);
-
-    /**
-     * Removes all nodes from the scene.
-     */
-    void removeAllNodes();
-
-    /**
-     * Returns the number of nodes at the root level of the scene.
-     *
-     * @return The node count.
-     */
-    unsigned int getNodeCount() const;
-
-    /**
-     * Returns the first node in the scene.
-     *
-     * @return The first node in the scene.
-     */
-    Node* getFirstNode() const;
-
-    /**
-     * Gets the active camera for the scene.
-     *
-     * @return The active camera for the scene.
-     */
-    Camera* getActiveCamera() const;
-
-    /**
-     * Sets the active camera on the scene.
-     *
-     * @param camera The active camera to be set on the scene.
-     */
-    void setActiveCamera(Camera* camera);
-
-    /**
-     * Sets the audio listener to transform along with the active camera if set to true.
-     * If you have a 2D game that doesn't require it, then set to false.  This is on by default for the scene.
-     *
-     * @param bind true if you want to the audio listener to follow the active camera's transform.
-     */
-    void bindAudioListenerToCamera(bool bind);
-
-    /**
-     * Returns the ambient color of the scene.
-     *
-     * The default ambient light color is black (0,0,0).
-     *
-     * This value can be bound to materials using the SCENE_LIGHT_AMBIENT_COLOR auto binding.
-     *
-     * @return The scene's ambient color.
-     */
-    const Vector3& getAmbientColor() const;
-
-    /**
-     * Sets the ambient color of the scene.
-     *
-     * @param red The red channel between 0.0 and 1.0.
-     * @param green The green channel between 0.0 and 1.0.
-     * @param blue The blue channel between 0.0 and 1.0.
-     *
-     * @see getAmbientColor()
-     */
-    void setAmbientColor(float red, float green, float blue);
-
-    /**
-     * Visits each node in the scene and calls the specified method pointer.
-     *
-     * Calling this method invokes the specified method pointer for each node
-     * in the scene hierarchy.
-     *
-     * The visitMethod parameter must be a pointer to a method that has a bool
-     * return type and accepts a single parameter of type Node*.
-     *
-     * A depth-first traversal of the scene continues while the visit method
-     * returns true. Returning false will stop traversing further children for
-     * the given node and the traversal will continue at the next sibling.
-     *
-     * @param instance The pointer to an instance of the object that contains visitMethod.
-     * @param visitMethod The pointer to the class method to call for each node in the scene.
-     */
-    template <class T>
-    void visit(T* instance, bool (T::*visitMethod)(Node*));
-
-    /**
-     * Visits each node in the scene and calls the specified method pointer.
-     *
-     * Calling this method invokes the specified method pointer for each node
-     * in the scene hierarchy, passing the Node and the specified cookie value.
-     *
-     * The visitMethod parameter must be a pointer to a method that has a bool
-     * return type and accepts two parameters: a Node pointer and a cookie of a
-     * user-specified type.
-     *
-     * A depth-first traversal of the scene continues while the visit method
-     * returns true. Returning false will stop traversing further children for
-     * the given node and the traversal will continue at the next sibling.
-     *
-     * @param instance The pointer to an instance of the object that contains visitMethod.
-     * @param visitMethod The pointer to the class method to call for each node in the scene.
-     * @param cookie An optional user-defined parameter that will be passed to each invocation of visitMethod.
-     */
-    template <class T, class C>
-    void visit(T* instance, bool (T::*visitMethod)(Node*,C), C cookie);
-
-    /**
-     * Visits each node in the scene and calls the specified Lua function.
-     *
-     * Calling this method invokes the specified Lua function for each node
-     * in the scene hierarchy.
-     *
-     * The visitMethod parameter must be a string containing the name of a
-     * valid Lua function that has a boolean return type and accepts a
-     * single parameter of type Node*.
-     *
-     * A depth-first traversal of the scene continues while the visit method
-     * returns true. Returning false will stop traversing further children for
-     * the given node and the traversal will continue at the next sibling.
-     *
-     * @param visitMethod The name of the Lua function to call for each node in the scene.
-     */
-    inline void visit(const char* visitMethod);
-
-    /**
-     * Draws debugging information (bounding volumes, etc.) for the scene.
-     *
-     * @param debugFlags Bitwise combination of debug flags from the DebugFlags
-     *        enumeration, specifying which debugging information to draw.
-     */
-    void drawDebug(unsigned int debugFlags);
-
-private:
-
-    /**
-     * Constructor.
-     */
-    Scene(const char* id);
-
-    /**
-     * Hidden copy constructor.
-     */
-    Scene(const Scene& copy);
-
-    /**
-     * Destructor.
-     */
-    virtual ~Scene();
-
-    /**
-     * Hidden copy assignment operator.
-     */
-    Scene& operator=(const Scene&);
-
-    /**
-     * Visits the given node and all of its children recursively.
-     */
-    template <class T>
-    void visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*));
-
-    /**
-     * Visits the given node and all of its children recursively.
-     */
-    template <class T, class C>
-    void visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,C), C cookie);
-
-    /**
-     * Visits the given node and all of its children recursively.
-     */
-    void visitNode(Node* node, const char* visitMethod);
-
-    std::string _id;
-    Camera* _activeCamera;
-    Node* _firstNode;
-    Node* _lastNode;
-    unsigned int _nodeCount;
-    Vector3 _ambientColor;
-    Vector3 _lightColor;
-    Vector3 _lightDirection;
-    bool _bindAudioListenerToCamera;
-    MeshBatch* _debugBatch;
-};
-
-template <class T>
-void Scene::visit(T* instance, bool (T::*visitMethod)(Node*))
-{
-    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
-    {
-        visitNode(node, instance, visitMethod);
-    }
-}
-
-template <class T, class C>
-void Scene::visit(T* instance, bool (T::*visitMethod)(Node*,C), C cookie)
-{
-    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
-    {
-        visitNode(node, instance, visitMethod, cookie);
-    }
-}
-
-inline void Scene::visit(const char* visitMethod)
-{
-    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
-    {
-        visitNode(node, visitMethod);
-    }
-}
-
-template <class T>
-void Scene::visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*))
-{
-    // Invoke the visit method for this node.
-    if (!(instance->*visitMethod)(node))
-        return;
-
-    // If this node has a model with a mesh skin, visit the joint hierarchy within it
-    // since we don't add joint hierarchies directly to the scene. If joints are never
-    // visited, it's possible that nodes embedded within the joint hierarchy that contain
-    // models will never get visited (and therefore never get drawn).
-    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
-    {
-        visitNode(node->_model->_skin->_rootNode, instance, visitMethod);
-    }
-
-    // Recurse for all children.
-    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
-    {
-        visitNode(child, instance, visitMethod);
-    }
-}
-
-template <class T, class C>
-void Scene::visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,C), C cookie)
-{
-    // Invoke the visit method for this node.
-    if (!(instance->*visitMethod)(node, cookie))
-        return;
-
-    // If this node has a model with a mesh skin, visit the joint hierarchy within it
-    // since we don't add joint hierarchies directly to the scene. If joints are never
-    // visited, it's possible that nodes embedded within the joint hierarchy that contain
-    // models will never get visited (and therefore never get drawn).
-    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
-    {
-        visitNode(node->_model->_skin->_rootNode, instance, visitMethod, cookie);
-    }
-
-    // Recurse for all children.
-    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
-    {
-        visitNode(child, instance, visitMethod, cookie);
-    }
-}
-
-}
-
-#endif
+#ifndef SCENE_H_
+#define SCENE_H_
+
+#include "Node.h"
+#include "MeshBatch.h"
+#include "ScriptController.h"
+#include "Light.h"
+
+namespace gameplay
+{
+
+/**
+ * Represents the root container for a hierarchy of nodes.
+ */
+class Scene : public Ref
+{
+public:
+
+    /**
+     * Enumeration of supported scene debug flags for debug drawing.
+     */
+    enum DebugFlags
+    {
+        DEBUG_BOXES = 1,
+        DEBUG_SPHERES = 2
+    };
+
+    /**
+     * Creates a new empty scene.
+     *
+     * @param id ID of the new scene, or NULL to use an empty string for the ID (default).
+     *
+     * @return The newly created empty scene.
+     * @script{create}
+     */
+    static Scene* create(const char* id = NULL);
+
+    /**
+     * Loads a scene from the given '.scene' or '.gpb' file.
+     *
+     * @param filePath The path to the '.scene' or '.gpb' file to load from.
+     * @return The loaded scene or <code>NULL</code> if the scene
+     *      could not be loaded from the given file.
+     * @script{create}
+     */
+    static Scene* load(const char* filePath);
+
+    /**
+     * Gets a currently active scene.
+     *
+     * If id is an NULL, the first active scene is returned.
+     *
+     * @param id ID of the scene to retrieve, or NULL to retrieve the first active scene.
+     *
+     * @return The scene that matches the specified ID, or NULL if no matching scene could be found.
+     */
+    static Scene* getScene(const char* id = NULL);
+
+    /**
+     * Gets the identifier for the scene.
+     *
+     * @return The scene identifier.
+     */
+    const char* getId() const;
+
+    /**
+     * Sets the identifier for the scene.
+     *
+     * @param id The identifier to set for the scene.
+     */
+    void setId(const char* id);
+
+    /**
+     * Returns the first node in the scene that matches the given ID.
+     *
+     * @param id The ID of the node to find.
+     * @param recursive true if a recursive search should be performed, false otherwise.
+     * @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
+     *      or false if nodes that start with the given ID are returned.
+     *
+     * @return The first node found that matches the given ID.
+     */
+    Node* findNode(const char* id, bool recursive = true, bool exactMatch = true) const;
+
+    /**
+     * Returns all nodes in the scene that match the given ID.
+     *
+     * @param id The ID of the node to find.
+     * @param nodes Vector of nodes to be populated with matches.
+     * @param recursive true if a recursive search should be performed, false otherwise.
+     * @param exactMatch true if only nodes who's ID exactly matches the specified ID are returned,
+     *      or false if nodes that start with the given ID are returned.
+     *
+     * @return The number of matches found.
+     * @script{ignore}
+     */
+    unsigned int findNodes(const char* id, std::vector<Node*>& nodes, bool recursive = true, bool exactMatch = true) const;
+
+    /**
+     * Creates and adds a new node to the scene.
+     *
+     * @param id An optional node ID.
+     *
+     * @return The new node.
+     */
+    Node* addNode(const char* id = NULL);
+
+    /**
+     * Adds the specified node to the scene.
+     *
+     * @param node The node to be added to the scene.
+     */
+    void addNode(Node* node);
+
+    /**
+     * Removes the specified node from the scene.
+     *
+     * @param node The node to remove.
+     */
+    void removeNode(Node* node);
+
+    /**
+     * Removes all nodes from the scene.
+     */
+    void removeAllNodes();
+
+    /**
+     * Returns the number of nodes at the root level of the scene.
+     *
+     * @return The node count.
+     */
+    unsigned int getNodeCount() const;
+
+    /**
+     * Returns the first node in the scene.
+     *
+     * @return The first node in the scene.
+     */
+    Node* getFirstNode() const;
+
+    /**
+     * Gets the active camera for the scene.
+     *
+     * @return The active camera for the scene.
+     */
+    Camera* getActiveCamera() const;
+
+    /**
+     * Sets the active camera on the scene.
+     *
+     * @param camera The active camera to be set on the scene.
+     */
+    void setActiveCamera(Camera* camera);
+
+    /**
+     * Sets the audio listener to transform along with the active camera if set to true.
+     * If you have a 2D game that doesn't require it, then set to false.  This is on by default for the scene.
+     *
+     * @param bind true if you want to the audio listener to follow the active camera's transform.
+     */
+    void bindAudioListenerToCamera(bool bind);
+
+    /**
+     * Returns the ambient color of the scene.
+     *
+     * The default ambient light color is black (0,0,0).
+     *
+     * This value can be bound to materials using the SCENE_LIGHT_AMBIENT_COLOR auto binding.
+     *
+     * @return The scene's ambient color.
+     */
+    const Vector3& getAmbientColor() const;
+
+    /**
+     * Sets the ambient color of the scene.
+     *
+     * @param red The red channel between 0.0 and 1.0.
+     * @param green The green channel between 0.0 and 1.0.
+     * @param blue The blue channel between 0.0 and 1.0.
+     *
+     * @see getAmbientColor()
+     */
+    void setAmbientColor(float red, float green, float blue);
+
+    /**
+     * Visits each node in the scene and calls the specified method pointer.
+     *
+     * Calling this method invokes the specified method pointer for each node
+     * in the scene hierarchy.
+     *
+     * The visitMethod parameter must be a pointer to a method that has a bool
+     * return type and accepts a single parameter of type Node*.
+     *
+     * A depth-first traversal of the scene continues while the visit method
+     * returns true. Returning false will stop traversing further children for
+     * the given node and the traversal will continue at the next sibling.
+     *
+     * @param instance The pointer to an instance of the object that contains visitMethod.
+     * @param visitMethod The pointer to the class method to call for each node in the scene.
+     */
+    template <class T>
+    void visit(T* instance, bool (T::*visitMethod)(Node*));
+
+    /**
+     * Visits each node in the scene and calls the specified method pointer.
+     *
+     * Calling this method invokes the specified method pointer for each node
+     * in the scene hierarchy, passing the Node and the specified cookie value.
+     *
+     * The visitMethod parameter must be a pointer to a method that has a bool
+     * return type and accepts two parameters: a Node pointer and a cookie of a
+     * user-specified type.
+     *
+     * A depth-first traversal of the scene continues while the visit method
+     * returns true. Returning false will stop traversing further children for
+     * the given node and the traversal will continue at the next sibling.
+     *
+     * @param instance The pointer to an instance of the object that contains visitMethod.
+     * @param visitMethod The pointer to the class method to call for each node in the scene.
+     * @param cookie An optional user-defined parameter that will be passed to each invocation of visitMethod.
+     */
+    template <class T, class C>
+    void visit(T* instance, bool (T::*visitMethod)(Node*,C), C cookie);
+
+    /**
+     * Visits each node in the scene and calls the specified Lua function.
+     *
+     * Calling this method invokes the specified Lua function for each node
+     * in the scene hierarchy.
+     *
+     * The visitMethod parameter must be a string containing the name of a
+     * valid Lua function that has a boolean return type and accepts a
+     * single parameter of type Node*.
+     *
+     * A depth-first traversal of the scene continues while the visit method
+     * returns true. Returning false will stop traversing further children for
+     * the given node and the traversal will continue at the next sibling.
+     *
+     * @param visitMethod The name of the Lua function to call for each node in the scene.
+     */
+    inline void visit(const char* visitMethod);
+
+    /**
+     * Draws debugging information (bounding volumes, etc.) for the scene.
+     *
+     * @param debugFlags Bitwise combination of debug flags from the DebugFlags
+     *        enumeration, specifying which debugging information to draw.
+     */
+    void drawDebug(unsigned int debugFlags);
+
+private:
+
+    /**
+     * Constructor.
+     */
+    Scene(const char* id);
+
+    /**
+     * Hidden copy constructor.
+     */
+    Scene(const Scene& copy);
+
+    /**
+     * Destructor.
+     */
+    virtual ~Scene();
+
+    /**
+     * Hidden copy assignment operator.
+     */
+    Scene& operator=(const Scene&);
+
+    /**
+     * Visits the given node and all of its children recursively.
+     */
+    template <class T>
+    void visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*));
+
+    /**
+     * Visits the given node and all of its children recursively.
+     */
+    template <class T, class C>
+    void visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,C), C cookie);
+
+    /**
+     * Visits the given node and all of its children recursively.
+     */
+    void visitNode(Node* node, const char* visitMethod);
+
+    std::string _id;
+    Camera* _activeCamera;
+    Node* _firstNode;
+    Node* _lastNode;
+    unsigned int _nodeCount;
+    Vector3 _ambientColor;
+    bool _bindAudioListenerToCamera;
+    MeshBatch* _debugBatch;
+};
+
+template <class T>
+void Scene::visit(T* instance, bool (T::*visitMethod)(Node*))
+{
+    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
+    {
+        visitNode(node, instance, visitMethod);
+    }
+}
+
+template <class T, class C>
+void Scene::visit(T* instance, bool (T::*visitMethod)(Node*,C), C cookie)
+{
+    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
+    {
+        visitNode(node, instance, visitMethod, cookie);
+    }
+}
+
+inline void Scene::visit(const char* visitMethod)
+{
+    for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
+    {
+        visitNode(node, visitMethod);
+    }
+}
+
+template <class T>
+void Scene::visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*))
+{
+    // Invoke the visit method for this node.
+    if (!(instance->*visitMethod)(node))
+        return;
+
+    // If this node has a model with a mesh skin, visit the joint hierarchy within it
+    // since we don't add joint hierarchies directly to the scene. If joints are never
+    // visited, it's possible that nodes embedded within the joint hierarchy that contain
+    // models will never get visited (and therefore never get drawn).
+    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
+    {
+        visitNode(node->_model->_skin->_rootNode, instance, visitMethod);
+    }
+
+    // Recurse for all children.
+    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
+    {
+        visitNode(child, instance, visitMethod);
+    }
+}
+
+template <class T, class C>
+void Scene::visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,C), C cookie)
+{
+    // Invoke the visit method for this node.
+    if (!(instance->*visitMethod)(node, cookie))
+        return;
+
+    // If this node has a model with a mesh skin, visit the joint hierarchy within it
+    // since we don't add joint hierarchies directly to the scene. If joints are never
+    // visited, it's possible that nodes embedded within the joint hierarchy that contain
+    // models will never get visited (and therefore never get drawn).
+    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
+    {
+        visitNode(node->_model->_skin->_rootNode, instance, visitMethod, cookie);
+    }
+
+    // Recurse for all children.
+    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
+    {
+        visitNode(child, instance, visitMethod, cookie);
+    }
+}
+
+}
+
+#endif

+ 312 - 312
newproject.bat

@@ -1,314 +1,314 @@
-@echo off
-
-REM ********************************************************************
-REM
-REM generate-project.bat
-REM
-REM This windows batch script generates a set of gameplay project files.
-REM The new project will be based of the template project and 
-REM it will be generated with the name and location that is specified
-REM as input parameters.
-REM
-REM IMPORTANT: This script must be run from the root of the gameplay
-REM source tree.
-REM
-REM ********************************************************************
-
-echo.
-echo 1. Enter a name for the new project.
-echo.
-echo    This name will be given to the project 
-echo    executable and a folder with this name
-echo    will be created to store all project files.
-echo.
-set /p projName=Project name: 
-if "%projName%" == "" (
-    echo.
-    echo ERROR: No project name specified.
-    echo.
-    pause
-    goto done
-)
-echo.
-
-echo.
-echo 2. Enter a game title.
-echo.
-echo    On some platforms, this title is used to
-echo    identify the game during installation and
-echo    on shortcuts/icons.
-echo.
-set /p title=Title: 
-if "%title%" == "" (
-    echo.
-    echo ERROR: No game title specified.
-    echo.
-    pause
-    goto done
-)
-echo.
-
-echo.
-echo 3. Enter a short game description.
-echo.
-set /p desc=Description: 
-if "%desc%" == "" (
-    set desc=%title%
-)
-echo.
-
-echo.
-echo 4. Enter a unique identifier for your project.
-echo.
-echo    This should be a human readable package name,
-echo    containing at least two words separated by a
-echo    period (eg. com.surname.gamename).
-echo.
-set /p uuid=Unique ID: 
-if "%uuid%" == "" (
-    echo.
-    echo ERROR: No uuid specified.
-    echo.
-    pause
-    goto done
-)
-echo.
-
-echo.
-echo 5. Enter author name.
-echo.
-echo    On BlackBerry targets, this is used for
-echo    signing and must match the developer name
-echo    of your development certificate.
-echo.
-set /p author=Author: 
-if "%author%" == "" (
-    echo.
-    echo ERROR: No author specified.
-    echo.
-    pause
-    goto done
-)
-echo.
-
-echo.
-echo 6. Enter your game's main class name.
-echo.
-echo    Your initial game header and source file
-echo    will be given this name and a class with 
-echo    this name will be created in these files.
-echo.
-set /p className=Class name: 
-if "%className%" == "" (
-    echo.
-    echo ERROR: No class name specified.
-    echo.
-    pause
-    goto done
-)
-echo.
-
-echo.
-echo 7. Enter the project path.
-echo.
-echo    This can be a relative path, absolute path,
-echo    or empty for the current folder. Note that
-echo    a project folder named %projName% will also
-echo    be created inside this folder.
-echo.
-set /p location=Path: 
-if "%location%" == "" (
-    set projPath=%projName%
-) else (
-    set projPath=%location%\%projName%
-)
-echo.
-
-call:replacevar projPath "/" "\"
-
-REM Does this path already exist?
-if exist "%projPath%" (
-    echo.
-    echo ERROR: Path '%projPath%' already exists, aborting.
-    echo.
-    pause
-    goto done
-
-REM Disabling following code which prompts to overwrite existing path,
-REM since this could be potentially damaging if the user specifies
-REM an important path and then types 'y', without thinking.
-REM
-REM    set /p owd=Directory '%projPath%' exists, overwrite [Y,N]? 
-REM    if not "!owd!" == "Y" (
-REM        if not "!owd!" == "y" (
-REM            echo Aborting.
-REM            pause
-REM            goto done
-REM        )
-REM    )
-REM    rmdir /S /Q %projPath%
-)
-
-REM Generate relative path from project folder to GamePlay folder
-set gpPath=%cd%
-call:makerelative gpPath "%projPath%\"
-call:replacevar gpPath "\" "/"
-
-mkdir "%projPath%"
-mkdir "%projPath%\src"
-mkdir "%projPath%\res"
-
-REM Copy Microsoft Visual Studio project files
-copy template\template.vcxproj "%projPath%\%projName%.vcxproj"
-call:replace "%projPath%\%projName%.vcxproj" TEMPLATE_PROJECT "%projName%"
-call:replace "%projPath%\%projName%.vcxproj" TemplateGame "%className%"
-call:replace "%projPath%\%projName%.vcxproj" GAMEPLAY_PATH "%gpPath%"
-
-copy template\template.vcxproj.filters "%projPath%\%projName%.vcxproj.filters"
-call:replace "%projPath%\%projName%.vcxproj.filters" TemplateGame "%className%"
-
-copy template\template.vcxproj.user "%projPath%\%projName%.vcxproj.user"
-call:replace "%projPath%\%projName%.vcxproj.user" GAMEPLAY_PATH "%gpPath%"
-
-REM Copy Apple XCode project files
+@echo off
+
+REM ********************************************************************
+REM
+REM generate-project.bat
+REM
+REM This windows batch script generates a set of gameplay project files.
+REM The new project will be based of the template project and 
+REM it will be generated with the name and location that is specified
+REM as input parameters.
+REM
+REM IMPORTANT: This script must be run from the root of the gameplay
+REM source tree.
+REM
+REM ********************************************************************
+
+echo.
+echo 1. Enter a name for the new project.
+echo.
+echo    This name will be given to the project 
+echo    executable and a folder with this name
+echo    will be created to store all project files.
+echo.
+set /p projName=Project name: 
+if "%projName%" == "" (
+    echo.
+    echo ERROR: No project name specified.
+    echo.
+    pause
+    goto done
+)
+echo.
+
+echo.
+echo 2. Enter a game title.
+echo.
+echo    On some platforms, this title is used to
+echo    identify the game during installation and
+echo    on shortcuts/icons.
+echo.
+set /p title=Title: 
+if "%title%" == "" (
+    echo.
+    echo ERROR: No game title specified.
+    echo.
+    pause
+    goto done
+)
+echo.
+
+echo.
+echo 3. Enter a short game description.
+echo.
+set /p desc=Description: 
+if "%desc%" == "" (
+    set desc=%title%
+)
+echo.
+
+echo.
+echo 4. Enter a unique identifier for your project.
+echo.
+echo    This should be a human readable package name,
+echo    containing at least two words separated by a
+echo    period (eg. com.surname.gamename).
+echo.
+set /p uuid=Unique ID: 
+if "%uuid%" == "" (
+    echo.
+    echo ERROR: No uuid specified.
+    echo.
+    pause
+    goto done
+)
+echo.
+
+echo.
+echo 5. Enter author name.
+echo.
+echo    On BlackBerry targets, this is used for
+echo    signing and must match the developer name
+echo    of your development certificate.
+echo.
+set /p author=Author: 
+if "%author%" == "" (
+    echo.
+    echo ERROR: No author specified.
+    echo.
+    pause
+    goto done
+)
+echo.
+
+echo.
+echo 6. Enter your game's main class name.
+echo.
+echo    Your initial game header and source file
+echo    will be given this name and a class with 
+echo    this name will be created in these files.
+echo.
+set /p className=Class name: 
+if "%className%" == "" (
+    echo.
+    echo ERROR: No class name specified.
+    echo.
+    pause
+    goto done
+)
+echo.
+
+echo.
+echo 7. Enter the project path.
+echo.
+echo    This can be a relative path, absolute path,
+echo    or empty for the current folder. Note that
+echo    a project folder named %projName% will also
+echo    be created inside this folder.
+echo.
+set /p location=Path: 
+if "%location%" == "" (
+    set projPath=%projName%
+) else (
+    set projPath=%location%\%projName%
+)
+echo.
+
+call:replacevar projPath "/" "\"
+
+REM Does this path already exist?
+if exist "%projPath%" (
+    echo.
+    echo ERROR: Path '%projPath%' already exists, aborting.
+    echo.
+    pause
+    goto done
+
+REM Disabling following code which prompts to overwrite existing path,
+REM since this could be potentially damaging if the user specifies
+REM an important path and then types 'y', without thinking.
+REM
+REM    set /p owd=Directory '%projPath%' exists, overwrite [Y,N]? 
+REM    if not "!owd!" == "Y" (
+REM        if not "!owd!" == "y" (
+REM            echo Aborting.
+REM            pause
+REM            goto done
+REM        )
+REM    )
+REM    rmdir /S /Q %projPath%
+)
+
+REM Generate relative path from project folder to GamePlay folder
+set gpPath=%cd%
+call:makerelative gpPath "%projPath%\"
+call:replacevar gpPath "\" "\"
+
+mkdir "%projPath%"
+mkdir "%projPath%\src"
+mkdir "%projPath%\res"
+
+REM Copy Microsoft Visual Studio project files
+copy template\template.vcxproj "%projPath%\%projName%.vcxproj"
+call:replace "%projPath%\%projName%.vcxproj" TEMPLATE_PROJECT "%projName%"
+call:replace "%projPath%\%projName%.vcxproj" TemplateGame "%className%"
+call:replace "%projPath%\%projName%.vcxproj" GAMEPLAY_PATH "%gpPath%"
+
+copy template\template.vcxproj.filters "%projPath%\%projName%.vcxproj.filters"
+call:replace "%projPath%\%projName%.vcxproj.filters" TemplateGame "%className%"
+
+copy template\template.vcxproj.user "%projPath%\%projName%.vcxproj.user"
+call:replace "%projPath%\%projName%.vcxproj.user" GAMEPLAY_PATH "%gpPath%"
+
+REM Copy Apple XCode project files
 mkdir "%projPath%\%projName%.xcodeproj"
-copy template\template.xcodeproj\project.pbxproj "%projPath%\%projName%.xcodeproj\project.pbxproj"
-call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" GAMEPLAY_PATH "%gpPath%"
-call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" TemplateGame "%className%"
-call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" TEMPLATE_PROJECT "%projName%"
-
-copy template\TEMPLATE_PROJECT-macosx.plist "%projPath%\%projName%-macosx.plist"
-call:replace "%projPath%\%projName%-macosx.plist" TEMPLATE_UUID "%uuid%"
-call:replace "%projPath%\%projName%-macosx.plist" TEMPLATE_AUTHOR "%author%"
-
+copy template\template.xcodeproj\project.pbxproj "%projPath%\%projName%.xcodeproj\project.pbxproj"
+call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" GAMEPLAY_PATH "%gpPath%"
+call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" TemplateGame "%className%"
+call:replace "%projPath%\%projName%.xcodeproj\project.pbxproj" TEMPLATE_PROJECT "%projName%"
+
+copy template\TEMPLATE_PROJECT-macosx.plist "%projPath%\%projName%-macosx.plist"
+call:replace "%projPath%\%projName%-macosx.plist" TEMPLATE_UUID "%uuid%"
+call:replace "%projPath%\%projName%-macosx.plist" TEMPLATE_AUTHOR "%author%"
+
 copy template\TEMPLATE_PROJECT-ios.plist "%projPath%\%projName%-ios.plist"
-copy template\[email protected] "%projPath%\[email protected]"
-call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_TITLE "%title%"
-call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_UUID "%uuid%"
-call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_AUTHOR "%author%"
-
-REM Copy BlackBerry NDK project files
-copy template\template.cproject "%projPath%\.cproject"
-call:replace "%projPath%\.cproject" TEMPLATE_PROJECT "%projName%"
-call:replace "%projPath%\.cproject" TEMPLATE_UUID "%uuid%"
-call:replace "%projPath%\.cproject" GAMEPLAY_PATH "%gpPath%"
-
-copy template\template.project "%projPath%\.project"
-call:replace "%projPath%\.project" TEMPLATE_PROJECT "%projName%"
-
-copy template\template.bar-descriptor.xml "%projPath%\bar-descriptor.xml"
-call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_PROJECT "%projName%"
-call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_TITLE "%title%"
-call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_UUID "%uuid%"
-call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_AUTHOR "%author%"
-call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_DESCRIPTION "%desc%"
-
-REM Copy Android NDK project files
-mkdir "%projPath%\android"
-
-copy template\android\template.AndroidManifest.xml "%projPath%\android\AndroidManifest.xml"
-call:replace "%projPath%\android\AndroidManifest.xml" TEMPLATE_PROJECT "%projName%"
-call:replace "%projPath%\android\AndroidManifest.xml" TEMPLATE_UUID "%uuid%"
-
-copy template\android\template.build.xml "%projPath%\android\build.xml"
-call:replace "%projPath%\android\build.xml" TEMPLATE_PROJECT "%projName%"
-
-mkdir "%projPath%\android\jni"
-
-copy template\android\jni\Application.mk "%projPath%\android\jni\Application.mk"
-
-copy template\android\jni\template.Android.mk "%projPath%\android\jni\Android.mk"
-call:replace "%projPath%\android\jni\Android.mk" TemplateGame "%className%"
-call:replace "%projPath%\android\jni\Android.mk" TEMPLATE_PROJECT "%projName%"
-call:replace "%projPath%\android\jni\Android.mk" GAMEPLAY_PATH "%gpPath%"
-
-mkdir "%projPath%\android\res\drawable"
-
-copy template\icon.png "%projPath%\android\res\drawable\icon.png"
-
-mkdir "%projPath%\android\res\values"
-
-copy template\android\res\values\template.strings.xml "%projPath%\android\res\values\strings.xml"
-call:replace "%projPath%\android\res\values\strings.xml" TEMPLATE_TITLE "%title%"
-
-mkdir "%projPath%\build"
-copy "template\template-CMakeLists.txt" "%projPath%\CMakeLists.txt"
-call:replace "%projPath%\CMakeLists.txt" TEMPLATE_PROJECT %projName%
-call:replace "%projPath%\CMakeLists.txt" TemplateGame %className%
-call:replace "%projPath%\CMakeLists.txt" GAMEPLAY_PATH %gpPath%
-
-REM Copy source files
-copy template\src\TemplateGame.h "%projPath%\src\%className%.h"
-copy template\src\TemplateGame.cpp "%projPath%\src\%className%.cpp"
-call:replace "%projPath%\src\%className%.h" TemplateGame "%className%"
-call:replace "%projPath%\src\%className%.cpp" TemplateGame "%className%"
-
-REM Copy resource files
-copy template\res\* "%projPath%\res\"
-
-REM Copy icon
-copy template\icon.png "%projPath%\icon.png"
-
-REM Copy config
-copy template\game.config "%projPath%\game.config"
-call:replace "%projPath%\game.config" TEMPLATE_TITLE "%title%"
-
-REM Open new project folder
-start "" "%projPath%"
-
-goto done
-
-:replace
-set rtemp=%~1.rtemp
-if exist "%rtemp%" del /Q "%rtemp%"
-for /f "tokens=1* eol=€ delims=€]" %%j in ('type "%~1" ^| find /V /N ""') do (
-    set line=%%k
-    setlocal EnableDelayedExpansion
-    if "!line!" == "" (
-        echo.>>"%rtemp%"
-    ) else (
-        set linput=!line!
-        set loutput=!linput:%~2=%~3!
-        echo.!loutput!>>"%rtemp%"
-    )
-    endlocal
-)
-copy /Y "%rtemp%" "%~1"
-del /Q "%rtemp%"
-exit /b
-goto done
-
-:replacevar
-setlocal EnableDelayedExpansion
-echo !%~1!>.replacevar.tmp
-endlocal
-call:replace .replacevar.tmp "%~2" "%~3"
-set /p replaced=<.replacevar.tmp
-set %~1=%replaced%
-del /Q .replacevar.tmp
-exit /b
-goto done
-
-:makerelative
-setlocal EnableDelayedExpansion
-set src=%~1
-if defined %1 set src=!%~1!
-set bas=%~2
-if not defined bas set bas=%cd%
-for /f "tokens=*" %%a in ("%src%") do set src=%%~fa
-for /f "tokens=*" %%a in ("%bas%") do set bas=%%~fa
-set mat=&rem variable to store matching part of the name
-set upp=&rem variable to reference a parent
-for /f "tokens=*" %%a in ('echo.%bas:\=^&echo.%') do (
-    set sub=!sub!%%a\
-    call set tmp=%%src:!sub!=%%
-    if "!tmp!" NEQ "!src!" (set mat=!sub!)ELSE (set upp=!upp!..\)
-)
-set src=%upp%!src:%mat%=!
-( endlocal & REM RETURN VALUES
-    IF defined %1 (SET %~1=%src%) ELSE ECHO.%src%
-)
-exit /b
-goto done
-
-:done
+copy template\[email protected] "%projPath%\[email protected]"
+call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_TITLE "%title%"
+call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_UUID "%uuid%"
+call:replace "%projPath%\%projName%-ios.plist" TEMPLATE_AUTHOR "%author%"
+
+REM Copy BlackBerry NDK project files
+copy template\template.cproject "%projPath%\.cproject"
+call:replace "%projPath%\.cproject" TEMPLATE_PROJECT "%projName%"
+call:replace "%projPath%\.cproject" TEMPLATE_UUID "%uuid%"
+call:replace "%projPath%\.cproject" GAMEPLAY_PATH "%gpPath%"
+
+copy template\template.project "%projPath%\.project"
+call:replace "%projPath%\.project" TEMPLATE_PROJECT "%projName%"
+
+copy template\template.bar-descriptor.xml "%projPath%\bar-descriptor.xml"
+call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_PROJECT "%projName%"
+call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_TITLE "%title%"
+call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_UUID "%uuid%"
+call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_AUTHOR "%author%"
+call:replace "%projPath%\bar-descriptor.xml" TEMPLATE_DESCRIPTION "%desc%"
+
+REM Copy Android NDK project files
+mkdir "%projPath%\android"
+
+copy template\android\template.AndroidManifest.xml "%projPath%\android\AndroidManifest.xml"
+call:replace "%projPath%\android\AndroidManifest.xml" TEMPLATE_PROJECT "%projName%"
+call:replace "%projPath%\android\AndroidManifest.xml" TEMPLATE_UUID "%uuid%"
+
+copy template\android\template.build.xml "%projPath%\android\build.xml"
+call:replace "%projPath%\android\build.xml" TEMPLATE_PROJECT "%projName%"
+
+mkdir "%projPath%\android\jni"
+
+copy template\android\jni\Application.mk "%projPath%\android\jni\Application.mk"
+
+copy template\android\jni\template.Android.mk "%projPath%\android\jni\Android.mk"
+call:replace "%projPath%\android\jni\Android.mk" TemplateGame "%className%"
+call:replace "%projPath%\android\jni\Android.mk" TEMPLATE_PROJECT "%projName%"
+call:replace "%projPath%\android\jni\Android.mk" GAMEPLAY_PATH "%gpPath%"
+
+mkdir "%projPath%\android\res\drawable"
+
+copy template\icon.png "%projPath%\android\res\drawable\icon.png"
+
+mkdir "%projPath%\android\res\values"
+
+copy template\android\res\values\template.strings.xml "%projPath%\android\res\values\strings.xml"
+call:replace "%projPath%\android\res\values\strings.xml" TEMPLATE_TITLE "%title%"
+
+mkdir "%projPath%\build"
+copy "template\template-CMakeLists.txt" "%projPath%\CMakeLists.txt"
+call:replace "%projPath%\CMakeLists.txt" TEMPLATE_PROJECT %projName%
+call:replace "%projPath%\CMakeLists.txt" TemplateGame %className%
+call:replace "%projPath%\CMakeLists.txt" GAMEPLAY_PATH %gpPath%
+
+REM Copy source files
+copy template\src\TemplateGame.h "%projPath%\src\%className%.h"
+copy template\src\TemplateGame.cpp "%projPath%\src\%className%.cpp"
+call:replace "%projPath%\src\%className%.h" TemplateGame "%className%"
+call:replace "%projPath%\src\%className%.cpp" TemplateGame "%className%"
+
+REM Copy resource files
+copy template\res\* "%projPath%\res\"
+
+REM Copy icon
+copy template\icon.png "%projPath%\icon.png"
+
+REM Copy config
+copy template\game.config "%projPath%\game.config"
+call:replace "%projPath%\game.config" TEMPLATE_TITLE "%title%"
+
+REM Open new project folder
+start "" "%projPath%"
+
+goto done
+
+:replace
+set rtemp=%~1.rtemp
+if exist "%rtemp%" del /Q "%rtemp%"
+for /f "tokens=1* eol=€ delims=€]" %%j in ('type "%~1" ^| find /V /N ""') do (
+    set line=%%k
+    setlocal EnableDelayedExpansion
+    if "!line!" == "" (
+        echo.>>"%rtemp%"
+    ) else (
+        set linput=!line!
+        set loutput=!linput:%~2=%~3!
+        echo.!loutput!>>"%rtemp%"
+    )
+    endlocal
+)
+copy /Y "%rtemp%" "%~1"
+del /Q "%rtemp%"
+exit /b
+goto done
+
+:replacevar
+setlocal EnableDelayedExpansion
+echo !%~1!>.replacevar.tmp
+endlocal
+call:replace .replacevar.tmp "%~2" "%~3"
+set /p replaced=<.replacevar.tmp
+set %~1=%replaced%
+del /Q .replacevar.tmp
+exit /b
+goto done
+
+:makerelative
+setlocal EnableDelayedExpansion
+set src=%~1
+if defined %1 set src=!%~1!
+set bas=%~2
+if not defined bas set bas=%cd%
+for /f "tokens=*" %%a in ("%src%") do set src=%%~fa
+for /f "tokens=*" %%a in ("%bas%") do set bas=%%~fa
+set mat=&rem variable to store matching part of the name
+set upp=&rem variable to reference a parent
+for /f "tokens=*" %%a in ('echo.%bas:\=^&echo.%') do (
+    set sub=!sub!%%a\
+    call set tmp=%%src:!sub!=%%
+    if "!tmp!" NEQ "!src!" (set mat=!sub!)ELSE (set upp=!upp!..\)
+)
+set src=%upp%!src:%mat%=!
+( endlocal & REM RETURN VALUES
+    IF defined %1 (SET %~1=%src%) ELSE ECHO.%src%
+)
+exit /b
+goto done
+
+:done

+ 0 - 23
template/res/box.material

@@ -1,23 +0,0 @@
-material box
-{
-    technique
-    {
-        pass
-        {
-            // shaders
-            vertexShader = res/colored.vert
-            fragmentShader = res/colored.frag
-            
-            // uniforms
-            u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX
-            u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
-
-            // render state
-            renderState
-            {
-                cullFace = true
-                depthTest = true
-            }
-        }
-    }
-}

+ 0 - 35
template/res/colored.frag

@@ -1,35 +0,0 @@
-#ifdef OPENGL_ES
-precision highp float;
-#endif
-
-// Uniforms
-uniform vec4 u_diffuseColor;                    // Diffuse color
-uniform vec3 u_ambientColor;                    // Ambient color
-uniform vec3 u_lightColor;                      // Light color
-uniform vec3 u_lightDirection;       	        // Light direction
-
-// Inputs
-varying vec3 v_normalVector;                    // Normal vector in view space.
-
-void main()
-{
-	// Base color
-    vec4 baseColor = u_diffuseColor;
-
-    // Normalize the vectors.
-    vec3 lightDirection = normalize(u_lightDirection);
-    vec3 normalVector = normalize(v_normalVector);
-
-    // Ambient
-    vec3 ambientColor = baseColor.rgb * u_ambientColor;
-
-    // Diffuse
-	float attenuation = 1.0;
-    float ddot = dot(normalVector, -lightDirection);
-    float intensity =  max(0.0, attenuation * ddot);
-    vec3 diffuseColor = u_lightColor * baseColor.rgb * intensity;
-
-    // Light the pixel
-    gl_FragColor.a = baseColor.a;
-    gl_FragColor.rgb = ambientColor + diffuseColor;
-}

+ 0 - 24
template/res/colored.vert

@@ -1,24 +0,0 @@
-// Inputs
-attribute vec4 a_position;                          // Vertex Position (x, y, z, w)
-attribute vec3 a_normal;                            // Vertex Normal (x, y, z)
-
-// Uniforms
-uniform mat4 u_worldViewProjectionMatrix;           // Matrix to transform a position to clip space.
-uniform mat4 u_inverseTransposeWorldViewMatrix;         // Matrix to transform a normal to view space.
-
-// Outputs
-varying vec3 v_normalVector;                        // Normal vector in view space.
-
-void main()
-{
-	// Vertex attributes
-    vec4 position = a_position;
-    vec3 normal = a_normal;
-        
-    // Transform position to clip space.
-    gl_Position = u_worldViewProjectionMatrix * position;
-
-    // Transform normal to view space.
-    mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
-    v_normalVector = inverseTransposeWorldViewMatrix * normal;
-}

+ 0 - 0
template/res/box.fbx → template/res/demo.fbx


BIN
template/res/box.gpb → template/res/demo.gpb


+ 38 - 0
template/res/demo.material

@@ -0,0 +1,38 @@
+material colored
+{
+    u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX
+    
+    renderState
+    {
+        cullFace = true
+        depthTest = true
+    }
+    
+    technique
+    {
+        pass 
+        {
+            vertexShader = res/shaders/colored.vert
+            fragmentShader = res/shaders/colored.frag
+        }
+    }
+}
+
+material lambert2 : colored
+{
+    u_diffuseColor = 0.4, 0.4, 0.4, 1
+
+    u_ambientColor = SCENE_AMBIENT_COLOR
+    u_directionalLightColor[0] = 1, 1, 1
+    u_directionalLightDirection[0] = 0, -1, 0
+    u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
+
+    technique
+    {
+        pass 
+        {
+            defines = DIRECTIONAL_LIGHT_COUNT 1
+        }
+    }
+}
+

+ 16 - 0
template/res/demo.scene

@@ -0,0 +1,16 @@
+scene
+{
+    path = res/demo.gpb
+
+    ambientColor = 1, 1, 1
+
+    node box
+    {
+        material = res/demo.material#lambert2
+    }
+
+    physics
+    {
+        gravity = 0.0, -9.8, 0.0
+    }
+}

+ 81 - 87
template/src/TemplateGame.cpp

@@ -1,87 +1,81 @@
-#include "TemplateGame.h"
-
-// Declare our game instance
-TemplateGame game;
-
-TemplateGame::TemplateGame()
-    : _scene(NULL)
-{
-}
-
-void TemplateGame::initialize()
-{
-    // Load game scene from file
-    _scene = Scene::load("res/box.gpb");
-
-    // Set the aspect ratio for the scene's camera to match the current resolution
-    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
-    
-    // Get light node
-    Node* lightNode = _scene->findNode("directionalLight");
-    Light* light = lightNode->getLight();
-
-    // Initialize box model
-    Node* boxNode = _scene->findNode("box");
-    Model* boxModel = boxNode->getModel();
-    Material* boxMaterial = boxModel->setMaterial("res/box.material");
-    boxMaterial->getParameter("u_ambientColor")->setValue(_scene->getAmbientColor());
-    boxMaterial->getParameter("u_lightColor")->setValue(light->getColor());
-    boxMaterial->getParameter("u_lightDirection")->setValue(lightNode->getForwardVectorView());
-}
-
-void TemplateGame::finalize()
-{
-    SAFE_RELEASE(_scene);
-}
-
-void TemplateGame::update(float elapsedTime)
-{
-    // Rotate model
-    _scene->findNode("box")->rotateY(MATH_DEG_TO_RAD((float)elapsedTime / 1000.0f * 180.0f));
-}
-
-void TemplateGame::render(float elapsedTime)
-{
-    // Clear the color and depth buffers
-    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
-
-    // Visit all the nodes in the scene for drawing
-    _scene->visit(this, &TemplateGame::drawScene);
-}
-
-bool TemplateGame::drawScene(Node* node)
-{
-    // If the node visited contains a model, draw it
-    Model* model = node->getModel(); 
-    if (model)
-    {
-        model->draw();
-    }
-    return true;
-}
-
-void TemplateGame::keyEvent(Keyboard::KeyEvent evt, int key)
-{
-    if (evt == Keyboard::KEY_PRESS)
-    {
-        switch (key)
-        {
-        case Keyboard::KEY_ESCAPE:
-            exit();
-            break;
-        }
-    }
-}
-
-void TemplateGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
-{
-    switch (evt)
-    {
-    case Touch::TOUCH_PRESS:
-        break;
-    case Touch::TOUCH_RELEASE:
-        break;
-    case Touch::TOUCH_MOVE:
-        break;
-    };
-}
+#include "TemplateGame.h"
+
+// Declare our game instance
+TemplateGame game;
+
+TemplateGame::TemplateGame()
+    : _scene(NULL), _wireframe(false)
+{
+}
+
+void TemplateGame::initialize()
+{
+    // Load game scene from file
+    _scene = Scene::load("res/demo.scene");
+
+    // Get the box model and initialize its material parameter values and bindings
+    Node* boxNode = _scene->findNode("box");
+    Model* boxModel = boxNode->getModel();
+    Material* boxMaterial = boxModel->getMaterial();
+
+    // Set the aspect ratio for the scene's camera to match the current resolution
+    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
+}
+
+void TemplateGame::finalize()
+{
+    SAFE_RELEASE(_scene);
+}
+
+void TemplateGame::update(float elapsedTime)
+{
+    // Rotate model
+    _scene->findNode("box")->rotateY(MATH_DEG_TO_RAD((float)elapsedTime / 1000.0f * 180.0f));
+}
+
+void TemplateGame::render(float elapsedTime)
+{
+    // Clear the color and depth buffers
+    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
+
+    // Visit all the nodes in the scene for drawing
+    _scene->visit(this, &TemplateGame::drawScene);
+}
+
+bool TemplateGame::drawScene(Node* node)
+{
+    // If the node visited contains a model, draw it
+    Model* model = node->getModel(); 
+    if (model)
+    {
+        model->draw(_wireframe);
+    }
+    return true;
+}
+
+void TemplateGame::keyEvent(Keyboard::KeyEvent evt, int key)
+{
+    if (evt == Keyboard::KEY_PRESS)
+    {
+        switch (key)
+        {
+        case Keyboard::KEY_ESCAPE:
+            exit();
+            break;
+        }
+    }
+}
+
+void TemplateGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+{
+    switch (evt)
+    {
+    case Touch::TOUCH_PRESS:
+        _wireframe = !_wireframe;
+        break;
+    case Touch::TOUCH_RELEASE:
+        break;
+    case Touch::TOUCH_MOVE:
+        break;
+    };
+}

+ 63 - 62
template/src/TemplateGame.h

@@ -1,62 +1,63 @@
-#ifndef TEMPLATEGAME_H_
-#define TEMPLATEGAME_H_
-
-#include "gameplay.h"
-
-using namespace gameplay;
-
-/**
- * Main game class.
- */
-class TemplateGame: public Game
-{
-public:
-
-    /**
-     * Constructor.
-     */
-    TemplateGame();
-
-    /**
-     * @see Game::keyEvent
-     */
-	void keyEvent(Keyboard::KeyEvent evt, int key);
-	
-    /**
-     * @see Game::touchEvent
-     */
-    void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
-
-protected:
-
-    /**
-     * @see Game::initialize
-     */
-    void initialize();
-
-    /**
-     * @see Game::finalize
-     */
-    void finalize();
-
-    /**
-     * @see Game::update
-     */
-    void update(float elapsedTime);
-
-    /**
-     * @see Game::render
-     */
-    void render(float elapsedTime);
-
-private:
-
-    /**
-     * Draws the scene each frame.
-     */
-    bool drawScene(Node* node);
-
-    Scene* _scene;
-};
-
-#endif
+#ifndef TEMPLATEGAME_H_
+#define TEMPLATEGAME_H_
+
+#include "gameplay.h"
+
+using namespace gameplay;
+
+/**
+ * Main game class.
+ */
+class TemplateGame: public Game
+{
+public:
+
+    /**
+     * Constructor.
+     */
+    TemplateGame();
+
+    /**
+     * @see Game::keyEvent
+     */
+	void keyEvent(Keyboard::KeyEvent evt, int key);
+	
+    /**
+     * @see Game::touchEvent
+     */
+    void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
+
+protected:
+
+    /**
+     * @see Game::initialize
+     */
+    void initialize();
+
+    /**
+     * @see Game::finalize
+     */
+    void finalize();
+
+    /**
+     * @see Game::update
+     */
+    void update(float elapsedTime);
+
+    /**
+     * @see Game::render
+     */
+    void render(float elapsedTime);
+
+private:
+
+    /**
+     * Draws the scene each frame.
+     */
+    bool drawScene(Node* node);
+
+    Scene* _scene;
+    bool _wireframe;
+};
+
+#endif

+ 24 - 13
template/template.vcxproj

@@ -146,8 +146,7 @@
       <AdditionalLibraryDirectories>GAMEPLAY_PATH/external-deps/lua/lib/windows/x86;GAMEPLAY_PATH/external-deps/bullet/lib/windows/x86;GAMEPLAY_PATH/external-deps/openal/lib/windows/x86;GAMEPLAY_PATH/external-deps/oggvorbis/lib/windows/x86;GAMEPLAY_PATH/external-deps/glew/lib/windows/x86;GAMEPLAY_PATH/external-deps/png/lib/windows/x86;GAMEPLAY_PATH/external-deps/zlib/lib/windows/x86;GAMEPLAY_PATH/gameplay/windows/x86/$(Configuration)</AdditionalLibraryDirectories>
     </Link>
     <PostBuildEvent>
-      <Command>
-      </Command>
+      <Command>xcopy GAMEPLAY_PATH\gameplay\res\shaders res\shaders\* /s /y</Command>
     </PostBuildEvent>
     <CustomBuildStep>
       <Command>
@@ -176,8 +175,7 @@
       <AdditionalLibraryDirectories>GAMEPLAY_PATH/external-deps/lua/lib/windows/x64;GAMEPLAY_PATH/external-deps/bullet/lib/windows/x64;GAMEPLAY_PATH/external-deps/openal/lib/windows/x64;GAMEPLAY_PATH/external-deps/oggvorbis/lib/windows/x64;GAMEPLAY_PATH/external-deps/glew/lib/windows/x64;GAMEPLAY_PATH/external-deps/png/lib/windows/x64;GAMEPLAY_PATH/external-deps/zlib/lib/windows/x64;GAMEPLAY_PATH/gameplay/windows/x64/$(Configuration)</AdditionalLibraryDirectories>
     </Link>
     <PostBuildEvent>
-      <Command>
-      </Command>
+      <Command>xcopy GAMEPLAY_PATH\gameplay\res\shaders res\shaders\* /s /y</Command>
     </PostBuildEvent>
     <CustomBuildStep>
       <Command>
@@ -208,8 +206,7 @@
       <AdditionalLibraryDirectories>GAMEPLAY_PATH/external-deps/lua/lib/windows/x86;GAMEPLAY_PATH/external-deps/bullet/lib/windows/x86;GAMEPLAY_PATH/external-deps/openal/lib/windows/x86;GAMEPLAY_PATH/external-deps/oggvorbis/lib/windows/x86;GAMEPLAY_PATH/external-deps/glew/lib/windows/x86;GAMEPLAY_PATH/external-deps/png/lib/windows/x86;GAMEPLAY_PATH/external-deps/zlib/lib/windows/x86;GAMEPLAY_PATH/gameplay/windows/x86/$(Configuration)</AdditionalLibraryDirectories>
     </Link>
     <PostBuildEvent>
-      <Command>
-      </Command>
+      <Command>xcopy GAMEPLAY_PATH\gameplay\res\shaders res\shaders\* /s /y</Command>
     </PostBuildEvent>
     <CustomBuildStep>
       <Command>
@@ -272,8 +269,7 @@
       <AdditionalLibraryDirectories>GAMEPLAY_PATH/external-deps/lua/lib/windows/x86;GAMEPLAY_PATH/external-deps/bullet/lib/windows/x86;GAMEPLAY_PATH/external-deps/openal/lib/windows/x86;GAMEPLAY_PATH/external-deps/oggvorbis/lib/windows/x86;GAMEPLAY_PATH/external-deps/glew/lib/windows/x86;GAMEPLAY_PATH/external-deps/png/lib/windows/x86;GAMEPLAY_PATH/external-deps/zlib/lib/windows/x86;GAMEPLAY_PATH/gameplay/windows/x86/$(Configuration)</AdditionalLibraryDirectories>
     </Link>
     <PostBuildEvent>
-      <Command>
-      </Command>
+      <Command>xcopy GAMEPLAY_PATH\gameplay\res\shaders res\shaders\* /s /y</Command>
     </PostBuildEvent>
     <CustomBuildStep>
       <Command>
@@ -322,11 +318,26 @@
     </None>
     <None Include="game.config" />
     <None Include="icon.png" />
-    <None Include="res\box.fbx" />
-    <None Include="res\box.gpb" />
-    <None Include="res\box.material" />
-    <None Include="res\colored.frag" />
-    <None Include="res\colored.vert" />
+    <None Include="res\demo.fbx" />
+    <None Include="res\demo.gpb" />
+    <None Include="res\demo.material" />
+    <None Include="res\demo.scene" />
+    <None Include="res\shaders\colored.frag" />
+    <None Include="res\shaders\colored.vert" />
+    <None Include="res\shaders\font.frag" />
+    <None Include="res\shaders\font.vert" />
+    <None Include="res\shaders\form.frag" />
+    <None Include="res\shaders\form.vert" />
+    <None Include="res\shaders\lighting.frag" />
+    <None Include="res\shaders\lighting.vert" />
+    <None Include="res\shaders\skinning-none.vert" />
+    <None Include="res\shaders\skinning.vert" />
+    <None Include="res\shaders\sprite.frag" />
+    <None Include="res\shaders\sprite.vert" />
+    <None Include="res\shaders\terrain.frag" />
+    <None Include="res\shaders\terrain.vert" />
+    <None Include="res\shaders\textured.frag" />
+    <None Include="res\shaders\textured.vert" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\TemplateGame.cpp" />

+ 86 - 38
template/template.vcxproj.filters

@@ -1,39 +1,87 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="res">
-    </Filter>
-    <Filter Include="src">
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-	<None Include="game.config" />
-    <None Include="icon.png" />
-    <None Include="bar-descriptor.xml" />
-    <None Include="res\box.fbx">
-      <Filter>res</Filter>
-    </None>
-    <None Include="res\box.gpb">
-      <Filter>res</Filter>
-    </None>
-    <None Include="res\box.material">
-      <Filter>res</Filter>
-    </None>
-    <None Include="res\colored.frag">
-      <Filter>res</Filter>
-    </None>
-    <None Include="res\colored.vert">
-      <Filter>res</Filter>
-    </None>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="src\TemplateGame.h">
-      <Filter>src</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="src\TemplateGame.cpp">
-      <Filter>src</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="res">
+    </Filter>
+    <Filter Include="src">
+    </Filter>
+    <Filter Include="res\shaders">
+      <UniqueIdentifier>{f54d3628-f193-4138-97ca-0ca3b34480d0}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="game.config" />
+    <None Include="icon.png" />
+    <None Include="bar-descriptor.xml" />
+    <None Include="res\demo.fbx">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\demo.gpb">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\demo.material">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\demo.scene">
+      <Filter>res</Filter>
+    </None>
+    <None Include="res\shaders\colored.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\colored.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\font.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\font.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\form.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\form.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\lighting.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\lighting.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\skinning.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\skinning-none.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\sprite.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\sprite.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\terrain.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\terrain.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\textured.frag">
+      <Filter>res\shaders</Filter>
+    </None>
+    <None Include="res\shaders\textured.vert">
+      <Filter>res\shaders</Filter>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="src\TemplateGame.h">
+      <Filter>src</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="src\TemplateGame.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>