|
7 | 7 |
|
8 | 8 | public class Vertex extends Struct { |
9 | 9 |
|
10 | | - public final Vector3f position = new Vector3f(); |
11 | | - public final Vector2f texCoord = new Vector2f(); |
12 | | - public final Vector3f normal = new Vector3f(); |
| 10 | + private final Field<Vector3f> position = new Field<>(new Vector3f()); |
| 11 | + private final Field<Vector2f> texCoord = new Field<>(new Vector2f()); |
| 12 | + private final Field<Vector3f> normal = new Field<>(new Vector3f()); |
13 | 13 |
|
14 | | - public Vertex(StructLayout layout) { |
15 | | - addFields(new Field(position), new Field(texCoord), new Field(normal)); |
16 | | - setLayout(layout); // stage layout, not calculated immediately |
| 14 | + public Vertex() { |
| 15 | + addFields(position, texCoord, normal); |
17 | 16 | } |
18 | 17 |
|
| 18 | + public void bind(StructLayout layout, long address) { |
| 19 | + for (Field f : fields) { |
| 20 | + f.bind(layout, address); |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + public void setPosition(Vector3f position) { |
| 25 | + updateLayout(); |
| 26 | + this.position.set(address, position); |
| 27 | + } |
| 28 | + |
| 29 | + public void setPosition(float x, float y, float z) { |
| 30 | + position.set(position.getAlias().set(x, y, z)); |
| 31 | + } |
| 32 | + |
| 33 | + public Vector3f getPosition() { |
| 34 | + return position.get(address); |
| 35 | + } |
| 36 | + |
| 37 | + public void setTexCoord(Vector2f texCoord) { |
| 38 | + this.texCoord.set(address, texCoord); |
| 39 | + } |
19 | 40 |
|
| 41 | + public void setTexCoord(float x, float y) { |
| 42 | + texCoord.set(address, texCoord.getAlias().set(x, y)); |
| 43 | + } |
| 44 | + |
| 45 | + public Vector2f getTexCoord() { |
| 46 | + return texCoord.get(address); |
| 47 | + } |
20 | 48 |
|
21 | 49 | } |
0 commit comments