-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyPrimitiveNode.js
85 lines (59 loc) · 2.61 KB
/
MyPrimitiveNode.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* MyPrimitiveNode class, representing a leaf in the scene graph.
* @constructor
**/
function MyPrimitiveNode(graph, type, args) {
this.graph = graph;
this.type = type;
this.args = args;
this.obj = null;
switch (this.type) {
case 'rectangle':
this.obj = new MyQuad(this.graph.scene, Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]));
break;
case 'sphere':
this.obj = new MySphere(this.graph.scene, args[0], args[1], args[2]);
break;
case 'cylinder':
case 'cilinder':
this.obj = new MyCilinder(this.graph.scene, Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]), Number(args[4]));
break;
case 'triangle':
this.obj = new MyTriangle(this.graph.scene, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
break;
case 'thorus':
case 'torus':
this.obj = new MyTorus(this.graph.scene, Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]));
break;
/*NURBS*/
case 'plane':
this.obj = new MyPlane(this.graph.scene, Number(args[0]), Number(args[1]));
break;
case 'patch':
this.obj = new MyPatch(this.graph.scene, Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]), args[4]);
break;
case 'cylinder2':
case 'cilinder2':
this.obj = new MyCylinder2(this.graph.scene, Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]), Number(args[4]));
break;
case 'vehicle':
// inclui pelo menos 1 superficie nao plana gerada utilizando NURBs or js
this.obj = new MyVehicle(this.graph.scene);
break;
/*SHADERS*/
case 'terrain':
//<terrain idtexture="terrainid" idheightmap="1" parts="100" heightscale="0.1" />
this.obj = new MyTerrain(this.graph.scene, Number(args[2]), Number(args[2]), args[0], args[1], Number(args[3]));
break;
case 'water':
//<water idtexture="waterid" idwavemap="1" parts="100" heightscale="0.1" texscale="1" />
this.obj = new MyWater(this.graph.scene, Number(args[2]), Number(args[2]), args[0], args[1], Number(args[3]), Number(args[4])); //[4]texscale nao passa
break;
}
};
MyPrimitiveNode.prototype.display = function() {
this.obj.display();
};
MyPrimitiveNode.prototype.updateTexCoords = function(sFactor, tFactor) {
this.obj.updateTexCoords(sFactor, tFactor);
};