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();
}
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();
}
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);
}
}
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);
}
}
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();
}
Aggregations