Ver código fonte

Merge pull request #882 from dgough/next

Added Game::getArguments()
Sean Paul Taylor 13 anos atrás
pai
commit
5458462dbf

+ 1 - 1
gameplay-template/gameplay-template.vcxproj

@@ -315,7 +315,7 @@
     </None>
     <None Include="game.config" />
     <None Include="icon.png" />
-    <None Include="res\box.dae" />
+    <None Include="res\box.fbx" />
     <None Include="res\box.gpb" />
     <None Include="res\box.material" />
     <None Include="res\colored.frag" />

+ 1 - 1
gameplay-template/gameplay-template.vcxproj.filters

@@ -10,7 +10,7 @@
 	<None Include="game.config" />
     <None Include="icon.png" />
     <None Include="bar-descriptor.xml" />
-    <None Include="res\box.dae">
+    <None Include="res\box.fbx">
       <Filter>res</Filter>
     </None>
     <None Include="res\box.gpb">

+ 0 - 183
gameplay-template/res/box.dae

@@ -1,183 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
-  <asset>
-    <contributor>
-      <author>sgrenier</author>
-      <authoring_tool>OpenCOLLADA2011 x64</authoring_tool>
-      <comments>
-			ColladaMaya export options: 
-			bakeTransforms=1;relativePaths=0;copyTextures=0;exportTriangles=1;exportCgfxFileReferences=0;
-			isSampling=0;curveConstrainSampling=0;removeStaticCurves=1;exportPolygonMeshes=1;exportLights=1;
-			exportCameras=1;exportJointsAndSkin=1;exportAnimations=1;exportInvisibleNodes=0;exportDefaultCameras=0;
-			exportTexCoords=1;exportNormals=1;exportNormalsPerVertex=1;exportVertexColors=0;exportVertexColorsPerVertex=0;
-			exportTexTangents=0;exportTangents=0;exportReferencedMaterials=0;exportMaterialsOnly=0;
-			exportXRefs=1;dereferenceXRefs=1;exportCameraAsLookat=0;cameraXFov=0;cameraYFov=1;doublePrecision=0
-		</comments>
-      <source_data>file:///C:/Users/sgrenier/Documents/maya/projects/default/untitled</source_data>
-    </contributor>
-    <created>2011-12-05T20:23:32</created>
-    <modified>2011-12-05T20:23:32</modified>
-    <unit name="centimeter" meter="0.01"/>
-    <up_axis>Y_UP</up_axis>
-  </asset>
-  <library_lights>
-    <light id="directionalLightShape" name="directionalLightShape">
-      <technique_common>
-        <directional>
-          <color>1 1 1</color>
-        </directional>
-      </technique_common>
-      <extra>
-        <technique profile="OpenCOLLADAMaya">
-          <originalMayaNodeId>directionalLightShape</originalMayaNodeId>
-        </technique>
-      </extra>
-    </light>
-  </library_lights>
-  <library_cameras>
-    <camera id="cameraShape" name="cameraShape">
-      <optics>
-        <technique_common>
-          <perspective>
-            <yfov>27.38717</yfov>
-            <aspect_ratio>1.7</aspect_ratio>
-            <znear>0.25</znear>
-            <zfar>100</zfar>
-          </perspective>
-        </technique_common>
-      </optics>
-      <extra>
-        <technique profile="OpenCOLLADAMaya">
-          <film_fit>0</film_fit>
-          <film_fit_offset>0</film_fit_offset>
-          <film_offsetX>0</film_offsetX>
-          <film_offsetY>0</film_offsetY>
-          <horizontal_aperture>4.079992</horizontal_aperture>
-          <lens_squeeze>1</lens_squeeze>
-          <originalMayaNodeId>cameraShape</originalMayaNodeId>
-          <vertical_aperture>2.399995</vertical_aperture>
-        </technique>
-      </extra>
-    </camera>
-  </library_cameras>
-  <library_materials>
-    <material id="lambert1" name="lambert1">
-      <instance_effect url="#lambert1-fx"/>
-    </material>
-  </library_materials>
-  <library_effects>
-    <effect id="lambert1-fx">
-      <profile_COMMON>
-        <technique sid="common">
-          <lambert>
-            <emission>
-              <color>0 0 0 1</color>
-            </emission>
-            <ambient>
-              <color>0 0 0 1</color>
-            </ambient>
-            <diffuse>
-              <color>0.4 0.4 0.4 1</color>
-            </diffuse>
-            <transparent opaque="RGB_ZERO">
-              <color>0 0 0 1</color>
-            </transparent>
-            <transparency>
-              <float>1</float>
-            </transparency>
-          </lambert>
-        </technique>
-      </profile_COMMON>
-    </effect>
-  </library_effects>
-  <library_geometries>
-    <geometry id="boxShape" name="boxShape">
-      <mesh>
-        <source id="boxShape-positions" name="boxShape-positions">
-          <float_array id="boxShape-positions-array" count="24">-0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5</float_array>
-          <technique_common>
-            <accessor source="#boxShape-positions-array" count="8" stride="3">
-              <param name="X" type="float"/>
-              <param name="Y" type="float"/>
-              <param name="Z" type="float"/>
-            </accessor>
-          </technique_common>
-        </source>
-        <source id="boxShape-normals" name="boxShape-normals">
-          <float_array id="boxShape-normals-array" count="72">0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0</float_array>
-          <technique_common>
-            <accessor source="#boxShape-normals-array" count="24" stride="3">
-              <param name="X" type="float"/>
-              <param name="Y" type="float"/>
-              <param name="Z" type="float"/>
-            </accessor>
-          </technique_common>
-        </source>
-        <source id="boxShape-map1" name="boxShape-map1">
-          <float_array id="boxShape-map1-array" count="28">0.375 0 0.625 0 0.375 0.25 0.625 0.25 0.375 0.5 0.625 0.5 0.375 0.75 0.625 0.75 0.375 1 0.625 1 0.875 0 0.875 0.25 0.125 0 0.125 0.25</float_array>
-          <technique_common>
-            <accessor source="#boxShape-map1-array" count="14" stride="2">
-              <param name="S" type="float"/>
-              <param name="T" type="float"/>
-            </accessor>
-          </technique_common>
-        </source>
-        <vertices id="boxShape-vertices" name="boxShape-vertices">
-          <input semantic="POSITION" source="#boxShape-positions"/>
-        </vertices>
-        <triangles material="initialShadingGroup" count="12">
-          <input semantic="VERTEX" source="#boxShape-vertices" offset="0"/>
-          <input semantic="NORMAL" source="#boxShape-normals" offset="1"/>
-          <input semantic="TEXCOORD" source="#boxShape-map1" offset="2" set="0"/>
-          <p>0 0 0 1 1 1 2 3 2 2 3 2 1 1 1 3 2 3 2 4 2 3 5 3 4 7 4 4 7 4 3 5 3 5 6 5 4 8 4 5 9 5 6 11 6 6 11 6 5 9 5 7 10 7 6 12 6 7 13 7 0 15 8 0 15 8 7 13 7 1 14 9 1 16 1 7 17 10 3 19 3 3 19 3 7 17 10 5 18 11 6 20 12 0 21 0 4 23 13 4 23 13 0 21 0 2 22 2</p>
-        </triangles>
-      </mesh>
-      <extra>
-        <technique profile="OpenCOLLADAMaya">
-          <originalMayaNodeId>boxShape</originalMayaNodeId>
-          <double_sided>1</double_sided>
-        </technique>
-      </extra>
-    </geometry>
-  </library_geometries>
-  <library_visual_scenes>
-    <visual_scene id="VisualSceneNode" name="untitled">
-      <node id="box" name="box" type="NODE">
-        <matrix sid="transform">1 0 0 0 0 1 0 0.5 0 0 1 0 0 0 0 1</matrix>
-        <instance_geometry url="#boxShape">
-          <bind_material>
-            <technique_common>
-              <instance_material symbol="initialShadingGroup" target="#lambert1"/>
-            </technique_common>
-          </bind_material>
-        </instance_geometry>
-        <extra>
-          <technique profile="OpenCOLLADAMaya">
-            <originalMayaNodeId>box</originalMayaNodeId>
-          </technique>
-        </extra>
-      </node>
-      <node id="camera" name="camera" type="NODE">
-        <matrix sid="transform">0.9753993 -0.08127667 0.2049154 1.554299 0.0276844 0.9673549 0.251909 2.301022 -0.2187002 -0.2400389 0.9458073 7.279555 0 0 0 1</matrix>
-        <instance_camera url="#cameraShape"/>
-        <extra>
-          <technique profile="OpenCOLLADAMaya">
-            <originalMayaNodeId>camera</originalMayaNodeId>
-          </technique>
-        </extra>
-      </node>
-      <node id="directionalLight" name="directionalLight" type="NODE">
-        <matrix sid="transform">0.9282893 -0.14183 0.3437488 4.077966 -0.03090286 0.8917856 0.4514016 1.976955 -0.3705726 -0.4296541 0.8234521 6.724438 0 0 0 1</matrix>
-        <instance_light url="#directionalLightShape"/>
-        <extra>
-          <technique profile="OpenCOLLADAMaya">
-            <originalMayaNodeId>directionalLight</originalMayaNodeId>
-          </technique>
-        </extra>
-      </node>
-    </visual_scene>
-  </library_visual_scenes>
-  <scene>
-    <instance_visual_scene url="#VisualSceneNode"/>
-  </scene>
-</COLLADA>

BIN
gameplay-template/res/box.fbx


BIN
gameplay-template/res/box.gpb


+ 2 - 4
gameplay-template/src/TemplateGame.cpp

@@ -11,12 +11,10 @@ TemplateGame::TemplateGame()
 void TemplateGame::initialize()
 {
     // Load game scene from file
-    Bundle* bundle = Bundle::create("res/box.gpb");
-    _scene = bundle->loadScene();
-    SAFE_RELEASE(bundle);
+    _scene = Scene::load("res/box.gpb");
 
     // Set the aspect ratio for the scene's camera to match the current resolution
-    _scene->getActiveCamera()->setAspectRatio((float)getWidth() / (float)getHeight());
+    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
     
     // Get light node
     Node* lightNode = _scene->findNode("directionalLight");

+ 1 - 1
gameplay/res/shaders/colored.vert

@@ -15,11 +15,11 @@ varying vec3 v_color;										// Output Vertex Color
 // 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
+uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space.
 #if defined(SKINNING)
 uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
 #endif
 #if defined(SPECULAR)
-uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space.
 uniform vec3 u_cameraPosition;                 				// Position of the camera in view space.
 #endif
 #if defined(POINT_LIGHT)

+ 5 - 0
gameplay/src/Game.cpp

@@ -500,6 +500,11 @@ void Game::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad)
 {
 }
 
+void Game::getArguments(int* argc, char*** argv)
+{
+    Platform::getArguments(argc, argv);
+}
+
 void Game::schedule(float timeOffset, TimeListener* timeListener, void* cookie)
 {
     GP_ASSERT(_timeEvents);

+ 8 - 0
gameplay/src/Game.h

@@ -507,6 +507,14 @@ public:
      */
     inline void getAccelerometerValues(float* pitch, float* roll);
 
+    /**
+     * Gets the command line arguments.
+     * 
+     * @param argc The number of command line arguments.
+     * @param argv The array of command line arguments.
+     */
+    void getArguments(int* argc, char*** argv);
+
     /**
      * Schedules a time event to be sent to the given TimeListener a given number of game milliseconds from now.
      * Game time stops while the game is paused. A time offset of zero will fire the time event in the next frame.

+ 8 - 0
gameplay/src/Platform.h

@@ -207,6 +207,14 @@ private:
      * @param roll The accelerometer roll.
      */
     static void getAccelerometerValues(float* pitch, float* roll);
+
+    /**
+     * Gets the command line arguments.
+     * 
+     * @param argc The number of command line arguments.
+     * @param argv The array of command line arguments.
+     */
+    static void getArguments(int* argc, char*** argv);
     
     /**
      * Shows or hides the virtual keyboard (if supported).

+ 8 - 0
gameplay/src/PlatformAndroid.cpp

@@ -1217,6 +1217,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     }
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = 0;
+    if (argv)
+        *argv = 0;
+}
+
 bool Platform::hasMouse()
 {
     // not supported

+ 10 - 0
gameplay/src/PlatformBlackBerry.cpp

@@ -26,6 +26,8 @@
 
 using namespace std;
 
+int __argc = 0;
+char** __argv = 0;
 struct timespec __timespec;
 static double __timeStart;
 static double __timeAbsolute;
@@ -1472,6 +1474,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     }
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+
 bool Platform::hasMouse()
 {
     // not supported

+ 30 - 19
gameplay/src/PlatformLinux.cpp

@@ -25,6 +25,9 @@
 
 using namespace std;
 
+int __argc = 0;
+char** __argv = 0;
+
 enum GamepadAxisInfoFlags
 {
     GP_AXIS_SKIP = 0x1,
@@ -1398,21 +1401,21 @@ namespace gameplay
         usleep(ms * 1000);
     }
 
-    void Platform::setMultiSampling(bool enabled)
-    {
-        if (enabled == __multiSampling)
-        {
-            return;
-        }
-        
-            //todo
-            
-            __multiSampling = enabled;
-    }
-    
-        bool Platform::isMultiSampling()
-        {
-            return __multiSampling;
+    void Platform::setMultiSampling(bool enabled)
+    {
+        if (enabled == __multiSampling)
+        {
+            return;
+        }
+        
+            //todo
+            
+            __multiSampling = enabled;
+    }
+    
+        bool Platform::isMultiSampling()
+        {
+            return __multiSampling;
         }
 
     void Platform::setMultiTouch(bool enabled)
@@ -1434,6 +1437,14 @@ namespace gameplay
         *roll = __roll;
     }
 
+    void Platform::getArguments(int* argc, char*** argv)
+    {
+        if (argc)
+            *argc = __argc;
+        if (argv)
+            *argv = __argv;
+    }
+
     bool Platform::hasMouse()
     {
         return true;
@@ -1538,7 +1549,7 @@ namespace gameplay
             return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
         }
     }
-    
+    
         void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
                 unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
         {
@@ -1550,10 +1561,10 @@ namespace gameplay
         Gamepad::remove(handle);
     }
 
-    void Platform::shutdownInternal()
-    {
+    void Platform::shutdownInternal()
+    {
         closeAllGamepads();
-        Game::getInstance()->shutdown();
+        Game::getInstance()->shutdown();
     }
 
     bool Platform::isGestureSupported(Gesture::GestureEvent evt)

+ 11 - 0
gameplay/src/PlatformMacOSX.mm

@@ -30,6 +30,9 @@ using namespace gameplay;
 @class View;
 @class HIDGamepad;
 
+int __argc = 0;
+char** __argv = 0;
+
 // Default to 720p
 static int __width = 1280;
 static int __height = 720;
@@ -1789,6 +1792,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     *roll = __roll;
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+    
 bool Platform::hasMouse()
 {
     return true;

+ 8 - 0
gameplay/src/PlatformWindows.cpp

@@ -1112,6 +1112,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     *roll = __roll;
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+
 bool Platform::hasMouse()
 {
     return true;

+ 11 - 0
gameplay/src/PlatformiOS.mm

@@ -32,6 +32,9 @@ extern const int WINDOW_WIDTH  = [[UIScreen mainScreen] bounds].size.height * [[
 extern const int WINDOW_HEIGHT = [[UIScreen mainScreen] bounds].size.width * [[UIScreen mainScreen] scale];
 extern const int WINDOW_SCALE = [[UIScreen mainScreen] scale];
 
+int __argc = 0;
+char** __argv = 0;
+
 @class AppDelegate;
 @class View;
 
@@ -1381,6 +1384,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
 {
     [__appDelegate getAccelerometerPitch:pitch roll:roll];
 }
+    
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
 
 bool Platform::hasMouse()
 {

+ 5 - 0
gameplay/src/gameplay-main-blackberry.cpp

@@ -4,11 +4,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);

+ 6 - 1
gameplay/src/gameplay-main-ios.mm

@@ -5,11 +5,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
-{   
+{
+    __argc = argc;
+    __argv = argv;
     NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);

+ 5 - 0
gameplay/src/gameplay-main-linux.cpp

@@ -4,11 +4,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);

+ 5 - 0
gameplay/src/gameplay-main-macosx.mm

@@ -5,11 +5,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);