Commits

John Marsden  committed 776ea9b

Base ECS 3D

  • Participants
  • Parent commits b8225cf
  • Branches develop

Comments (0)

Files changed (1)

File src/main/java/cc/plural/test/ecs/TestECS3D.java

             Display.setIcon(icons);
         }
     }
-    
+
     public void init(Renderer renderer) {
         setIcon(renderer);
         renderer.setFrameRate(80);
         if (logger.isInfoEnabled()) {
             logger.info(rendererDump);
         }
-        
-        renderer.setPerspectiveProjection(0, 200, QuickMath.PI/2, 1);
+
+        renderer.setPerspectiveProjection(0, 200, QuickMath.PI / 2, 1);
 
         engine = new Engine();
-        
+
         GameObject testObject = engine.createGameObject("Test Game Cube");
+
+        Vertex[] cubeVerticies = new Vertex[]{
+            // back quad
+            new Vertex(1.0f, 1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(-1.0f, 1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(-1.0f, -1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            // back quad
+            new Vertex(1.0f, 1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(-1.0f, 1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(-1.0f, -1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, 1.0f, 1f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+            // left quad
+            new Vertex(-1.0f, 1.0f, -1.0f, 1f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(-1.0f, 1.0f, 1.0f, 1f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(-1.0f, -1.0f, 1.0f, 1f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(-1.0f, -1.0f, -1.0f, 1f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
+            // right quad
+            new Vertex(1.0f, 1.0f, -1.0f, 1f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(1.0f, 1.0f, 1.0f, 1f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, 1.0f, 1f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, -1.0f, 1f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f),
+            // top quad
+            new Vertex(-1.0f, 1.0f, -1.0f, 1f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f),
+            new Vertex(-1.0f, 1.0f, 1.0f, 1f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f),
+            new Vertex(1.0f, 1.0f, 1.0f, 1f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f),
+            new Vertex(1.0f, 1.0f, -1.0f, 1f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f),
+            // bottom quad
+            new Vertex(-1.0f, -1.0f, -1.0f, 1f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
+            new Vertex(-1.0f, -1.0f, 1.0f, 1f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, 1.0f, 1f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
+            new Vertex(1.0f, -1.0f, -1.0f, 1f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f)
+        };
+
+        testObject.createGeometry();
+
+        testObject.geometry.mesh = renderer.createStaticMesh(cubeVerticies, new short[]{0, 1, 2, 2, 3, 0});
+        testObject.geometry.mesh.init();
+        testObject.geometry.mesh.load();
+
+        testObject.createSpatial();
         
         engine.dumpState();
     }