OSDN Git Service

renamed BoneAnimation -> NodeAnimation, fixed up a few things in gdx-invaders, still...
authorbadlogic <badlogicgames@gmail.com>
Sat, 6 Apr 2013 22:17:56 +0000 (00:17 +0200)
committerbadlogic <badlogicgames@gmail.com>
Sat, 6 Apr 2013 22:17:56 +0000 (00:17 +0200)
demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java
demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/Renderer.java
demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/simulation/Simulation.java
gdx/src/com/badlogic/gdx/graphics/g3d/Model.java
gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java
gdx/src/com/badlogic/gdx/graphics/g3d/model/Animation.java
gdx/src/com/badlogic/gdx/graphics/g3d/model/MorphAnimation.java [deleted file]
gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeAnimation.java [moved from gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneAnimation.java with 74% similarity]
gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeKeyframe.java [moved from gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneKeyframe.java with 92% similarity]

index 918c061..742301d 100644 (file)
@@ -23,7 +23,7 @@ public class GdxInvadersDesktop {
                LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();\r
                config.title = "Gdx Invaders";\r
                config.vSyncEnabled = true;\r
-               config.useGL20 = false;\r
+               config.useGL20 = true;\r
                new LwjglApplication(new GdxInvaders(), config);\r
        }\r
 }\r
index 8dfdd16..82d119e 100644 (file)
@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
+import com.badlogic.gdx.graphics.GL20;\r
 import com.badlogic.gdx.graphics.GLCommon;\r
 import com.badlogic.gdx.graphics.Mesh;\r
 import com.badlogic.gdx.graphics.PerspectiveCamera;\r
index 5278819..17d71a9 100644 (file)
@@ -80,7 +80,7 @@ public class Simulation implements Disposable {
                shipModel.materials.get(0).add(TextureAttribute.createDiffuse(shipTexture));\r
                invaderModel.materials.get(0).add(TextureAttribute.createDiffuse(invaderTexture));\r
                \r
-               blockModel.materials.get(0).add(ColorAttribute.createDiffuse(0, 0, 1, 0.5f));\r
+               ((ColorAttribute)blockModel.materials.get(0).get(ColorAttribute.Diffuse)).color.set(0, 0, 1, 0.5f);\r
                blockModel.materials.get(0).add(new BlendingAttribute(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA));\r
                \r
                shotModel.materials.get(0).add(ColorAttribute.createDiffuse(1, 1, 0, 1f));\r
@@ -139,6 +139,7 @@ public class Simulation implements Disposable {
                                TextureAttribute.createDiffuse(explosionTexture)));\r
                \r
                ship = new Ship(shipModel);\r
+               ship.transform.rotate(0, 1, 0, 180);\r
 \r
                for (int row = 0; row < 4; row++) {\r
                        for (int column = 0; column < 8; column++) {\r
@@ -231,10 +232,10 @@ public class Simulation implements Disposable {
                removedShots.clear();\r
 \r
                if (!ship.isExploding) {\r
+                       ship.transform.getTranslation(tmpV1);\r
                        for (int i = 0; i < shots.size(); i++) {\r
                                Shot shot = shots.get(i);\r
                                if (!shot.isInvaderShot) continue;\r
-                               ship.transform.getTranslation(tmpV1);\r
                                shot.transform.getTranslation(tmpV2);\r
                                if (tmpV1.dst(tmpV2) < Ship.SHIP_RADIUS) {\r
                                        removedShots.add(shot);\r
@@ -251,10 +252,10 @@ public class Simulation implements Disposable {
                                shots.remove(removedShots.get(i));\r
                }\r
 \r
+               ship.transform.getTranslation(tmpV2);\r
                for (int i = 0; i < invaders.size(); i++) {\r
                        Invader invader = invaders.get(i);\r
                        invader.transform.getTranslation(tmpV1);\r
-                       ship.transform.getTranslation(tmpV2);\r
                        if (tmpV1.dst(tmpV2) < Ship.SHIP_RADIUS) {\r
                                ship.lives--;\r
                                invaders.remove(invader);\r
@@ -272,11 +273,11 @@ public class Simulation implements Disposable {
 \r
                for (int i = 0; i < shots.size(); i++) {\r
                        Shot shot = shots.get(i);\r
+                       shot.transform.getTranslation(tmpV2);\r
 \r
                        for (int j = 0; j < blocks.size(); j++) {\r
                                Block block = blocks.get(j);\r
                                block.transform.getTranslation(tmpV1);\r
-                               shot.transform.getTranslation(tmpV2);\r
                                if (tmpV1.dst(tmpV2) < Block.BLOCK_RADIUS) {\r
                                        removedShots.add(shot);\r
                                        shot.hasLeftField = true;\r
index 8ee5902..d4fa814 100644 (file)
@@ -42,10 +42,10 @@ import com.badlogic.gdx.utils.Pool;
  * A model can be rendered by creating a {@link ModelInstance} from it. That instance has an additional
  * transform to position the model in the world, and allows modification of materials and nodes without
  * destroying the original model. The original model is the owner of any meshes and textures, all instances
- * derrived from the model share these resources. Disposing the model will automatically make all instances
+ * created from the model share these resources. Disposing the model will automatically make all instances
  * invalid!</p>
  * 
- * A model is derrived from {@link ModelData}, which in turn is loaded by a {@link ModelLoader}.
+ * A model is created from {@link ModelData}, which in turn is loaded by a {@link ModelLoader}.
  *   
  * @author badlogic
  *
index 9adb36d..cfdd348 100644 (file)
@@ -1,6 +1,7 @@
 package com.badlogic.gdx.graphics.g3d;
 
 import com.badlogic.gdx.graphics.g3d.materials.Material;
+import com.badlogic.gdx.graphics.g3d.model.Animation;
 import com.badlogic.gdx.graphics.g3d.model.MeshPart;
 import com.badlogic.gdx.graphics.g3d.model.MeshPartMaterial;
 import com.badlogic.gdx.graphics.g3d.model.Node;
@@ -30,6 +31,8 @@ public class ModelInstance implements RenderableProvider {
        public final Array<Material> materials = new Array<Material>();
        /** a copy of the nodes of the original model, referencing the copied materials in their {@link MeshPartMaterial} instances **/
        public final Array<Node> nodes = new Array<Node>();
+       /** a copy of the animations of the original model **/
+       public final Array<Animation> animations = new Array<Animation>();
 
        /** Constructs a new ModelInstance with all nodes and materials of the given model. */
        public ModelInstance(Model model) {
index b4d67d5..1bfe37a 100644 (file)
@@ -1,8 +1,22 @@
 package com.badlogic.gdx.graphics.g3d.model;
 
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.utils.Array;
 
+/**
+ * An Animation has an id and a list of {@link NodeAnimation} instances. Each
+ * NodeAnimation animates a single {@link Node} in the {@link Model}. Every
+ * {@link NodeAnimation} is assumed to have the same amount of keyframes,
+ * at the same timestamps, as all other node animations for faster keyframe
+ * searches.
+ * 
+ * @author badlogic
+ */
 public class Animation {
+       /** the unique id of the animation **/
        public String id;
-       public Array<BoneAnimation> boneAnimations = new Array<BoneAnimation>();
+       /** the duration in seconds **/
+       public float duration;
+       /** the animation curves for individual nodes **/
+       public Array<NodeAnimation> nodeAnimations = new Array<NodeAnimation>();
 }
diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/model/MorphAnimation.java b/gdx/src/com/badlogic/gdx/graphics/g3d/model/MorphAnimation.java
deleted file mode 100644 (file)
index 7171874..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.badlogic.gdx.graphics.g3d.model;
-
-public class MorphAnimation {
-
-}
@@ -4,15 +4,15 @@ import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.utils.Array;
 
 /**
- * A BoneAnimation defines keyframes for a {@link Node} in a {@link Model}. The keyframes
+ * A NodeAnimation defines keyframes for a {@link Node} in a {@link Model}. The keyframes
  * are given as a translation vector, a rotation quaternion and a scale vector. Keyframes are 
  * interpolated linearly for now. Keytimes are given in seconds.
  * @author badlogic
  *
  */
-public class BoneAnimation {
+public class NodeAnimation {
        /** the Node affected by this animation **/
        public Node node;
        /** the keyframes, sorted by time, ascending **/
-       public Array<BoneKeyframe> keyframes = new Array<BoneKeyframe>();
+       public Array<NodeKeyframe> keyframes = new Array<NodeKeyframe>();
 }
@@ -5,11 +5,11 @@ import com.badlogic.gdx.math.Vector3;
 
 /**
  * A BoneyKeyframe specifies the translation, rotation and scale of a frame within
- * a {@link BoneAnimation}.
+ * a {@link NodeAnimation}.
  * @author badlogic
  *
  */
-public class BoneKeyframe {
+public class NodeKeyframe {
        /** the timestamp of this keyframe **/
        public float keytime;
        /** the translation, given in local space, relative to the parent **/