1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| import com.game.*; import org.lwjgl.glfw.GLFW; import org.lwjgl.system.MemoryUtil;
import java.nio.FloatBuffer;
import static org.lwjgl.opengl.GL30.*;
public class TestLogic implements ILogic {
Entity entity;
@Override public void init() { float[] vertices = new float[] { -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, };
float[] colors = new float[]{ 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, }; int[] indices = new int[] { 0, 1, 3, 3, 1, 2, 4, 0, 3, 5, 4, 3, 3, 2, 7, 5, 3, 7, 6, 1, 0, 6, 0, 4, 2, 1, 6, 2, 6, 7, 7, 6, 4, 7, 4, 5, };
Mesh mesh = new Mesh(vertices, colors, indices); entity = new Entity(mesh); entity.setPosition(0, 0, -2); Engine.scene.addEntity(entity); }
@Override public void update() { float rotation = entity.getRotation().x + 1.5f; if ( rotation > 360 ) { rotation = 0; } entity.setRotation(rotation, rotation, rotation); } [...] }
|