Search in sources :

Example 21 with Vector3f

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

the class Location method removeChild.

public static void removeChild(EntityRef parent, EntityRef child) {
    LocationComponent childLoc = child.getComponent(LocationComponent.class);
    LocationComponent parentLoc = parent.getComponent(LocationComponent.class);
    if (childLoc != null && parentLoc != null && childLoc.getParent().equals(parent)) {
        Vector3f oldWorldPos = childLoc.getWorldPosition();
        parentLoc.children.remove(child);
        childLoc.parent = EntityRef.NULL;
        childLoc.setWorldPosition(oldWorldPos);
        child.saveComponent(childLoc);
        parent.saveComponent(parentLoc);
    }
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 22 with Vector3f

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

the class LocationComponent method getWorldDirection.

public Vector3f getWorldDirection() {
    Vector3f result = Direction.FORWARD.getVector3f();
    getWorldRotation().rotate(result, result);
    return result;
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 23 with Vector3f

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

the class LocationComponent method getLocalDirection.

public Vector3f getLocalDirection() {
    Vector3f result = Direction.FORWARD.getVector3f();
    getLocalRotation().rotate(result, result);
    return result;
}
Also used : Vector3f(org.terasology.math.geom.Vector3f)

Example 24 with Vector3f

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

the class FirstPersonClientSystem method setFirstPersonheldItemMountPointRotation.

@Command(shortDescription = "Sets the held item mount point rotation for the first person view")
public void setFirstPersonheldItemMountPointRotation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (newComponent != null) {
        newComponent.rotateDegrees = new Vector3f(x, y, z);
        ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
    }
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 25 with Vector3f

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

the class FirstPersonClientSystem method setFirstPersonheldItemMountPointTranslation.

@Command(shortDescription = "Sets the held item mount point translation for the first person view")
public void setFirstPersonheldItemMountPointTranslation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (newComponent != null) {
        newComponent.translate = new Vector3f(x, y, z);
        ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
    }
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) Command(org.terasology.logic.console.commandSystem.annotations.Command)

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