diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/lib/rdge/materials/material.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-x | js/lib/rdge/materials/material.js | 592 |
1 files changed, 306 insertions, 286 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 34d3aa1f..0f6f6c92 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.02; |
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 |