aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/taper-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/taper-material.js')
-rw-r--r--js/lib/rdge/materials/taper-material.js87
1 files changed, 54 insertions, 33 deletions
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js
index 2dc3e120..bf5236fd 100644
--- a/js/lib/rdge/materials/taper-material.js
+++ b/js/lib/rdge/materials/taper-material.js
@@ -38,7 +38,7 @@ var Texture = require("js/lib/rdge/texture").Texture;
38var TaperMaterial = function TaperMaterial() 38var TaperMaterial = function TaperMaterial()
39{ 39{
40 // initialize the inherited members 40 // initialize the inherited members
41 this.inheritedFrom = Material; 41 this.inheritedFrom = Material;
42 this.inheritedFrom(); 42 this.inheritedFrom();
43 43
44 /////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////
@@ -55,13 +55,15 @@ var TaperMaterial = function TaperMaterial()
55 this.getShaderName = function () { return this._shaderName; }; 55 this.getShaderName = function () { return this._shaderName; };
56 56
57 this.isAnimated = function () { return true; }; 57 this.isAnimated = function () { return true; };
58 this.getShaderDef = function() { return taperShaderDef; }; 58 this.getShaderDef = function() { return taperShaderDef; };
59 this.getTechniqueName = function() { return 'colorMe' }; 59 this.getTechniqueName = function() { return 'colorMe' };
60 60
61 this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; 61 this.hasVertexDeformation = function () { return this._hasVertexDeformation; };
62 this._hasVertexDeformation = true; 62 this._hasVertexDeformation = true;
63 this._vertexDeformationTolerance = 0.02; // should be a property 63 this._vertexDeformationTolerance = 0.02; // should be a property
64 64
65 this.getVertexDeformationTolerance = function() { return this._propValues[this._propNames[7]]; };
66
65 /////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////
66 // Methods 68 // Methods
67 /////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////
@@ -76,7 +78,7 @@ var TaperMaterial = function TaperMaterial()
76 // set up the material node 78 // set up the material node
77 this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID()); 79 this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID());
78 this._materialNode.setShader(this._shader); 80 this._materialNode.setShader(this._shader);
79 81
80 this._time = 0; 82 this._time = 0;
81 if (this._shader && this._shader['default']) { 83 if (this._shader && this._shader['default']) {
82 this._shader['default'].u_time.set([this._time]); 84 this._shader['default'].u_time.set([this._time]);
@@ -86,13 +88,30 @@ var TaperMaterial = function TaperMaterial()
86 this.setShaderValues(); 88 this.setShaderValues();
87 }; 89 };
88 90
91 this.resetToDefault = function()
92 {
93 this._propValues[this._propNames[0]] = 0.25;
94 this._propValues[this._propNames[1]] = 0.50;
95 this._propValues[this._propNames[2]] = 0.75;
96 this._propValues[this._propNames[3]] = -1;
97 this._propValues[this._propNames[4]] = 1;
98 this._propValues[this._propNames[5]] = 0.0;
99 this._propValues[this._propNames[6]] = 0.9;
100 this._propValues[this._propNames[7]] = this._vertexDeformationTolerance;
101 this._propValues[this._propNames[8]] = 1.0;
102
103 var nProps = this._propNames.length;
104 for (var i=0; i<nProps; i++)
105 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
106 };
107
89 108
90 /////////////////////////////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////
91 // Material Property Accessors 110 // Material Property Accessors
92 /////////////////////////////////////////////////////////////////////// 111 ///////////////////////////////////////////////////////////////////////
93 this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "u_speed" ]; 112 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" ]; 113 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" ]; 114 this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float", "float" ];
96 this._propValues = []; 115 this._propValues = [];
97 116
98 // initialize the property values 117 // initialize the property values
@@ -103,7 +122,8 @@ var TaperMaterial = function TaperMaterial()
103 this._propValues[this._propNames[4]] = 1; 122 this._propValues[this._propNames[4]] = 1;
104 this._propValues[this._propNames[5]] = 0.0; 123 this._propValues[this._propNames[5]] = 0.0;
105 this._propValues[this._propNames[6]] = 0.9; 124 this._propValues[this._propNames[6]] = 0.9;
106 this._propValues[this._propNames[7]] = 1.0; 125 this._propValues[this._propNames[7]] = this._vertexDeformationTolerance;
126 this._propValues[this._propNames[8]] = 1.0;
107 127
108 this.update = function (time) { 128 this.update = function (time) {
109 var speed = this._propValues["u_speed"]; 129 var speed = this._propValues["u_speed"];
@@ -117,7 +137,7 @@ var TaperMaterial = function TaperMaterial()
117 } 137 }
118 138
119 var t1 = this._propValues["u_limit1"] - this._deltaTime, 139 var t1 = this._propValues["u_limit1"] - this._deltaTime,
120 t2 = this._propValues["u_limit2"] - this._deltaTime; 140 t2 = this._propValues["u_limit2"] - this._deltaTime;
121 141
122 142
123 this._shader.colorMe["u_limit1"].set([t1]); 143 this._shader.colorMe["u_limit1"].set([t1]);
@@ -138,31 +158,32 @@ taperShaderDef = {
138 }, 158 },
139 'techniques': { // rendering control 159 'techniques': { // rendering control
140 'colorMe': [ // simple color pass 160 'colorMe': [ // simple color pass
141 { 161 {
142 'vshader': 'defaultVShader', 162 'vshader': 'defaultVShader',
143 'fshader': 'defaultFShader', 163 'fshader': 'defaultFShader',
144 164
145 // attributes 165 // attributes
146 'attributes': 166 'attributes':
147 { 167 {
148 'vert': { 'type': 'vec3' }, 168 'vert': { 'type': 'vec3' },
149 'normal': { 'type': 'vec3' }, 169 'normal': { 'type': 'vec3' },
150 'texcoord': { 'type': 'vec2' } 170 'texcoord': { 'type': 'vec2' }
151 }, 171 },
152 // attributes 172 // attributes
153 'params': 173 'params':
154 { 174 {
155 'u_limit1': { 'type': 'float' }, 175 'u_limit1': { 'type': 'float' },
156 'u_limit2': { 'type': 'float' }, 176 'u_limit2': { 'type': 'float' },
157 'u_limit3': { 'type': 'float' }, 177 'u_limit3': { 'type': 'float' },
158 'u_minVal': { 'type': 'float' }, 178 'u_minVal': { 'type': 'float' },
159 'u_maxVal': { 'type': 'float' }, 179 'u_maxVal': { 'type': 'float' },
160 'u_center': { 'type': 'float' }, 180 'u_center': { 'type': 'float' },
161 'u_taperAmount': { 'type': 'float' }, 181 'u_taperAmount': { 'type': 'float' },
162 'u_speed': { 'type': 'float' } 182 'facettol': { 'type': 'float' },
163 } 183 'u_speed': { 'type': 'float' }
184 }
164 } 185 }
165 ] 186 ]
166 } 187 }
167}; 188};
168 189