aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/taper-material.js
diff options
context:
space:
mode:
authorKruti Shah2012-07-17 12:40:00 -0700
committerKruti Shah2012-07-17 12:40:00 -0700
commitbf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /js/lib/rdge/materials/taper-material.js
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js/lib/rdge/materials/taper-material.js')
-rw-r--r--js/lib/rdge/materials/taper-material.js112
1 files changed, 67 insertions, 45 deletions
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js
index 2dc3e120..929dffa6 100644
--- a/js/lib/rdge/materials/taper-material.js
+++ b/js/lib/rdge/materials/taper-material.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, 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
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -38,7 +39,7 @@ var Texture = require("js/lib/rdge/texture").Texture;
38var TaperMaterial = function TaperMaterial() 39var TaperMaterial = function TaperMaterial()
39{ 40{
40 // initialize the inherited members 41 // initialize the inherited members
41 this.inheritedFrom = Material; 42 this.inheritedFrom = Material;
42 this.inheritedFrom(); 43 this.inheritedFrom();
43 44
44 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
@@ -55,12 +56,14 @@ var TaperMaterial = function TaperMaterial()
55 this.getShaderName = function () { return this._shaderName; }; 56 this.getShaderName = function () { return this._shaderName; };
56 57
57 this.isAnimated = function () { return true; }; 58 this.isAnimated = function () { return true; };
58 this.getShaderDef = function() { return taperShaderDef; }; 59 this.getShaderDef = function() { return taperShaderDef; };
59 this.getTechniqueName = function() { return 'colorMe' }; 60 this.getTechniqueName = function() { return 'colorMe' };
60 61
61 this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; 62 this.hasVertexDeformation = function () { return this._hasVertexDeformation; };
62 this._hasVertexDeformation = true; 63 this._hasVertexDeformation = true;
63 this._vertexDeformationTolerance = 0.02; // should be a property 64 this._vertexDeformationTolerance = 0.1; // should be a property
65
66 this.getVertexDeformationTolerance = function() { return this._propValues[this._propNames[7]]; };
64 67
65 /////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////
66 // Methods 69 // Methods
@@ -76,7 +79,7 @@ var TaperMaterial = function TaperMaterial()
76 // set up the material node 79 // set up the material node
77 this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID()); 80 this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID());
78 this._materialNode.setShader(this._shader); 81 this._materialNode.setShader(this._shader);
79 82
80 this._time = 0; 83 this._time = 0;
81 if (this._shader && this._shader['default']) { 84 if (this._shader && this._shader['default']) {
82 this._shader['default'].u_time.set([this._time]); 85 this._shader['default'].u_time.set([this._time]);
@@ -86,13 +89,30 @@ var TaperMaterial = function TaperMaterial()
86 this.setShaderValues(); 89 this.setShaderValues();
87 }; 90 };
88 91
92 this.resetToDefault = function()
93 {
94 this._propValues[this._propNames[0]] = 0.25;
95 this._propValues[this._propNames[1]] = 0.50;
96 this._propValues[this._propNames[2]] = 0.75;
97 this._propValues[this._propNames[3]] = -1;
98 this._propValues[this._propNames[4]] = 1;
99 this._propValues[this._propNames[5]] = 0.0;
100 this._propValues[this._propNames[6]] = 0.9;
101 this._propValues[this._propNames[7]] = this._vertexDeformationTolerance;
102 this._propValues[this._propNames[8]] = 1.0;
103
104 var nProps = this._propNames.length;
105 for (var i=0; i<nProps; i++)
106 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
107 };
108
89 109
90 /////////////////////////////////////////////////////////////////////// 110 ///////////////////////////////////////////////////////////////////////
91 // Material Property Accessors 111 // Material Property Accessors
92 /////////////////////////////////////////////////////////////////////// 112 ///////////////////////////////////////////////////////////////////////
93 this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "u_speed" ]; 113 this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "facettol", "u_speed" ];
94 this._propLabels = [ "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount", "Speed" ]; 114 this._propLabels = [ "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount", "Faceting Tolerance", "Speed" ];
95 this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float" ]; 115 this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float", "float" ];
96 this._propValues = []; 116 this._propValues = [];
97 117
98 // initialize the property values 118 // initialize the property values
@@ -103,7 +123,8 @@ var TaperMaterial = function TaperMaterial()
103 this._propValues[this._propNames[4]] = 1; 123 this._propValues[this._propNames[4]] = 1;
104 this._propValues[this._propNames[5]] = 0.0; 124 this._propValues[this._propNames[5]] = 0.0;
105 this._propValues[this._propNames[6]] = 0.9; 125 this._propValues[this._propNames[6]] = 0.9;
106 this._propValues[this._propNames[7]] = 1.0; 126 this._propValues[this._propNames[7]] = this._vertexDeformationTolerance;
127 this._propValues[this._propNames[8]] = 1.0;
107 128
108 this.update = function (time) { 129 this.update = function (time) {
109 var speed = this._propValues["u_speed"]; 130 var speed = this._propValues["u_speed"];
@@ -117,7 +138,7 @@ var TaperMaterial = function TaperMaterial()
117 } 138 }
118 139
119 var t1 = this._propValues["u_limit1"] - this._deltaTime, 140 var t1 = this._propValues["u_limit1"] - this._deltaTime,
120 t2 = this._propValues["u_limit2"] - this._deltaTime; 141 t2 = this._propValues["u_limit2"] - this._deltaTime;
121 142
122 143
123 this._shader.colorMe["u_limit1"].set([t1]); 144 this._shader.colorMe["u_limit1"].set([t1]);
@@ -138,31 +159,32 @@ taperShaderDef = {
138 }, 159 },
139 'techniques': { // rendering control 160 'techniques': { // rendering control
140 'colorMe': [ // simple color pass 161 'colorMe': [ // simple color pass
141 { 162 {
142 'vshader': 'defaultVShader', 163 'vshader': 'defaultVShader',
143 'fshader': 'defaultFShader', 164 'fshader': 'defaultFShader',
144 165
145 // attributes 166 // attributes
146 'attributes': 167 'attributes':
147 { 168 {
148 'vert': { 'type': 'vec3' }, 169 'vert': { 'type': 'vec3' },
149 'normal': { 'type': 'vec3' }, 170 'normal': { 'type': 'vec3' },
150 'texcoord': { 'type': 'vec2' } 171 'texcoord': { 'type': 'vec2' }
151 }, 172 },
152 // attributes 173 // attributes
153 'params': 174 'params':
154 { 175 {
155 'u_limit1': { 'type': 'float' }, 176 'u_limit1': { 'type': 'float' },
156 'u_limit2': { 'type': 'float' }, 177 'u_limit2': { 'type': 'float' },
157 'u_limit3': { 'type': 'float' }, 178 'u_limit3': { 'type': 'float' },
158 'u_minVal': { 'type': 'float' }, 179 'u_minVal': { 'type': 'float' },
159 'u_maxVal': { 'type': 'float' }, 180 'u_maxVal': { 'type': 'float' },
160 'u_center': { 'type': 'float' }, 181 'u_center': { 'type': 'float' },
161 'u_taperAmount': { 'type': 'float' }, 182 'u_taperAmount': { 'type': 'float' },
162 'u_speed': { 'type': 'float' } 183 'facettol': { 'type': 'float' },
163 } 184 'u_speed': { 'type': 'float' }
185 }
164 } 186 }
165 ] 187 ]
166 } 188 }
167}; 189};
168 190