-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshObject.java
57 lines (47 loc) · 1.28 KB
/
MeshObject.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import greenfoot.GreenfootImage;
/**
* Write a description of class MeshObject here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MeshObject extends GameObject
{
private Mesh mesh;
private GreenfootImage texture;
public MeshObject(Mesh mesh, GreenfootImage texture)
{
this.mesh = mesh;
this.texture = texture;
}
public void update(World3D world, float deltaTime)
{
mesh.draw(world.getRenderContext(), getTransform().getTransformation(), world.getCamera().getViewProjection(), texture);
}
public Mesh getMesh()
{
return mesh;
}
public GreenfootImage getTexture()
{
return texture;
}
public int[] getIndices()
{
return mesh.getIndices();
}
public Vertex[] getVertices()
{
return mesh.getVertices();
}
public Vertex[] getTransformedVertices()
{
Vertex[] out = new Vertex[getVertices().length];
for (int i = 0; i < getVertices().length; i++)
{
Vertex v = getVertices()[i];
out[i] = new Vertex(getTransform().getTransformation().transform(v.getPosition()), v.getNormal(), v.getTexCoords());
}
return out;
}
}