aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/runtime/RuntimeGeomObj.js')
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeGeomObj.js611
1 files changed, 0 insertions, 611 deletions
diff --git a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js b/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
deleted file mode 100644
index fd5bf3aa..00000000
--- a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
+++ /dev/null
@@ -1,611 +0,0 @@
1
2/* <copyright>
3This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
4No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
5(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
6</copyright> */
7
8///////////////////////////////////////////////////////////////////////
9// Class RuntimeGeomObj
10// Super class for all geometry classes
11///////////////////////////////////////////////////////////////////////
12function RuntimeGeomObj()
13{
14 ///////////////////////////////////////////////////////////////////////
15 // Constants
16 ///////////////////////////////////////////////////////////////////////
17 this.GEOM_TYPE_RECTANGLE = 1;
18 this.GEOM_TYPE_CIRCLE = 2;
19 this.GEOM_TYPE_LINE = 3;
20 this.GEOM_TYPE_PATH = 4;
21 this.GEOM_TYPE_CUBIC_BEZIER = 5;
22 this.GEOM_TYPE_UNDEFINED = -1;
23
24 ///////////////////////////////////////////////////////////////////////
25 // Instance variables
26 ///////////////////////////////////////////////////////////////////////
27 this._children;
28
29 // stroke and fill colors
30 this._strokeColor = [0,0,0,0];
31 this._fillColor = [0,0,0,0];
32
33 // array of materials
34 this._materials = [];
35
36 ///////////////////////////////////////////////////////////////////////
37 // Property accessors
38 ///////////////////////////////////////////////////////////////////////
39
40 this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; }
41
42 this.setWorld = function(w) { this._world = w; }
43 this.getWorld = function() { return this._world; }
44
45 ///////////////////////////////////////////////////////////////////////
46 // Methods
47 ///////////////////////////////////////////////////////////////////////
48 this.makeStrokeMaterial = function()
49 {
50 }
51
52 this.makeFillMaterial = function()
53 {
54 }
55
56
57 this.render = function()
58 {
59 }
60
61 this.addChild = function( child )
62 {
63 if (!this._children) this._children = [];
64 this._children.push( child );
65 }
66
67 this.import = function()
68 {
69 }
70
71 this.importMaterials = function(importStr)
72 {
73 var nMaterials = Number( getPropertyFromString( "nMaterials: ", importStr ) );
74 for (var i=0; i<nMaterials; i++)
75 {
76 var matNodeName = getPropertyFromString( "materialNodeName: ", importStr );
77
78 var mat;
79 var materialType = getPropertyFromString( "material: ", importStr );
80 switch (materialType)
81 {
82 case "flat": mat = new RuntimeFlatMaterial(); break;
83 case "radialGradient": mat = new RuntimeRadialGradientMaterial(); break;
84 case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break;
85 case "bumpMetal": mat = new RuntimeBumpMetalMaterial(); break;
86 case "uber": mat = new RuntimeUberMaterial(); break;
87
88 case "deform":
89 case "water":
90 case "tunnel":
91 case "reliefTunnel":
92 case "squareTunnel":
93 case "twist":
94 case "fly":
95 case "julia":
96 case "mandel":
97 case "star":
98 case "zinvert":
99 case "keleidoscope":
100 case "pulse": mat = new RuntimePulseMaterial(); break;
101
102 default:
103 console.log( "material type: " + materialType + " is not supported" );
104 break;
105 }
106
107 if (mat)
108 {
109 mat.import( importStr );
110 mat._materialNodeName = matNodeName;
111 this._materials.push( mat );
112 }
113
114 var endIndex = importStr.indexOf( "endMaterial\n" );
115 if (endIndex < 0) break;
116 importStr = importStr.substr( endIndex );
117 }
118 }
119
120 ////////////////////////////////////////////////////////////////////
121 // vector function
122
123 this.vecAdd = function( dimen, a, b )
124 {
125 var rtnVec;
126 if ((a.length < dimen) || (b.length < dimen))
127 {
128 throw new Error( "dimension error in vecAdd" );
129 }
130
131 rtnVec = [];
132 for (var i=0; i<dimen; i++)
133 rtnVec[i] = a[i] + b[i];
134
135 return rtnVec;
136 }
137
138
139 this.vecSubtract = function( dimen, a, b )
140 {
141 var rtnVec;
142 if ((a.length < dimen) || (b.length < dimen))
143 {
144 throw new Error( "dimension error in vecSubtract" );
145 }
146
147 rtnVec = [];
148 for (var i=0; i<dimen; i++)
149 rtnVec[i] = a[i] - b[i];
150
151 return rtnVec;
152 }
153
154 this.vecDot = function( dimen, v0, v1 )
155 {
156 if ((v0.length < dimen) || (v1.length < dimen))
157 {
158 throw new Error( "dimension error in vecDot" );
159 }
160
161 var sum = 0.0;
162 for (var i=0; i<dimen; i++)
163 sum += v0[i] * v1[i];
164
165 return sum;
166 }
167
168 this.vecMag = function( dimen, vec )
169 {
170 var sum = 0.0;
171 for (var i=0; i<dimen; i++)
172 sum += vec[i]*vec[i];
173 return Math.sqrt( sum );
174 }
175
176 this.vecScale = function(dimen, vec, scale)
177 {
178 for (var i=0; i<dimen; i++)
179 vec[i] *= scale;
180
181 return vec;
182 }
183
184 this.vecNormalize = function(dimen, vec, len)
185 {
186 var rtnVec;
187 if (!len) len = 1.0;
188
189 var sum = 0.0;
190 for (var i=0; i<dimen; i++)
191 sum += vec[i]*vec[i];
192 sum = Math.sqrt( sum );
193
194 if (Math.abs(sum) >= 0.001)
195 {
196 var scale = len/sum;
197 rtnVec = [];
198 for (var i=0; i<dimen; i++)
199 rtnVec[i] = vec[i]*scale;
200 }
201
202 return rtnVec;
203 },
204
205 this.transformPoint = function( srcPt, mat )
206 {
207 var pt = srcPt.slice(0);
208 var x = this.vecDot(3, pt, [mat[0], mat[4], mat[ 8]] ) + mat[12],
209 y = this.vecDot(3, pt, [mat[1], mat[5], mat[ 9]] ) + mat[13],
210 z = this.vecDot(3, pt, [mat[2], mat[6], mat[10]] ) + mat[14];
211
212 return [x, y, z];
213 }
214}
215
216function getPropertyFromString( prop, str )
217{
218 var index = str.indexOf( prop );
219 if (index < 0) throw new Error( "property " + prop + " not found in string: " + str);
220
221 var rtnStr = str.substr( index+p