Example usage for com.badlogic.gdx.graphics.g3d.utils ModelBuilder createArrow

List of usage examples for com.badlogic.gdx.graphics.g3d.utils ModelBuilder createArrow

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.utils ModelBuilder createArrow.

Prototype

public Model createArrow(Vector3 from, Vector3 to, Material material, long attributes) 

Source Link

Document

Convenience method to create a model with an arrow.

Usage

From source file:com.mygdx.game.utilities.ModelFactory.java

License:Apache License

public static Model buildCompassModel() {
    float compassScale = 5;
    ModelBuilder modelBuilder = new ModelBuilder();
    Model arrow = modelBuilder.createArrow(Vector3.Zero, Vector3.Y.cpy().scl(compassScale), null,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
    modelBuilder.begin();//from  w w w  . j ava  2 s. c  o m

    Mesh zArrow = arrow.meshes.first().copy(false);
    zArrow.transform(new Matrix4().rotate(Vector3.X, 90));
    modelBuilder.part("part1", zArrow, GL20.GL_TRIANGLES,
            new Material(ColorAttribute.createDiffuse(Color.BLUE)));

    modelBuilder.node();
    Mesh yArrow = arrow.meshes.first().copy(false);
    modelBuilder.part("part2", yArrow, GL20.GL_TRIANGLES,
            new Material(ColorAttribute.createDiffuse(Color.GREEN)));

    modelBuilder.node();
    Mesh xArrow = arrow.meshes.first().copy(false);
    xArrow.transform(new Matrix4().rotate(Vector3.Z, -90));
    modelBuilder.part("part3", xArrow, GL20.GL_TRIANGLES,
            new Material(ColorAttribute.createDiffuse(Color.RED)));

    arrow.dispose();
    return modelBuilder.end();
}