diff options
author | Kruti Shah | 2012-07-17 12:40:00 -0700 |
---|---|---|
committer | Kruti Shah | 2012-07-17 12:40:00 -0700 |
commit | bf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch) | |
tree | 2156d9920ea1b7db49ed6460545fea7cda121bae /js/lib/rdge/materials/material.js | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | b4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff) | |
download | ninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz |
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-x | js/lib/rdge/materials/material.js | 590 |
1 files changed, 305 insertions, 285 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 34d3aa1f..e8571e9d 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -39,160 +40,156 @@ var Material = function GLMaterial( world ) { | |||
39 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
40 | // Instance variables | 41 | // Instance variables |
41 | /////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////// |
42 | this._name = "GLMaterial"; | 43 | this._name = "GLMaterial"; |
43 | this._shaderName = "undefined"; | 44 | this._shaderName = "undefined"; |
44 | 45 | ||
45 | this._time = 0.0; | 46 | this._time = 0.0; |
46 | this._dTime = 0.01; | 47 | this._dTime = 0.01; |
47 | 48 | ||
48 | // keep a reference to the owning GLWorld | 49 | // keep a reference to the owning GLWorld |
49 | this._world = null; | 50 | this._world = null; |
50 | if(world) { | 51 | if(world) { |
51 | this._world = world; | 52 | this._world = world; |
52 | } | 53 | } |
53 | 54 | ||
54 | this._glTextures = []; // indexed by uniform name | 55 | this._glTextures = []; // indexed by uniform name |
55 | 56 | ||
56 | // vertex deformation variables | 57 | // vertex deformation variables |
57 | this._hasVertexDeformation = false; | 58 | this._hasVertexDeformation = false; |
58 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) | 59 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) |
59 | this._vertexDeformationTolerance = 0.1; | 60 | this._vertexDeformationTolerance = 0.1; |
60 | 61 | ||
61 | // RDGE variables | 62 | // RDGE variables |
62 | this._shader = null; | 63 | this._shader = null; |
63 | this._materialNode = null; | 64 | this._materialNode = null; |
64 | 65 | ||
65 | // vertex deformation variables | ||
66 | this._hasVertexDeformation = false; | ||
67 | this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) | ||
68 | this._vertexDeformationTolerance = 0.02; | ||
69 | 66 | ||
70 | /////////////////////////////////////////////////////////////////////// | 67 | /////////////////////////////////////////////////////////////////////// |
71 | // Property Accessors | 68 | // Property Accessors |
72 | /////////////////////////////////////////////////////////////////////// | 69 | /////////////////////////////////////////////////////////////////////// |
73 | 70 | ||
74 | this.setName = function(n) { | 71 | this.setName = function(n) { |
75 | this._name = n; | 72 | this._name = n; |
76 | }; | 73 | }; |
77 | 74 | ||
78 | this.getName = function() { | 75 | this.getName = function() { |
79 | return this._name; | 76 | return this._name; |
80 | }; | 77 | }; |
81 | 78 | ||
82 | this.setShaderName = function(n) { | 79 | this.setShaderName = function(n) { |
83 | this._shaderName = n; | 80 | this._shaderName = n; |
84 | }; | 81 | }; |
85 | 82 | ||
86 | this.getShaderName = function() { | 83 | this.getShaderName = function() { |
87 | return this._shaderName; | 84 | return this._shaderName; |
88 | }; | 85 | }; |
89 | 86 | ||
90 | this.setWorld = function(world) { | 87 | this.setWorld = function(world) { |
91 | this._world = world; | 88 | this._world = world; |
92 | }; | 89 | }; |
93 | 90 | ||
94 | this.getWorld = function() { | 91 | this.getWorld = function() { |
95 | return this._world; | 92 | return this._world; |
96 | }; | 93 | }; |
97 | 94 | ||
98 | this.getShader = function() { | 95 | this.getShader = function() { |
99 | return this._shader; | 96 | return this._shader; |
100 | }; | 97 | }; |
101 | 98 | ||
102 | this.getMaterialNode = function() { | 99 | this.getMaterialNode = function() { |
103 | return this._materialNode; | 100 | return this._materialNode; |
104 | }; | 101 | }; |
105 | 102 | ||
106 | // a material can be animated or not. default is not. | 103 | // a material can be animated or not. default is not. |
107 | // Any material needing continuous rendering should override this method | 104 | // Any material needing continuous rendering should override this method |
108 | this.isAnimated = function() { | 105 | this.isAnimated = function() { |
109 | return false; | 106 | return false; |
110 | }; | 107 | }; |
111 | 108 | ||
112 | this.getTechniqueName = function() { | 109 | this.getTechniqueName = function() { |
113 | return 'default' | 110 | return 'default' |
114 | }; | 111 | }; |
115 | 112 | ||
116 | // the vertex shader can apply deformations requiring refinement in | 113 | // the vertex shader can apply deformations requiring refinement in |
117 | // certain areas. | 114 | // certain areas. |
118 | this.hasVertexDeformation = function() { | 115 | this.hasVertexDeformation = function() { |
119 | return this._hasVertexDeformation; | 116 | return this._hasVertexDeformation; |
120 | }; | 117 | }; |
121 | 118 | ||
122 | this.getVertexDeformationRange = function() { | 119 | this.getVertexDeformationRange = function() { |
123 | return this._vertexDeformationRange.slice(); | 120 | return this._vertexDeformationRange.slice(); |
124 | }; | 121 | }; |
125 | 122 | ||
126 | this.getVertexDeformationTolerance = function() { | 123 | this.getVertexDeformationTolerance = function() { |
127 | return this._vertexDeformationTolerance; | 124 | return this._vertexDeformationTolerance; |
128 | }; | 125 | }; |
129 | 126 | ||
130 | /////////////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////////////// |
131 | // Common Material Methods | 128 | // Common Material Methods |
132 | /////////////////////////////////////////////////////////////////////// | 129 | /////////////////////////////////////////////////////////////////////// |
133 | this.getProperty = function( propName ) { | 130 | this.getProperty = function( propName ) { |
134 | return this._propValues[propName]; | 131 | return this._propValues[propName]; |
135 | }; | 132 | }; |
136 | 133 | ||
137 | this.getPropertyCount = function() { | 134 | this.getPropertyCount = function() { |
138 | return this._propNames.length; | 135 | return this._propNames.length; |
139 | }; | 136 | }; |
140 | 137 | ||
141 | this.getPropertyAtIndex = function( index ) { | 138 | this.getPropertyAtIndex = function( index ) { |
142 | var rtnArr = []; | 139 | var rtnArr = []; |
143 | if ((index < 0) || (index >= this.getPropertyCount())) { | 140 | if ((index < 0) || (index >= this.getPropertyCount())) { |
144 | throw new Error( "property index " + index + " is out of range for material" ); | 141 | throw new Error( "property index " + index + " is out of range for material" ); |
145 | } | 142 | } |
146 | 143 | ||
147 | return [ this._propNames[index], this._propLabels[index], this._propTypes[index], this._propValues[index] ]; | 144 | return [ this._propNames[index], this._propLabels[index], this._propTypes[index], this._propValues[index] ]; |
148 | }; | 145 | }; |
149 | 146 | ||
150 | this.getAllProperties = function( propNames, propValues, propTypes, propLabels) { | 147 | this.getAllProperties = function( propNames, propValues, propTypes, propLabels) { |
151 | // clear all the input arrays if there is junk in them | 148 | // clear all the input arrays if there is junk in them |
152 | propNames.length = 0; | 149 | propNames.length = 0; |
153 | propValues.length = 0; | 150 | propValues.length = 0; |
154 | propTypes.length = 0; | 151 | propTypes.length = 0; |
155 | propLabels.length = 0; | 152 | propLabels.length = 0; |
156 | 153 | ||
157 |