Search in sources :

Example 91 with Vector3f

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

the class StorageManagerTest method testPlayerRelevanceLocationSurvivesStorage.

@Test
public void testPlayerRelevanceLocationSurvivesStorage() {
    Vector3f loc = new Vector3f(1, 2, 3);
    character.addComponent(new LocationComponent(loc));
    esm.waitForCompletionOfPreviousSaveAndStartSaving();
    esm.finishSavingAndShutdown();
    PlayerStore restored = esm.loadPlayerStore(PLAYER_ID);
    assertEquals(loc, restored.getRelevanceLocation());
}
Also used : PlayerStore(org.terasology.persistence.PlayerStore) Vector3f(org.terasology.math.geom.Vector3f) LocationComponent(org.terasology.logic.location.LocationComponent) Test(org.junit.Test)

Example 92 with Vector3f

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

the class ByteCodeReflectFactoryTest method testCreateFieldAccessorWithGetterSetter.

@Test
public void testCreateFieldAccessorWithGetterSetter() throws Exception {
    ReflectFactory reflectFactory = new ByteCodeReflectFactory();
    FieldAccessor<GetterSetterComponent, Vector3f> fieldAccessor = reflectFactory.createFieldAccessor(GetterSetterComponent.class, GetterSetterComponent.class.getDeclaredField("value"), Vector3f.class);
    GetterSetterComponent comp = new GetterSetterComponent();
    Vector3f newVal = new Vector3f(1, 2, 3);
    fieldAccessor.setValue(comp, newVal);
    assertTrue(comp.setterUsed);
    assertEquals(newVal, fieldAccessor.getValue(comp));
    assertTrue(comp.getterUsed);
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) GetterSetterComponent(org.terasology.entitySystem.stubs.GetterSetterComponent) Test(org.junit.Test)

Example 93 with Vector3f

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

the class ChunkTest method testGetAabb.

@Test
public void testGetAabb() {
    assertEquals(new Vector3f(0, 0, 0), chunk.getAABB().getMin());
    assertEquals(new Vector3f(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y, ChunkConstants.SIZE_Z), chunk.getAABB().getMax());
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) Test(org.junit.Test)

Example 94 with Vector3f

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

the class LocationComponentTest method testParentRotatesWorldLocation.

@Test
public void testParentRotatesWorldLocation() {
    LocationComponent parent = giveParent();
    loc.setLocalPosition(pos1);
    parent.setLocalRotation(yawRotation);
    TeraAssert.assertEquals(new Vector3f(pos1.z, pos1.y, -pos1.x), loc.getWorldPosition(), 0.00001f);
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) Test(org.junit.Test)

Example 95 with Vector3f

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

the class LocationComponentTest method testScaleRotateAndOffsetCombineCorrectlyForWorldPosition.

@Test
public void testScaleRotateAndOffsetCombineCorrectlyForWorldPosition() {
    LocationComponent parent = giveParent();
    loc.setLocalPosition(pos1);
    parent.setLocalScale(2.0f);
    parent.setLocalPosition(pos2);
    parent.setLocalRotation(yawRotation);
    TeraAssert.assertEquals(new Vector3f(8, 7, 2), loc.getWorldPosition(), 0.00001f);
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) Test(org.junit.Test)

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