From 38ccecdb5307c18c2b7a942904fdf1ce479d0bb6 Mon Sep 17 00:00:00 2001 From: badlogic Date: Sun, 7 Apr 2013 00:17:56 +0200 Subject: [PATCH] renamed BoneAnimation -> NodeAnimation, fixed up a few things in gdx-invaders, still rather broken --- .../src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java | 2 +- .../src/com/badlogic/gdxinvaders/Renderer.java | 1 + .../com/badlogic/gdxinvaders/simulation/Simulation.java | 9 +++++---- gdx/src/com/badlogic/gdx/graphics/g3d/Model.java | 4 ++-- gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java | 3 +++ .../com/badlogic/gdx/graphics/g3d/model/Animation.java | 16 +++++++++++++++- .../badlogic/gdx/graphics/g3d/model/MorphAnimation.java | 5 ----- .../g3d/model/{BoneAnimation.java => NodeAnimation.java} | 6 +++--- .../g3d/model/{BoneKeyframe.java => NodeKeyframe.java} | 4 ++-- 9 files changed, 32 insertions(+), 18 deletions(-) delete mode 100644 gdx/src/com/badlogic/gdx/graphics/g3d/model/MorphAnimation.java rename gdx/src/com/badlogic/gdx/graphics/g3d/model/{BoneAnimation.java => NodeAnimation.java} (74%) rename gdx/src/com/badlogic/gdx/graphics/g3d/model/{BoneKeyframe.java => NodeKeyframe.java} (92%) diff --git a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java index 918c06124..742301d82 100644 --- a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java +++ b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/GdxInvadersDesktop.java @@ -23,7 +23,7 @@ public class GdxInvadersDesktop { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Gdx Invaders"; config.vSyncEnabled = true; - config.useGL20 = false; + config.useGL20 = true; new LwjglApplication(new GdxInvaders(), config); } } diff --git a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/Renderer.java b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/Renderer.java index 8dfdd1680..82d119e5a 100644 --- a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/Renderer.java +++ b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/Renderer.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL10; +import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GLCommon; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.PerspectiveCamera; diff --git a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/simulation/Simulation.java b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/simulation/Simulation.java index 527881934..17d71a9fe 100644 --- a/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/simulation/Simulation.java +++ b/demos/invaders/gdx-invaders/src/com/badlogic/gdxinvaders/simulation/Simulation.java @@ -80,7 +80,7 @@ public class Simulation implements Disposable { shipModel.materials.get(0).add(TextureAttribute.createDiffuse(shipTexture)); invaderModel.materials.get(0).add(TextureAttribute.createDiffuse(invaderTexture)); - blockModel.materials.get(0).add(ColorAttribute.createDiffuse(0, 0, 1, 0.5f)); + ((ColorAttribute)blockModel.materials.get(0).get(ColorAttribute.Diffuse)).color.set(0, 0, 1, 0.5f); blockModel.materials.get(0).add(new BlendingAttribute(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA)); shotModel.materials.get(0).add(ColorAttribute.createDiffuse(1, 1, 0, 1f)); @@ -139,6 +139,7 @@ public class Simulation implements Disposable { TextureAttribute.createDiffuse(explosionTexture))); ship = new Ship(shipModel); + ship.transform.rotate(0, 1, 0, 180); for (int row = 0; row < 4; row++) { for (int column = 0; column < 8; column++) { @@ -231,10 +232,10 @@ public class Simulation implements Disposable { removedShots.clear(); if (!ship.isExploding) { + ship.transform.getTranslation(tmpV1); for (int i = 0; i < shots.size(); i++) { Shot shot = shots.get(i); if (!shot.isInvaderShot) continue; - ship.transform.getTranslation(tmpV1); shot.transform.getTranslation(tmpV2); if (tmpV1.dst(tmpV2) < Ship.SHIP_RADIUS) { removedShots.add(shot); @@ -251,10 +252,10 @@ public class Simulation implements Disposable { shots.remove(removedShots.get(i)); } + ship.transform.getTranslation(tmpV2); for (int i = 0; i < invaders.size(); i++) { Invader invader = invaders.get(i); invader.transform.getTranslation(tmpV1); - ship.transform.getTranslation(tmpV2); if (tmpV1.dst(tmpV2) < Ship.SHIP_RADIUS) { ship.lives--; invaders.remove(invader); @@ -272,11 +273,11 @@ public class Simulation implements Disposable { for (int i = 0; i < shots.size(); i++) { Shot shot = shots.get(i); + shot.transform.getTranslation(tmpV2); for (int j = 0; j < blocks.size(); j++) { Block block = blocks.get(j); block.transform.getTranslation(tmpV1); - shot.transform.getTranslation(tmpV2); if (tmpV1.dst(tmpV2) < Block.BLOCK_RADIUS) { removedShots.add(shot); shot.hasLeftField = true; diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/Model.java b/gdx/src/com/badlogic/gdx/graphics/g3d/Model.java index 8ee5902ca..d4fa8141b 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/Model.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/Model.java @@ -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!

* - * 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 * diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java b/gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java index 9adb36dca..cfdd348ab 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/ModelInstance.java @@ -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 materials = new Array(); /** a copy of the nodes of the original model, referencing the copied materials in their {@link MeshPartMaterial} instances **/ public final Array nodes = new Array(); + /** a copy of the animations of the original model **/ + public final Array animations = new Array(); /** Constructs a new ModelInstance with all nodes and materials of the given model. */ public ModelInstance(Model model) { diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/model/Animation.java b/gdx/src/com/badlogic/gdx/graphics/g3d/model/Animation.java index b4d67d5f5..1bfe37a5d 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/model/Animation.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/model/Animation.java @@ -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 boneAnimations = new Array(); + /** the duration in seconds **/ + public float duration; + /** the animation curves for individual nodes **/ + public Array nodeAnimations = new Array(); } 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 index 71718745d..000000000 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/model/MorphAnimation.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.badlogic.gdx.graphics.g3d.model; - -public class MorphAnimation { - -} diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneAnimation.java b/gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeAnimation.java similarity index 74% rename from gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneAnimation.java rename to gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeAnimation.java index c0f047d25..a77bb520a 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneAnimation.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeAnimation.java @@ -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 keyframes = new Array(); + public Array keyframes = new Array(); } diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneKeyframe.java b/gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeKeyframe.java similarity index 92% rename from gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneKeyframe.java rename to gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeKeyframe.java index 097b1ea79..f6b28f094 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/model/BoneKeyframe.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/model/NodeKeyframe.java @@ -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 **/ -- 2.11.0