2
0
CartBlanche 2 сар өмнө
parent
commit
2c13dd7008

+ 5 - 1
Collisions/CollisionSample.sln

@@ -8,7 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollisionSample.Windows", "
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollisionSample.DesktopGL", "Platforms\Desktop\CollisionSample.DesktopGL.csproj", "{AFFFC991-4956-45EF-8746-C1AE3FC7A247}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollisionSample.DesktopVK", "Platforms\Vulkan\CollisionSample.DesktopVK.csproj", "{AFFFC991-4956-45EF-8746-C1AE3FC7A247}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollisionSample.DesktopVK", "Platforms\Vulkan\CollisionSample.DesktopVK.csproj", "{BB27C128-CEEB-46A7-A8BB-8E6A84EE73B0}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollisionSample.Android", "Platforms\Android\CollisionSample.Android.csproj", "{AFFFC991-4956-45EF-8746-C1AE3FC7A248}"
 EndProject
@@ -32,6 +32,10 @@ Global
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A247}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A247}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A247}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BB27C128-CEEB-46A7-A8BB-8E6A84EE73B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BB27C128-CEEB-46A7-A8BB-8E6A84EE73B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BB27C128-CEEB-46A7-A8BB-8E6A84EE73B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BB27C128-CEEB-46A7-A8BB-8E6A84EE73B0}.Release|Any CPU.Build.0 = Release|Any CPU
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A248}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A248}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{AFFFC991-4956-45EF-8746-C1AE3FC7A248}.Release|Any CPU.ActiveCfg = Release|Any CPU

+ 6 - 6
Collisions/Core/CollisionSample.cs

@@ -166,7 +166,7 @@ namespace CollisionSample
             cameraTarget = cameraOrigins[0];
 
             paused = false;
-            
+
             base.Initialize();
         }
 
@@ -266,7 +266,7 @@ namespace CollisionSample
             // Animate primary ray (this is the only animated primary object)
             // It sweeps back and forth across the secondary objects
             const float sweepTime = 3.1f;
-            float rayDt = (-Math.Abs((t/sweepTime) % 2.0f - 1.0f) * NumSecondaryShapes + 0.5f) * gap;
+            float rayDt = (-Math.Abs((t / sweepTime) % 2.0f - 1.0f) * NumSecondaryShapes + 0.5f) * gap;
             primaryRay.Direction.X = (float)Math.Sin(xRate * (t + rayDt));
             primaryRay.Direction.Y = (float)Math.Sin(yRate * (t + rayDt));
             primaryRay.Direction.Z = (float)Math.Sin(zRate * (t + rayDt));
@@ -391,7 +391,7 @@ namespace CollisionSample
             }
 
             // Group cycle
-            if ( (currentKeyboardState.IsKeyDown(Keys.G) && previousKeyboardState.IsKeyUp(Keys.G)) ||
+            if ((currentKeyboardState.IsKeyDown(Keys.G) && previousKeyboardState.IsKeyUp(Keys.G)) ||
                  (currentGamePadState.IsButtonDown(Buttons.A) && previousGamePadState.IsButtonUp(Buttons.A)))
             {
                 currentCamera = (currentCamera + 1) % NumGroups;
@@ -494,7 +494,7 @@ namespace CollisionSample
             for (int g = 0; g < NumGroups; ++g)
             {
                 Vector3 origin = new Vector3(cameraOrigins[g].X - 20, cameraOrigins[g].Y - 10, cameraOrigins[g].Z - 20);
-                debugDraw.DrawWireGrid(Vector3.UnitX*40, Vector3.UnitZ*40, origin, 20, 20, Color.Black);
+                debugDraw.DrawWireGrid(Vector3.UnitX * 40, Vector3.UnitZ * 40, origin, 20, 20, Color.Black);
             }
 
             DrawPrimaryShapes();
@@ -543,7 +543,7 @@ namespace CollisionSample
             switch (cr)
             {
                 case ContainmentType.Contains:
-                    return Color.Red;
+                    return Color.Blue;
                 case ContainmentType.Disjoint:
                     return Color.LightGray;
                 case ContainmentType.Intersects:
@@ -555,4 +555,4 @@ namespace CollisionSample
 
     }
 
-}
+}

+ 9 - 6
Collisions/Core/FrameRateCounter.cs

@@ -19,9 +19,9 @@ namespace CollisionSample
     /// </summary>
     public class FrameRateCounter : DrawableGameComponent
     {
-        ContentManager  content;
-        SpriteBatch     spriteBatch;
-        SpriteFont      spriteFont;
+        ContentManager content;
+        SpriteBatch spriteBatch;
+        SpriteFont spriteFont;
 
         int frameRate = 0;
         int frameCounter = 0;
@@ -70,6 +70,8 @@ namespace CollisionSample
             }
         }
 
+        const string legend = "\nBlue: Contains\nLightGray: Disjointed\nYellow: Intersects";
+
         /// <summary>
         /// Frame rate display occurs during the Draw method and uses the Font and Sprite batch to render text.
         /// </summary>
@@ -78,12 +80,13 @@ namespace CollisionSample
         {
             frameCounter++;
 
-            string fps = string.Format("fps: {0}", frameRate);
+            string fps = string.Format("FPS: {0}", frameRate);
+            fps += legend;
 
             spriteBatch.Begin();
-            spriteBatch.DrawString(spriteFont, fps, new Vector2(32, 32), Color.White);
+            spriteBatch.DrawString(spriteFont, fps, new Vector2(32, 20), Color.White);
             spriteBatch.End();
         }
     }
 
-}
+}

+ 21 - 0
Collisions/Platforms/Vulkan/README.md

@@ -0,0 +1,21 @@
+# Collisions (Vulkan)
+
+## Building and Running
+
+### DesktopVK (Cross-platform)
+
+#### Before Building
+
+* Goto https://github.com/MonoGame/MonoGame/actions and find the latest run that was built the `develop` branch.
+* Download the binary artefact, which will have a name with a similar format to `MonoGame.3.8.*4*.*-develop`
+* Extract that directory as a top level folder of these samples. eg. if you downloaded `MonoGame.3.8.4.2908-develop` the not level folder name should be `MonoGame.3.8.4.2908-develop` and within that will the extracted contents of you artefact your downloaded.
+* Currently the VK csproj looks for `MonoGame.3.8.4.2908-develop`, so you may need to edit the *VK.csproj to point to which ever artefact you downloaded and unzipped.
+
+#### Building and Running
+If the above went well, execute the following command in the top level directory of this sample.
+
+```
+dotnet run --project Platforms/Vulkan/CollisionSample.DesktopVK.csproj
+```
+
+