Search in sources :

Example 6 with Vector3f

use of org.terasology.math.geom.Vector3f in project Terasology by MovingBlocks.

the class TessellatorHelper method addGUIQuadMesh.

public static void addGUIQuadMesh(Tessellator tessellator, Vector4f color, float sizeX, float sizeY) {
    tessellator.resetParams();
    tessellator.setColor(new Vector4f(color.x, color.y, color.z, color.w));
    tessellator.setUseLighting(false);
    tessellator.setUseNormals(false);
    tessellator.addPoly(new Vector3f[] { new Vector3f(0, 0, 0), new Vector3f(sizeX, 0, 0), new Vector3f(sizeX, sizeY, 0), new Vector3f(0, sizeY, 0) }, new Vector2f[] { new Vector2f(0, 0), new Vector2f(1, 0), new Vector2f(1, 1), new Vector2f(0, 1) });
    tessellator.setUseLighting(true);
    tessellator.setUseNormals(true);
}
Also used : Vector4f(org.terasology.math.geom.Vector4f) Vector2f(org.terasology.math.geom.Vector2f) Vector3f(org.terasology.math.geom.Vector3f)

Example 7 with Vector3f

use of org.terasology.math.geom.Vector3f in project Terasology by MovingBlocks.

the class RenderableWorldImpl method squaredDistanceToCamera.

private static float squaredDistanceToCamera(RenderableChunk chunk, Vector3f cameraPosition) {
    // For performance reasons, to avoid instantiating too many vectors in a frequently called method,
    // comments are in use instead of appropriately named vectors.
    // chunk position in chunk coordinates
    Vector3f result = chunk.getPosition().toVector3f();
    // chunk center in chunk coordinates
    result.add(CHUNK_CENTER_OFFSET);
    // chunk center in world coordinates
    result.x *= ChunkConstants.SIZE_X;
    result.y *= ChunkConstants.SIZE_Y;
    result.z *= ChunkConstants.SIZE_Z;
    // camera to chunk vector
    result.sub(cameraPosition);
    return result.lengthSquared();
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 8 with Vector3f

use of org.terasology.math.geom.Vector3f in project Terasology by MovingBlocks.

the class BlockSelectionRenderer method renderMark.

public void renderMark(Vector3i blockPos) {
    Vector3f cameraPos = getCameraPosition();
    glPushMatrix();
    glTranslated(blockPos.x - cameraPos.x, blockPos.y - cameraPos.y, blockPos.z - cameraPos.z);
    glMatrixMode(GL_MODELVIEW);
    overlayMesh.render();
    glPopMatrix();
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 9 with Vector3f

use of org.terasology.math.geom.Vector3f in project Terasology by MovingBlocks.

the class BlockSelectionRenderer method renderMark2.

public void renderMark2(Vector3i blockPos) {
    Vector3f cameraPos = getCameraPosition();
    glPushMatrix();
    glTranslated(blockPos.x - cameraPos.x, blockPos.y - cameraPos.y, blockPos.z - cameraPos.z);
    glMatrixMode(GL_MODELVIEW);
    overlayMesh2.render();
    glPopMatrix();
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 10 with Vector3f

use of org.terasology.math.geom.Vector3f in project Terasology by MovingBlocks.

the class TelemetrySystem method recordDistanceTraveled.

private void recordDistanceTraveled() {
    Vector3f position = localPlayer.getPosition();
    float distanceMoved = position.distance(previousPos);
    gamePlayStatsComponent.distanceTraveled += distanceMoved;
    previousPos = position;
    localPlayer.getCharacterEntity().addOrSaveComponent(gamePlayStatsComponent);
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Aggregations

Vector3f (org.terasology.math.geom.Vector3f)194 LocationComponent (org.terasology.logic.location.LocationComponent)45 EntityRef (org.terasology.entitySystem.entity.EntityRef)44 Quat4f (org.terasology.math.geom.Quat4f)33 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)26 Vector3i (org.terasology.math.geom.Vector3i)21 Test (org.junit.Test)20 ClientComponent (org.terasology.network.ClientComponent)15 Command (org.terasology.logic.console.commandSystem.annotations.Command)14 Matrix4f (org.terasology.math.geom.Matrix4f)13 BaseVector3f (org.terasology.math.geom.BaseVector3f)9 Block (org.terasology.world.block.Block)9 Vector2f (org.terasology.math.geom.Vector2f)8 HitResult (org.terasology.physics.HitResult)8 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)7 IOException (java.io.IOException)6 FloatBuffer (java.nio.FloatBuffer)6 EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)5 AABB (org.terasology.math.AABB)5 ChunkMesh (org.terasology.rendering.primitives.ChunkMesh)5