shipTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);\r
final Texture invaderTexture = new Texture(Gdx.files.internal("data/invader.png"), Format.RGB565, true);\r
invaderTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);\r
- shipModel.materials.get(0).add(TextureAttribute.createDiffuse(shipTexture));\r
- invaderModel.materials.get(0).add(TextureAttribute.createDiffuse(invaderTexture));\r
+ shipModel.materials.get(0).set(TextureAttribute.createDiffuse(shipTexture));\r
+ invaderModel.materials.get(0).set(TextureAttribute.createDiffuse(invaderTexture));\r
\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
+ blockModel.materials.get(0).set(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
+ shotModel.materials.get(0).set(ColorAttribute.createDiffuse(1, 1, 0, 1f));\r
\r
final Texture explosionTexture = new Texture(Gdx.files.internal("data/explode.png"), Format.RGBA4444, true);\r
explosionTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);\r
Material result = new Material();
result.id = mtl.id;
if (mtl.ambient != null)
- result.add(new ColorAttribute(ColorAttribute.Ambient, mtl.ambient));
+ result.set(new ColorAttribute(ColorAttribute.Ambient, mtl.ambient));
if (mtl.diffuse != null)
- result.add(new ColorAttribute(ColorAttribute.Diffuse, mtl.diffuse));
+ result.set(new ColorAttribute(ColorAttribute.Diffuse, mtl.diffuse));
if (mtl.specular != null)
- result.add(new ColorAttribute(ColorAttribute.Specular, mtl.specular));
+ result.set(new ColorAttribute(ColorAttribute.Specular, mtl.specular));
if (mtl.emissive != null)
- result.add(new ColorAttribute(ColorAttribute.Emissive, mtl.emissive));
+ result.set(new ColorAttribute(ColorAttribute.Emissive, mtl.emissive));
if (mtl.shininess > 0f)
- result.add(new FloatAttribute(FloatAttribute.Shininess, mtl.shininess));
+ result.set(new FloatAttribute(FloatAttribute.Shininess, mtl.shininess));
ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
descriptor.magFilter = GL20.GL_LINEAR;
descriptor.uWrap = GL20.GL_CLAMP_TO_EDGE;
descriptor.vWrap = GL20.GL_CLAMP_TO_EDGE;
- result.add(new TextureAttribute(TextureAttribute.Diffuse, descriptor));
+ result.set(new TextureAttribute(TextureAttribute.Diffuse, descriptor));
}
}
/** Create a material with the specified attributes */
public Material(final Attribute... attributes) {
this();
- add(attributes);
+ set(attributes);
}
/** Create a material with the specified attributes */
public Material(final String id, final Attribute... attributes) {
this(id);
- add(attributes);
+ set(attributes);
}
/** Create a material with the specified attributes */
public Material(final Array<Attribute> attributes) {
this();
- add(attributes);
+ set(attributes);
}
/** Create a material with the specified attributes */
public Material(final String id, final Array<Attribute> attributes) {
this(id);
- add(attributes);
+ set(attributes);
}
/** Create a material which is an exact copy of the specified material */
public Material(final Material copyFrom) {
public Material(final String id, final Material copyFrom) {
this(id);
for (Attribute attr : copyFrom)
- add(attr.copy());
+ set(attr.copy());
}
private final void enable(final long mask) {
/** Add a attribute to this material.
* If the material already contains an attribute of the same type it is overwritten. */
- public final void add(final Attribute attribute) {
+ public final void set(final Attribute attribute) {
final int idx = indexOf(attribute.type);
if (idx < 0) {
enable(attribute.type);
/** Add an array of attributes to this material.
* If the material already contains an attribute of the same type it is overwritten. */
- public final void add(final Attribute... attributes) {
+ public final void set(final Attribute... attributes) {
for (final Attribute attr : attributes)
- add(attr);
+ set(attr);
}
/** Add an array of attributes to this material.
* If the material already contains an attribute of the same type it is overwritten. */
- public final void add(final Array<Attribute> attributes) {
+ public final void set(final Array<Attribute> attributes) {
for (final Attribute attr : attributes)
- add(attr);
+ set(attr);
}
/** Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID);
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.model.MeshPart;
import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.VertexInfo;
+import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;
private float uMin = 0, uMax = 1, vMin = 0, vMax = 1;
private float[] vertex;
- /** Begin building a mesh */
+ /** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public static VertexAttributes createAttributes(long usage) {
+ final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
+ if ((usage & Usage.Position) == Usage.Position)
+ attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
+ if ((usage & Usage.Color) == Usage.Color)
+ attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
+ if ((usage & Usage.Normal) == Usage.Normal)
+ attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
+ if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
+ attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE+"0"));
+ final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
+ for (int i = 0; i < attributes.length; i++)
+ attributes[i] = attrs.get(i);
+ return new VertexAttributes(attributes);
+ }
+
+ /** Begin building a mesh. Call {@link #part(String, int)} to start a {@link MeshPart}.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public void begin(final long attributes) {
+ begin(createAttributes(attributes), 0);
+ }
+
+ /** Begin building a mesh. Call {@link #part(String, int)} to start a {@link MeshPart}. */
public void begin(final VertexAttributes attributes) {
begin(attributes, 0);
}
+
+ /** Begin building a mesh.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public void begin(final long attributes, int primitiveType) {
+ begin(createAttributes(attributes), primitiveType);
+ }
+
/** Begin building a mesh */
public void begin(final VertexAttributes attributes, int primitiveType) {
if (this.attributes != null)
/** Creates a new MeshPart within the current Node.
* The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the model.
* @return The {@link MeshPartBuilder} you can use to build the MeshPart. */
- public MeshPartBuilder part(final String id, int primitiveType, final VertexAttributes attributes, final Material material) {
+ private MeshPartBuilder part(final String id, int primitiveType, final VertexAttributes attributes, final Material material) {
final MeshBuilder builder = getBuilder(attributes);
part(builder.part(id, primitiveType), material);
return builder;
}
+ /** Creates a new MeshPart within the current Node.
+ * The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported.
+ * @return The {@link MeshPartBuilder} you can use to build the MeshPart. */
+ public MeshPartBuilder part(final String id, int primitiveType, final long attributes, final Material material) {
+ return part(id, primitiveType, MeshBuilder.createAttributes(attributes), material);
+ }
+
/** Convenience method to create a model with a single node containing a box shape.
* The resources the Material might contain are not managed,
- * use {@link Model#manageDisposable(Disposable)} to add those to the model. */
- public Model createBox(float width, float height, float depth, final Material material, final VertexAttributes attributes) {
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createBox(float width, float height, float depth, final Material material, final long attributes) {
+ return createBox(width, height, depth, GL10.GL_TRIANGLES, material, attributes);
+ }
+
+ /** Convenience method to create a model with a single node containing a box shape.
+ * The resources the Material might contain are not managed,
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createBox(float width, float height, float depth, int primitiveType, final Material material, final long attributes) {
begin();
- part("box", GL10.GL_TRIANGLES, attributes, material).box(width, height, depth);
+ part("box", primitiveType, attributes, material).box(width, height, depth);
return end();
}
/** Convenience method to create a model with a single node containing a rectangle shape.
* The resources the Material might contain are not managed,
- * use {@link Model#manageDisposable(Disposable)} to add those to the model. */
- public Model createRect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ, final Material material, final VertexAttributes attributes) {
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createRect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ, final Material material, final long attributes) {
+ return createRect(x00, y00, z00, x10, y10, z10, x11, y11, z11, x01, y01, z01, normalX, normalY, normalZ, GL10.GL_TRIANGLES, material, attributes);
+ }
+
+ /** Convenience method to create a model with a single node containing a rectangle shape.
+ * The resources the Material might contain are not managed,
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createRect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ, int primitiveType, final Material material, final long attributes) {
begin();
- part("rect", GL10.GL_TRIANGLES, attributes, material).rect(x00, y00, z00, x10, y10, z10, x11, y11, z11, x01, y01, z01, normalX, normalY, normalZ);
+ part("rect", primitiveType, attributes, material).rect(x00, y00, z00, x10, y10, z10, x11, y11, z11, x01, y01, z01, normalX, normalY, normalZ);
return end();
}
/** Convenience method to create a model with a single node containing a cylinder shape.
* The resources the Material might contain are not managed,
- * use {@link Model#manageDisposable(Disposable)} to add those to the model. */
- public Model createCylinder(float width, float height, float depth, int divisions, final Material material, final VertexAttributes attributes) {
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createCylinder(float width, float height, float depth, int divisions, final Material material, final long attributes) {
+ return createCylinder(width, height, depth, divisions, GL10.GL_TRIANGLES, material, attributes);
+ }
+
+ /** Convenience method to create a model with a single node containing a cylinder shape.
+ * The resources the Material might contain are not managed,
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createCylinder(float width, float height, float depth, int divisions, int primitiveType, final Material material, final long attributes) {
begin();
- part("cylinder", GL10.GL_TRIANGLES, attributes, material).cylinder(width, height, depth, divisions);
+ part("cylinder", primitiveType, attributes, material).cylinder(width, height, depth, divisions);
return end();
}
/** Convenience method to create a model with a single node containing a cone shape.
* The resources the Material might contain are not managed,
- * use {@link Model#manageDisposable(Disposable)} to add those to the model. */
- public Model createCone(float width, float height, float depth, int divisions, final Material material, final VertexAttributes attributes) {
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createCone(float width, float height, float depth, int divisions, final Material material, final long attributes) {
+ return createCone(width, height, depth, divisions, GL10.GL_TRIANGLES, material, attributes);
+ }
+
+ /** Convenience method to create a model with a single node containing a cone shape.
+ * The resources the Material might contain are not managed,
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createCone(float width, float height, float depth, int divisions, int primitiveType, final Material material, final long attributes) {
begin();
- part("cone", GL10.GL_TRIANGLES, attributes, material).cone(width, height, depth, divisions);
+ part("cone", primitiveType, attributes, material).cone(width, height, depth, divisions);
return end();
}
+
+ /** Convenience method to create a model with a single node containing a sphere shape.
+ * The resources the Material might contain are not managed,
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createSphere(float width, float height, float depth, int divisionsU, int divisionsV, final Material material, final long attributes) {
+ return createSphere(width, height, depth, divisionsU, divisionsV, GL10.GL_TRIANGLES, material, attributes);
+ }
/** Convenience method to create a model with a single node containing a sphere shape.
* The resources the Material might contain are not managed,
- * use {@link Model#manageDisposable(Disposable)} to add those to the model. */
- public Model createSphere(float width, float height, float depth, int divisionsU, int divisionsV, final Material material, final VertexAttributes attributes) {
+ * use {@link Model#manageDisposable(Disposable)} to add those to the model.
+ * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage},
+ * only Position, Color, Normal and TextureCoordinates is supported. */
+ public Model createSphere(float width, float height, float depth, int divisionsU, int divisionsV, int primitiveType, final Material material, final long attributes) {
begin();
- part("cylinder", GL10.GL_TRIANGLES, attributes, material).sphere(width, height, depth, divisionsU, divisionsV);
+ part("cylinder", primitiveType, attributes, material).sphere(width, height, depth, divisionsU, divisionsV);
return end();
}
@Override\r
public void create () {\r
ModelBuilder builder = new ModelBuilder();\r
- sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));\r
+ sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), Usage.Position | Usage.Normal);\r
// cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));\r
\r
texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);\r
ObjLoader objLoader = new ObjLoader();\r
mesh = objLoader.loadObj(Gdx.files.internal("data/cube.obj"));\r
- mesh.materials.get(0).add(new TextureAttribute(TextureAttribute.Diffuse, texture));\r
+ mesh.materials.get(0).set(new TextureAttribute(TextureAttribute.Diffuse, texture));\r
modelInstance = new ModelInstance(mesh);\r
modelBatch = new ModelBatch();\r
\r
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
if(!material.has(TextureAttribute.Diffuse))
- material.add(textureAttribute);
+ material.set(textureAttribute);
else if(!material.has(ColorAttribute.Diffuse))
- material.add(colorAttribute);
+ material.set(colorAttribute);
else if(!material.has(BlendingAttribute.Type))
- material.add(blendingAttribute);
+ material.set(blendingAttribute);
else
material.clear();
VP_HEIGHT = Gdx.graphics.getHeight() - 4 * BORDER;\r
ObjLoader objLoader = new ObjLoader();\r
sphere = objLoader.loadObj(Gdx.files.internal("data/sphere.obj"));\r
- sphere.materials.get(0).add(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));\r
+ sphere.materials.get(0).set(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));\r
cam = new PerspectiveCamera(45, VP_WIDTH, VP_HEIGHT);\r
// cam = new OrthographicCamera(10, 10);\r
cam.far = 200;\r
public void create () {\r
ObjLoader objLoader = new ObjLoader();\r
sphere = objLoader.loadObj(Gdx.files.internal("data/sphere.obj"));\r
- sphere.materials.get(0).add(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));\r
+ sphere.materials.get(0).set(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE));\r
cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
cam.far = 200;\r
Random rand = new Random();\r
// Create some simple meshes
final Model groundModel = modelBuilder.createRect(20f, 0f, -20f, -20f, 0f, -20f, -20f, 0f, 20f, 20f, 0f, 20f, 0, 1, 0,
new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(16f)),
- new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));
+ Usage.Position | Usage.Normal);
final Model boxModel = modelBuilder.createBox(1f, 1f, 1f,
new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f)),
- new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));
+ Usage.Position | Usage.Normal);
// Add the constructors
world.addConstructor("ground", new BulletConstructor(groundModel, 0f)); // mass = 0: static body
package com.badlogic.gdx.tests.bullet;
import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
final Material material = new Material(TextureAttribute.createDiffuse(texture), ColorAttribute.createSpecular(1,1,1,1), FloatAttribute.createShininess(8f));
- final VertexAttributes attributes = new VertexAttributes(
- new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
- new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE),
- new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE+"0"));
+ final long attributes = Usage.Position | Usage.Normal | Usage.TextureCoordinates;
final Model sphere = modelBuilder.createSphere(4f, 4f, 4f, 24, 24, material, attributes);
world.addConstructor("sphere", new BulletConstructor(sphere, 10f, new btSphereShape(2f)));
public void create () {
super.create();
- final Model barModel = modelBuilder.createBox(10f, 1f, 1f, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));
+ final Model barModel = modelBuilder.createBox(10f, 1f, 1f, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), Usage.Position | Usage.Normal);
world.addConstructor("bar", new BulletConstructor(barModel, 0f)); // mass = 0: static body
// Create the entities
final Model sceneModel = objLoader.loadObj(Gdx.files.internal("data/car.obj"));
sceneModel.materials.get(0).clear();
- sceneModel.materials.get(0).add(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
+ sceneModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE));
world.addConstructor("car", new BulletConstructor(sceneModel, 5f, createConvexHullShape(sceneModel)));
// Create the entities
final Model sphereModel = modelBuilder.createSphere(0.5f, 0.5f, 0.5f, 8, 8,
new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE)),
- new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));
+ Usage.Position | Usage.Normal);
final BulletConstructor sphereConstructor = new BulletConstructor(sphereModel, 0.25f, new btSphereShape(0.25f));
sphereConstructor.bodyInfo.setM_restitution(1f);
world.addConstructor("sphere", sphereConstructor);
protected Model createCapsuleModel(float radius, float height) {
final float hh = radius + 0.5f * height;
- // return ModelBuilder
return modelBuilder.createCylinder(radius * 2, hh * 2f, radius * 2f, 16,
new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE)),
- new VertexAttributes(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)));
- // return ModelBuilder.createBox(radius*2f, hh*2f, radius*2f, new NewMaterial(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)));
+ Usage.Position | Usage.Normal);
}
}
private void createAxes() {
ModelBuilder modelBuilder = new ModelBuilder();
modelBuilder.begin();
- MeshPartBuilder builder = modelBuilder.part("grid", GL10.GL_LINES, new VertexAttributes(
- new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
- new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE)), new Material());
+ MeshPartBuilder builder = modelBuilder.part("grid", GL10.GL_LINES, Usage.Position | Usage.Color, new Material());
builder.setColor(Color.LIGHT_GRAY);
for (float t = GRID_MIN; t <= GRID_MAX; t+=GRID_STEP) {
builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
}
- builder = modelBuilder.part("axes", GL10.GL_LINES, new VertexAttributes(
- new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
- new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE)), new Material());
+ builder = modelBuilder.part("axes", GL10.GL_LINES, Usage.Position | Usage.Color, new Material());
builder.setColor(Color.RED);
builder.line(0, 0, 0, 100, 0, 0);
builder.setColor(Color.GREEN);