Commits

Michael Ludwig committed 8a48b23

Update demo for transparency

  • Participants
  • Parent commits d99807a

Comments (0)

Files changed (1)

File ferox-demos/src/main/java/com/ferox/scene/controller/ffp/TransparentDemo.java

 import com.ferox.scene.BlinnPhongMaterial;
 import com.ferox.scene.Camera;
 import com.ferox.scene.DiffuseColor;
+import com.ferox.scene.DirectionLight;
 import com.ferox.scene.PointLight;
 import com.ferox.scene.Renderable;
 import com.ferox.scene.Transform;
 import com.ferox.scene.controller.light.ComputeLightGroupTask;
 import com.ferox.scene.controller.light.ComputeShadowFrustumTask;
 import com.ferox.util.ApplicationStub;
+import com.ferox.util.geom.Box;
 import com.ferox.util.geom.Geometry;
-import com.ferox.util.geom.Teapot;
 import com.ferox.util.profile.Profiler;
 import com.lhkbob.entreri.Entity;
 import com.lhkbob.entreri.EntitySystem;
 public class TransparentDemo extends ApplicationStub {
     protected static final int BOUNDS = 50;
     protected static final double BOX_SIZE = 1.5;
-    protected static final int NUM_X = 1;
-    protected static final int NUM_Y = 1;
-    protected static final int NUM_Z = 1;
-    protected static final double GAP_X = 0;
-    protected static final double GAP_Y = 0;
-    protected static final double GAP_Z = 0;
+    protected static final int NUM_X = 5;
+    protected static final int NUM_Y = 5;
+    protected static final int NUM_Z = 5;
+    protected static final double GAP_X = 1;
+    protected static final double GAP_Y = 1;
+    protected static final double GAP_Z = 1;
 
     protected static final AxisAlignedBox worldBounds = new AxisAlignedBox(new Vector3(-2 * BOUNDS - 1,
                                                                                        -2 * BOUNDS - 1,
         updateCameraOrientation();
 
         // boxes
-        Geometry boxGeom = Teapot.create(BOX_SIZE); //Box.create(BOX_SIZE);
+        Geometry boxGeom = Box.create(BOX_SIZE);
         for (int x = 0; x < NUM_X; x++) {
             for (int y = 0; y < NUM_Y; y++) {
                 for (int z = 0; z < NUM_Z; z++) {
                        .setLocalBounds(boxGeom.getBounds());
                     box.add(BlinnPhongMaterial.class).getData()
                        .setNormals(boxGeom.getNormals());
-                    box.add(DiffuseColor.class).getData()
-                    //                       .setColor(new ColorRGB(x / (double) NUM_X,
-                    //                                              y / (double) NUM_Y,
-                    //                                              z / (double) NUM_Z));
-                       .setColor(new ColorRGB(.5, .5, .5));
+                    box.add(DiffuseColor.class)
+                       .getData()
+                       .setColor(new ColorRGB(x / (double) NUM_X,
+                                              y / (double) NUM_Y,
+                                              z / (double) NUM_Z));
                     double rand = Math.random();
-                    //                    if (rand < .3) {
-                    //                        box.add(Transparent.class).getData().setOpacity(.5)
-                    //                           .setAdditive(true);
-                    //                    } else if (rand < .6) {
-                    box.add(Transparent.class).getData().setOpacity(.5)
-                       .setAdditive(false);
-                    //                    }
+                    if (rand < .3) {
+                        box.add(Transparent.class).getData().setOpacity(.5)
+                           .setAdditive(true);
+                    } else if (rand < .6) {
+                        box.add(Transparent.class).getData().setOpacity(.5)
+                           .setAdditive(false);
+                    }
 
                     box.get(Transform.class).getData()
                        .setMatrix(new Matrix4().setIdentity().setCol(3, pos));
                                                            new Vector4(100, 100, 100, 1)));
 
         // a directed light, which casts shadows
-        //        Entity inf = system.addEntity();
-        //        inf.add(DirectionLight.class).getData().setColor(new ColorRGB(1, 1, 1))
-        //           .setShadowCaster(true);
-        //        inf.get(Transform.class)
-        //           .getData()
-        //           .setMatrix(new Matrix4().lookAt(new Vector3(), new Vector3(15, 15, 15),
-        //                                           new Vector3(0, 1, 0)));
+        Entity inf = system.addEntity();
+        inf.add(DirectionLight.class).getData().setColor(new ColorRGB(1, 1, 1))
+           .setShadowCaster(true);
+        inf.get(Transform.class)
+           .getData()
+           .setMatrix(new Matrix4().lookAt(new Vector3(), new Vector3(15, 15, 15),
+                                           new Vector3(0, 1, 0)));
     }
 
     @Override