use of com.badlogic.gdx.math.Matrix4 in project libgdx by libgdx.
the class AtlasIssueTest method create.
public void create() {
batch = new SpriteBatch();
batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480));
atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
sprite = atlas.createSprite("map");
font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
Gdx.gl.glClearColor(0, 1, 0, 1);
}
use of com.badlogic.gdx.math.Matrix4 in project libgdx by libgdx.
the class Benchmark3DTest method onLoaded.
@Override
protected void onLoaded() {
if (currentlyLoading == null || currentlyLoading.length() == 0)
return;
final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
instance.transform = new Matrix4().idt();
instance.transform.setToTranslation(MathUtils.random(-10, 10), MathUtils.random(-10, 10), MathUtils.random(-10, 10));
instance.transform.rotate(Vector3.X, MathUtils.random(-180, 180));
instance.transform.rotate(Vector3.Y, MathUtils.random(-180, 180));
instance.transform.rotate(Vector3.Z, MathUtils.random(-180, 180));
instances.add(instance);
}
use of com.badlogic.gdx.math.Matrix4 in project libgdx by libgdx.
the class Bullet method getShapeParts.
public static void getShapeParts(final Node node, final boolean applyTransform, final Array<ShapePart> out, final int offset, final Pool<ShapePart> pool) {
final Matrix4 transform = applyTransform ? node.localTransform : idt;
if (node.parts.size > 0) {
ShapePart part = null;
for (int i = offset, n = out.size; i < n; i++) {
final ShapePart p = out.get(i);
if (Arrays.equals(p.transform.val, transform.val)) {
part = p;
break;
}
}
if (part == null) {
part = pool.obtain();
part.parts.clear();
part.transform.set(transform);
out.add(part);
}
for (int i = 0, n = node.parts.size; i < n; i++) part.parts.add(node.parts.get(i).meshPart);
}
if (node.hasChildren()) {
final boolean transformed = applyTransform && !Arrays.equals(transform.val, idt.val);
final int o = transformed ? out.size : offset;
getShapeParts(node.getChildren(), out, o, pool);
if (transformed) {
for (int i = o, n = out.size; i < n; i++) {
final ShapePart part = out.get(i);
tmpM.set(part.transform);
part.transform.set(transform).mul(tmpM);
}
}
}
}
use of com.badlogic.gdx.math.Matrix4 in project libgdx by libgdx.
the class IsometricTiledMapRenderer method init.
private void init() {
// create the isometric transform
isoTransform = new Matrix4();
isoTransform.idt();
// isoTransform.translate(0, 32, 0);
isoTransform.scale((float) (Math.sqrt(2.0) / 2.0), (float) (Math.sqrt(2.0) / 4.0), 1.0f);
isoTransform.rotate(0.0f, 0.0f, 1.0f, -45);
// ... and the inverse matrix
invIsotransform = new Matrix4(isoTransform);
invIsotransform.inv();
}
use of com.badlogic.gdx.math.Matrix4 in project libgdx by libgdx.
the class Stage method calculateScissors.
/** Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix.
* @see ScissorStack#calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle) */
public void calculateScissors(Rectangle localRect, Rectangle scissorRect) {
viewport.calculateScissors(batch.getTransformMatrix(), localRect, scissorRect);
Matrix4 transformMatrix;
if (debugShapes != null && debugShapes.isDrawing())
transformMatrix = debugShapes.getTransformMatrix();
else
transformMatrix = batch.getTransformMatrix();
viewport.calculateScissors(transformMatrix, localRect, scissorRect);
}
Aggregations