Search in sources :

Example 21 with Matrix4

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);
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 22 with Matrix4

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);
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) Model(com.badlogic.gdx.graphics.g3d.Model) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 23 with Matrix4

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);
            }
        }
    }
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Example 24 with Matrix4

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();
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Example 25 with Matrix4

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);
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Aggregations

Matrix4 (com.badlogic.gdx.math.Matrix4)31 Vector3 (com.badlogic.gdx.math.Vector3)10 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)5 Texture (com.badlogic.gdx.graphics.Texture)4 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)3 Material (com.badlogic.gdx.graphics.g3d.Material)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 Quaternion (com.badlogic.gdx.math.Quaternion)3 JsonValue (com.badlogic.gdx.utils.JsonValue)3 InputAdapter (com.badlogic.gdx.InputAdapter)2 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2 Environment (com.badlogic.gdx.graphics.g3d.Environment)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)2 com.badlogic.gdx.physics.bullet.collision.btBvhTriangleMeshShape (com.badlogic.gdx.physics.bullet.collision.btBvhTriangleMeshShape)2 com.badlogic.gdx.physics.bullet.collision.btSphereShape (com.badlogic.gdx.physics.bullet.collision.btSphereShape)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 NodeComponent (io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)2 ArrayList (java.util.ArrayList)2