aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/FlatMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials/FlatMaterial.js')
-rwxr-xr-xjs/helper-classes/RDGE/Materials/FlatMaterial.js60
1 files changed, 25 insertions, 35 deletions
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js
index e2f23d75..570e7f9e 100755
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js
@@ -26,16 +26,19 @@ function FlatMaterial()
26 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
27 // Property Accessors 27 // Property Accessors
28 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
29 this.getColor = function() { return this._color; } 29 this.getColor = function() { return this._color; };
30 this.getShaderName = function() { return this._shaderName; } 30 this.getShaderName = function() { return this._shaderName; };
31 31
32 this.isAnimated = function() { return false; } 32 this.isAnimated = function() { return false; };
33 this.hasVertexDeformation = function() { return true; };
34 this._hasVertexDeformation = true;
35 this._vertexDeformationTolerance = 0.2;
33 36
34 //////////////////////////////////s///////////////////////////////////// 37 //////////////////////////////////s/////////////////////////////////////
35 // Methods 38 // Methods
36 /////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////
37 // duplcate method requirde 40 // duplcate method requirde
38 this.dup = function() { return new FlatMaterial(); } 41 this.dup = function() { return new FlatMaterial(); } ;
39 42
40 this.init = function() 43 this.init = function()
41 { 44 {
@@ -50,13 +53,7 @@ function FlatMaterial()
50 // set up the material node 53 // set up the material node
51 this._materialNode = createMaterialNode("flatMaterial"); 54 this._materialNode = createMaterialNode("flatMaterial");
52 this._materialNode.setShader(this._shader); 55 this._materialNode.setShader(this._shader);
53 56 };
54 // initialize the taper properties
55// this._shader.colorMe.u_limit1.set( [0.25] );
56// this._shader.colorMe.u_limit2.set( [0.5] );
57// this._shader.colorMe.u_limit3.set( [0.75] );
58// this._shader.colorMe.u_taperAmount.set( [0.5] );
59 }
60 57
61 58
62 /////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////
@@ -76,9 +73,9 @@ function FlatMaterial()
76 { 73 {
77 this._propValues[prop] = value; 74 this._propValues[prop] = value;
78 if (this._shader && this._shader.colorMe) 75 if (this._shader && this._shader.colorMe)
79 this._shader.colorMe[prop].set(value); 76 this._shader.colorMe[prop].set(value);
80 } 77 }
81 } 78 };
82 /////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////
83 80
84 this.export = function() 81 this.export = function()
@@ -94,13 +91,13 @@ function FlatMaterial()
94 exportStr += "endMaterial\n"; 91 exportStr += "endMaterial\n";
95 92
96 return exportStr; 93 return exportStr;
97 } 94 };
98 95
99 this.import = function( importStr ) 96 this.import = function( importStr )
100 { 97 {
101 var pu = new ParseUtils( importStr ); 98 var pu = new ParseUtils( importStr );
102 var material = pu.nextValue( "material: " ); 99 var material = pu.nextValue( "material: " );
103 if (material != this.getShaderName()) throw new Error( "ill-formed material" ); 100 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
104 this.setName( pu.nextValue( "name: ") ); 101 this.setName( pu.nextValue( "name: ") );
105 102
106 var rtnStr; 103 var rtnStr;
@@ -110,7 +107,7 @@ function FlatMaterial()
110 107
111 this.setProperty( "color", color); 108 this.setProperty( "color", color);
112 109
113 var endKey = "endMaterial\n"; 110 var endKey = "endMaterial\n";
114 var index = importStr.indexOf( endKey ); 111 var index = importStr.indexOf( endKey );
115 index += endKey.length; 112 index += endKey.length;
116 rtnStr = importStr.substr( index ); 113 rtnStr = importStr.substr( index );
@@ -120,16 +117,14 @@ function FlatMaterial()
120 throw new Error( "could not import material: " + importStr ); 117 throw new Error( "could not import material: " + importStr );
121 } 118 }
122 119
123 return rtnStr; 120 return rtnStr;
124 } 121 };
125 122
126 this.update = function( time ) 123 this.update = function( time )
127 { 124 {
128 } 125 };
129 126
130} 127}
131// used to create unique names
132var flatMaterialCounter = 0;
133 128
134/////////////////////////////////////////////////////////////////////////////////////// 129///////////////////////////////////////////////////////////////////////////////////////
135// RDGE shader 130// RDGE shader
@@ -139,7 +134,7 @@ flatShaderDef =
139{ 134{
140 'shaders': { // shader files 135 'shaders': { // shader files
141 'defaultVShader':"assets/shaders/Basic.vert.glsl", 136 'defaultVShader':"assets/shaders/Basic.vert.glsl",
142 'defaultFShader':"assets/shaders/Basic.frag.glsl", 137 'defaultFShader':"assets/shaders/Basic.frag.glsl"
143 }, 138 },
144 'techniques': { // rendering control 139 'techniques': { // rendering control
145 'colorMe':[ // simple color pass 140 'colorMe':[ // simple color pass
@@ -152,19 +147,14 @@ flatShaderDef =
152 { 147 {
153 'vert' : { 'type' : 'vec3' }, 148 'vert' : { 'type' : 'vec3' },
154 'normal' : { 'type' : 'vec3' }, 149 'normal' : { 'type' : 'vec3' },
155 'texcoord' : { 'type' : 'vec2' }, 150 'texcoord' : { 'type' : 'vec2' }
156 }, 151 },
157 // attributes 152 // attributes
158 'params' : 153 'params' :
159 { 154 {
160 'color' : { 'type' : 'vec4' }, 155 'color' : { 'type' : 'vec4' }
161 156 }
162 //'u_limit1': { 'type': 'float' }, 157 }
163 //'u_limit2': { 'type': 'float' },
164 //'u_limit3': { 'type': 'float' },
165 //'u_taperAmount': { 'type': 'float' }
166 },
167 },
168 ] 158 ]
169 } 159 }
170}; 160};