Search in sources :

Example 36 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project bladecoder-adventure-engine by bladecoder.

the class CanvasDrawer method drawBBoxActors.

public void drawBBoxActors(Scene scn) {
    drawer.setProjectionMatrix(camera.combined);
    drawer.setTransformMatrix(new Matrix4());
    drawer.begin(ShapeType.Line);
    for (BaseActor a : scn.getActors().values()) {
        Polygon p = a.getBBox();
        if (p == null) {
            EditorLogger.error("ERROR DRAWING BBOX FOR: " + a.getId());
        }
        if (a instanceof ObstacleActor) {
            drawer.setColor(Scene.OBSTACLE_COLOR);
            drawer.polygon(p.getTransformedVertices());
        } else if (a instanceof InteractiveActor) {
            InteractiveActor iActor = (InteractiveActor) a;
            if (!scn.getLayer(iActor.getLayer()).isVisible())
                continue;
            drawer.setColor(Scene.ACTOR_BBOX_COLOR);
            if (p.getTransformedVertices().length > 2)
                drawer.polygon(p.getTransformedVertices());
        } else if (a instanceof AnchorActor) {
            drawer.setColor(Scene.ANCHOR_COLOR);
            drawer.line(p.getX() - Scene.ANCHOR_RADIUS, p.getY(), p.getX() + Scene.ANCHOR_RADIUS, p.getY());
            drawer.line(p.getX(), p.getY() - Scene.ANCHOR_RADIUS, p.getX(), p.getY() + Scene.ANCHOR_RADIUS);
        }
    // drawer.rect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    }
    drawer.end();
}
Also used : AnchorActor(com.bladecoder.engine.model.AnchorActor) ObstacleActor(com.bladecoder.engine.model.ObstacleActor) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) Polygon(com.badlogic.gdx.math.Polygon) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 37 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project bladecoder-adventure-engine by bladecoder.

the class CanvasDrawer method drawBGBounds.

public void drawBGBounds() {
    // Gdx.gl20.glEnable(GL20.GL_BLEND);
    // Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    drawer.setProjectionMatrix(camera.combined);
    drawer.setTransformMatrix(new Matrix4());
    drawer.begin(ShapeRenderer.ShapeType.Line);
    drawer.setColor(Color.MAGENTA);
    drawer.rect(0, 0, World.getInstance().getWidth(), World.getInstance().getHeight());
    drawer.end();
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Example 38 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project bladecoder-adventure-engine by bladecoder.

the class SpineRenderer method draw.

@Override
public void draw(SpriteBatch batch, float x, float y, float scale, float rotation, Color tint) {
    SkeletonCacheEntry cs = (SkeletonCacheEntry) currentSource;
    if (cs != null && cs.skeleton != null) {
        Matrix4 tm = batch.getTransformMatrix();
        tmp.set(tm);
        float originX = cs.skeleton.getRootBone().getX();
        float originY = cs.skeleton.getRootBone().getY();
        tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scale, scale, 1).translate(originX, originY, 0);
        // cs.skeleton.setX(x / scale);
        // cs.skeleton.setY(y / scale);
        batch.setTransformMatrix(tm);
        if (tint != null)
            cs.skeleton.setColor(tint);
        renderer.draw(batch, cs.skeleton);
        if (tint != null)
            batch.setColor(Color.WHITE);
        batch.setTransformMatrix(tmp);
    } else {
        float dx = getAlignDx(getWidth(), orgAlign);
        float dy = getAlignDy(getHeight(), orgAlign);
        RectangleRenderer.draw(batch, x + dx * scale, y + dy * scale, getWidth() * scale, getHeight() * scale, Color.RED);
    }
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Example 39 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project bladecoder-adventure-engine by bladecoder.

the class TextRenderer method draw.

@Override
public void draw(SpriteBatch batch, float x, float y, float scale, float rotation, Color tint) {
    float dx = getAlignDx(getWidth(), orgAlign);
    float dy = getAlignDy(getHeight(), orgAlign);
    if (font != null && text != null) {
        if (tint != null && !tint.equals(color)) {
            color.set(tint);
            String tt = text;
            if (tt.charAt(0) == I18N.PREFIX)
                tt = I18N.getString(tt.substring(1));
            if (editorTranslatedText != null)
                tt = editorTranslatedText;
            layout.setText(font, tt, color, 0, textAlign, false);
        }
        Matrix4 tm = batch.getTransformMatrix();
        tmp.set(tm);
        float originX = dx;
        float originY = layout.height + dy;
        if (textAlign == Align.right)
            originX += getWidth();
        else if (textAlign == Align.center)
            originX += getWidth() / 2;
        tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scale, scale, 1).translate(originX, originY, 0);
        batch.setTransformMatrix(tm);
        font.draw(batch, layout, 0, 0);
        batch.setTransformMatrix(tmp);
    } else {
        RectangleRenderer.draw(batch, x + dx * scale, y + dy * scale, getWidth() * scale, getHeight() * scale, Color.RED);
    }
}
Also used : Matrix4(com.badlogic.gdx.math.Matrix4)

Example 40 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project Eidolons by IDemiurge.

the class ChainedStage method draw.

@Override
public void draw() {
    final Matrix4 combined = getCamera().combined.cpy();
    getCamera().update();
    final Group root = getRoot();
    if (!root.isVisible())
        return;
    combined.setToOrtho2D(0, 0, GdxMaster.getWidth(), GdxMaster.getHeight());
    Batch batch = this.getBatch();
    batch.setProjectionMatrix(combined);
    batch.begin();
    root.draw(batch, 1);
    batch.end();
}
Also used : Group(com.badlogic.gdx.scenes.scene2d.Group) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Batch(com.badlogic.gdx.graphics.g2d.Batch) Matrix4(com.badlogic.gdx.math.Matrix4)

Aggregations

Matrix4 (com.badlogic.gdx.math.Matrix4)40 Vector3 (com.badlogic.gdx.math.Vector3)10 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)6 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 Batch (com.badlogic.gdx.graphics.g2d.Batch)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 Group (com.badlogic.gdx.scenes.scene2d.Group)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2