import com.badlogic.gdx.graphics.g2d.SpriteBatch;\r
import com.badlogic.gdx.graphics.g3d.ModelBatch;\r
import com.badlogic.gdx.graphics.g3d.RenderableProvider;\r
-import com.badlogic.gdx.graphics.g3d.test.TestShader;\r
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;\r
import com.badlogic.gdx.graphics.glutils.ShaderProgram;\r
import com.badlogic.gdx.math.Matrix3;\r
import com.badlogic.gdx.math.Matrix4;\r
try {\r
spriteBatch = new SpriteBatch();\r
modelBatch = new ModelBatch();\r
- TestShader.ignoreUnimplemented = true;\r
+ DefaultShader.ignoreUnimplemented = true;\r
\r
backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);\r
backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);\r
--- /dev/null
+package com.badlogic.gdx.graphics.g3d;
+
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.math.Vector3;
+
+public class Light {
+ public final Color color = new Color();
+ public Vector3 position;
+ public Vector3 direction;
+ public float angle = 0f;
+ public float power = 1f;
+
+ /** Create a new directional light */
+ public Light(final Color color, final Vector3 direction) {
+ this.color.set(color);
+ this.direction = new Vector3(direction);
+ }
+
+ /** Create a new directional light */
+ public Light(float r, float g, float b, float a, float x, float y, float z) {
+ this.color.set(r, g, b, a);
+ this.direction = new Vector3(x, y, z);
+ }
+
+ /** Create a new point light */
+ public Light(final Color color, final Vector3 position, final float power) {
+ this(color.r, color.g, color.b, color.a, position.x, position.y, position.z, power);
+ }
+
+ /** Create a new point light */
+ public Light(final float red, final float green, final float blue, final float alpha,
+ final float x, final float y, final float z, final float power) {
+ color.set(red, green, blue, alpha);
+ this.position = new Vector3(x, y, z);
+ this.power = power;
+ }
+
+ /** Create a new spot light */
+ public Light(final Color color, final Vector3 position, final Vector3 direction, final float angle, final float power) {
+ this.color.set(color);
+ this.position = new Vector3(position);
+ this.direction = new Vector3(direction);
+ this.angle = angle;
+ this.power = power;
+ }
+
+ public boolean equals(Light other) {
+ if (other == null) return false;
+ if (other == this) return true;
+ return color.equals(other.color) && position.equals(other.position) && power == other.power;
+ }
+
+ @Override
+ public boolean equals (Object arg0) {
+ if (arg0 == null) return false;
+ if (arg0 == this) return true;
+ if (!(arg0 instanceof Light)) return false;
+ return equals((Light)arg0);
+ }
+
+ public boolean isPointLight() {
+ return position != null && direction == null;
+ }
+
+ public boolean isDirectionalLight() {
+ return position == null && direction != null;
+ }
+
+ public boolean isSpotLight() {
+ return position != null && direction != null;
+ }
+}
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
-import com.badlogic.gdx.graphics.g3d.test.Light;
import com.badlogic.gdx.graphics.g3d.utils.DefaultRenderableSorter;
import com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider;
import com.badlogic.gdx.graphics.g3d.utils.DefaultTextureBinder;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.g3d.materials.Material;
import com.badlogic.gdx.graphics.g3d.model.Node;
-import com.badlogic.gdx.graphics.g3d.test.Light;
import com.badlogic.gdx.math.Matrix4;
/**
-package com.badlogic.gdx.graphics.g3d.test;
+package com.badlogic.gdx.graphics.g3d.shaders;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.Shader;
import com.badlogic.gdx.graphics.g3d.materials.BlendingAttribute;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.utils.GdxRuntimeException;
-public class TestShader implements Shader {
+public class DefaultShader implements Shader {
public final static String PROJECTION_TRANSFORM = "u_projTrans";
public final static String MODEL_TRANSFORM = "u_modelTrans";
public final static String NORMAL_TRANSFORM = "u_normalMatrix";
private static String defaultVertexShader = null;
public final static String getDefaultVertexShader() {
if (defaultVertexShader == null)
- defaultVertexShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/test/test.vertex.glsl").readString();
+ defaultVertexShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl").readString();
return defaultVertexShader;
}
private static String defaultFragmentShader = null;
public final static String getDefaultFragmentShader() {
if (defaultFragmentShader == null)
- defaultFragmentShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/test/test.fragment.glsl").readString();
+ defaultFragmentShader = Gdx.files.classpath("com/badlogic/gdx/graphics/g3d/shaders/default.fragment.glsl").readString();
return defaultFragmentShader;
}
protected RenderContext context;
protected long mask;
- public TestShader(final Material material, int maxLightsCount) {
+ public DefaultShader(final Material material, int maxLightsCount) {
this(getDefaultVertexShader(), getDefaultFragmentShader(), material, maxLightsCount);
}
- public TestShader(final long mask, int maxLightsCount) {
+ public DefaultShader(final long mask, int maxLightsCount) {
this(getDefaultVertexShader(), getDefaultFragmentShader(), mask, maxLightsCount);
}
- public TestShader(final String vertexShader, final String fragmentShader, final Material material, int maxLightsCount) {
+ public DefaultShader(final String vertexShader, final String fragmentShader, final Material material, int maxLightsCount) {
this(vertexShader, fragmentShader, material.getMask(), maxLightsCount);
}
- public TestShader(final String vertexShader, final String fragmentShader, final long mask, int maxLightsCount) {
+ public DefaultShader(final String vertexShader, final String fragmentShader, final long mask, int maxLightsCount) {
if (!Gdx.graphics.isGL20Available())
throw new GdxRuntimeException("This shader requires OpenGL ES 2.0");
@Override
public boolean equals (Object obj) {
- return (obj instanceof TestShader) ? equals((TestShader)obj) : false;
+ return (obj instanceof DefaultShader) ? equals((DefaultShader)obj) : false;
}
- public boolean equals (TestShader obj) {
+ public boolean equals (DefaultShader obj) {
return (obj == this);
}
-package com.badlogic.gdx.graphics.g3d.test;
+package com.badlogic.gdx.graphics.g3d.shaders;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.Shader;
import com.badlogic.gdx.graphics.g3d.materials.BlendingAttribute;
+++ /dev/null
-package com.badlogic.gdx.graphics.g3d.test;
-
-import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.math.Vector3;
-
-public class Light {
- public final Color color = new Color();
- public final Vector3 position = new Vector3();
- public float power = 1f;
-
- public Light(final Color color, final Vector3 position, final float power) {
- this(color.r, color.g, color.b, color.a, position.x, position.y, position.z, power);
- }
-
- public Light(final float red, final float green, final float blue, final float alpha,
- final float x, final float y, final float z, final float power) {
- color.set(red, green, blue, alpha);
- position.set(x, y, z);
- this.power = power;
- }
-
- public boolean equals(Light other) {
- if (other == null) return false;
- if (other == this) return true;
- return color.equals(other.color) && position.equals(other.position) && power == other.power;
- }
-
- @Override
- public boolean equals (Object arg0) {
- if (arg0 == null) return false;
- if (arg0 == this) return true;
- if (!(arg0 instanceof Light)) return false;
- return equals((Light)arg0);
- }
-}
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.Shader;
import com.badlogic.gdx.graphics.g3d.materials.Material;
-import com.badlogic.gdx.graphics.g3d.test.GLES10Shader;
-import com.badlogic.gdx.graphics.g3d.test.TestShader;
+import com.badlogic.gdx.graphics.g3d.shaders.GLES10Shader;
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;
import com.badlogic.gdx.utils.Array;
public class DefaultShaderProvider extends BaseShaderProvider {
protected Shader createShader(final Renderable renderable) {
Gdx.app.log("DefaultShaderProvider", "Creating new shader");
if (Gdx.graphics.isGL20Available())
- return new TestShader(renderable.material, renderable.lights == null ? -1 : maxLightsCount);
+ return new DefaultShader(renderable.material, renderable.lights == null ? -1 : maxLightsCount);
return new GLES10Shader(maxLightsCount);
}
}
import com.badlogic.gdx.graphics.g3d.ModelInstance;\r
import com.badlogic.gdx.graphics.g3d.materials.ColorAttribute;\r
import com.badlogic.gdx.graphics.g3d.materials.Material;\r
-import com.badlogic.gdx.graphics.g3d.test.TestShader;\r
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;\r
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;\r
import com.badlogic.gdx.graphics.glutils.ShaderProgram;\r
import com.badlogic.gdx.math.Vector3;\r
import com.badlogic.gdx.graphics.g3d.ModelBatch;\r
import com.badlogic.gdx.graphics.g3d.ModelInstance;\r
import com.badlogic.gdx.graphics.g3d.loader.ObjLoader;\r
-import com.badlogic.gdx.graphics.g3d.test.TestShader;\r
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;\r
import com.badlogic.gdx.graphics.glutils.FrameBuffer;\r
import com.badlogic.gdx.graphics.glutils.ShaderProgram;\r
import com.badlogic.gdx.math.Matrix4;\r
Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog());\r
}\r
\r
- TestShader.ignoreUnimplemented = true;\r
+ DefaultShader.ignoreUnimplemented = true;\r
ObjLoader objLoader = new ObjLoader();\r
scene = objLoader.loadObj(Gdx.files.internal("data/scene.obj"));\r
sceneInstance = new ModelInstance(scene);\r
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.loader.ObjLoader;
import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPart;
import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPartMaterial;
import com.badlogic.gdx.graphics.g3d.model.data.ModelNode;
-import com.badlogic.gdx.graphics.g3d.test.Light;
-import com.badlogic.gdx.graphics.g3d.test.TestShader;
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.math.Quaternion;
public void create () {
init();
modelBatch = new ModelBatch();
- TestShader.ignoreUnimplemented = true;
+ DefaultShader.ignoreUnimplemented = true;
world = createWorld();
world.performanceCounter = performanceCounter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
-import com.badlogic.gdx.graphics.g3d.test.Light;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
package com.badlogic.gdx.tests.bullet;
import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
-import com.badlogic.gdx.graphics.g3d.test.Light;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.WindowedMean;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.loader.JsonModelLoader;
import com.badlogic.gdx.graphics.g3d.loader.ObjLoader;
-import com.badlogic.gdx.graphics.g3d.test.Light;
-import com.badlogic.gdx.graphics.g3d.test.TestShader;
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;
import com.badlogic.gdx.graphics.g3d.utils.DefaultTextureBinder;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3;
@Override
public void create () {
- TestShader.ignoreUnimplemented = true;
+ DefaultShader.ignoreUnimplemented = true;
final JsonModelLoader loader = new JsonModelLoader();
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.PerspectiveCamera;
+import com.badlogic.gdx.graphics.g3d.Light;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.loader.JsonModelLoader;
-import com.badlogic.gdx.graphics.g3d.test.Light;
-import com.badlogic.gdx.graphics.g3d.test.TestShader;
+import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Matrix4;
model = new Model(loader.parseModel(Gdx.files.internal("data/g3d/cubes.g3dj")));
instance = new ModelInstance(model);
modelBatch = new ModelBatch();
- TestShader.ignoreUnimplemented = true;
+ DefaultShader.ignoreUnimplemented = true;
shapeRenderer = new ShapeRenderer();
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());