-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expand attribute scheme to allow combining meshdata
- Loading branch information
Showing
3 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...tests/src/test/java/org/terasology/engine/rendering/assets/mesh/StandardMeshDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.engine.rendering.assets.mesh; | ||
|
||
import org.joml.Matrix4f; | ||
import org.joml.Vector3f; | ||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
import org.terasology.joml.test.VectorAssert; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class StandardMeshDataTest { | ||
|
||
@Test | ||
public void testCombineMeshes() { | ||
StandardMeshData m1 = new StandardMeshData(); | ||
m1.position.put(new Vector3f(10f, 10f, 10f)); | ||
m1.position.put(new Vector3f(15f, 20f, 10f)); | ||
m1.position.put(new Vector3f(10f, 30f, 10f)); | ||
|
||
StandardMeshData m2 = new StandardMeshData(); | ||
m2.position.put(new Vector3f(10f, 10f, 10f)); | ||
m2.position.put(new Vector3f(15f, 20f, 10f)); | ||
m2.position.put(new Vector3f(10f, 30f, 10f)); | ||
|
||
m1.combine(new Matrix4f(), m2); | ||
|
||
assertEquals(m1.position.getPosition(), 6); | ||
assertEquals(m1.normal.getPosition(), 0); | ||
assertEquals(m1.uv0.getPosition(), 0); | ||
assertEquals(m1.uv1.getPosition(), 0); | ||
assertEquals(m1.color0.getPosition(), 0); | ||
|
||
VectorAssert.assertEquals(m1.position.get(0, new Vector3f()), new Vector3f(10f, 10f, 10f), .001f); | ||
VectorAssert.assertEquals(m1.position.get(1, new Vector3f()), new Vector3f(15f, 20f, 10f), .001f); | ||
VectorAssert.assertEquals(m1.position.get(2, new Vector3f()), new Vector3f(10f, 30f, 10f), .001f); | ||
|
||
VectorAssert.assertEquals(m1.position.get(3, new Vector3f()), new Vector3f(10f, 10f, 10f), .001f); | ||
VectorAssert.assertEquals(m1.position.get(4, new Vector3f()), new Vector3f(15f, 20f, 10f), .001f); | ||
VectorAssert.assertEquals(m1.position.get(5, new Vector3f()), new Vector3f(10f, 30f, 10f), .001f); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters