-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformNode.java
40 lines (32 loc) · 1.05 KB
/
TransformNode.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
/* This code is from exercise sheet written by Dr. Steve Maddock */
import gmaths.*;
import com.jogamp.opengl.*;
public class TransformNode extends SGNode {
private Mat4 transform;
public TransformNode(String name, Mat4 t) {
super(name);
transform = new Mat4(t);
}
public void setTransform(Mat4 m) {
transform = new Mat4(m);
}
protected void update(Mat4 t) {
worldTransform = t;
t = Mat4.multiply(worldTransform, transform);
for (int i = 0; i < children.size(); i++) {
children.get(i).update(t);
}
}
public void print(int indent, boolean inFull) {
System.out.println(getIndentString(indent) + "Name: " + name);
if (inFull) {
System.out.println("worldTransform");
System.out.println(worldTransform);
System.out.println("transform node:");
System.out.println(transform);
}
for (int i = 0; i < children.size(); i++) {
children.get(i).print(indent + 1, inFull);
}
}
}