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
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
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
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
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
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
\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
* 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
*
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;
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) {
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>();
}
+++ /dev/null
-package com.badlogic.gdx.graphics.g3d.model;
-
-public class MorphAnimation {
-
-}
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>();
}
/**
* 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 **/