diff options
author | Nivesh Rajbhandari | 2012-02-09 12:02:27 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-09 12:02:27 -0800 |
commit | a9b1a1f2642841c4165ede69d131b1deb6238622 (patch) | |
tree | 2076dc497fbde041283af8b0082b0f4e24c9e1c6 /js/helper-classes/RDGE/Materials/FlatMaterial.js | |
parent | 31e2eb0d0da9b032116ad073918ca36ec11dac45 (diff) | |
parent | ce81a3f4387d80f9ac406e73b843fb5dbe9cf432 (diff) | |
download | ninja-a9b1a1f2642841c4165ede69d131b1deb6238622.tar.gz |
Merge branch 'refs/heads/ninja-internal' into SnapManagerFixes
Conflicts:
js/helper-classes/RDGE/Materials/FlatMaterial.js
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/Materials/FlatMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/FlatMaterial.js | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js index a5c079a8..83da145e 100644 --- a/js/helper-classes/RDGE/Materials/FlatMaterial.js +++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js | |||
@@ -29,6 +29,8 @@ function FlatMaterial() | |||
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; } | ||
33 | |||
32 | //////////////////////////////////s///////////////////////////////////// | 34 | //////////////////////////////////s///////////////////////////////////// |
33 | // Methods | 35 | // Methods |
34 | /////////////////////////////////////////////////////////////////////// | 36 | /////////////////////////////////////////////////////////////////////// |
@@ -48,6 +50,12 @@ function FlatMaterial() | |||
48 | // set up the material node | 50 | // set up the material node |
49 | this._materialNode = createMaterialNode("flatMaterial"); | 51 | this._materialNode = createMaterialNode("flatMaterial"); |
50 | this._materialNode.setShader(this._shader); | 52 | this._materialNode.setShader(this._shader); |
53 | |||
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] ); | ||
51 | } | 59 | } |
52 | 60 | ||
53 | 61 | ||
@@ -68,7 +76,7 @@ function FlatMaterial() | |||
68 | { | 76 | { |
69 | this._propValues[prop] = value; | 77 | this._propValues[prop] = value; |
70 | if (this._shader && this._shader.colorMe) | 78 | if (this._shader && this._shader.colorMe) |
71 | this._shader.colorMe[prop].set(value); | 79 | this._shader.colorMe[prop].set(value); |
72 | } | 80 | } |
73 | } | 81 | } |
74 | /////////////////////////////////////////////////////////////////////// | 82 | /////////////////////////////////////////////////////////////////////// |
@@ -88,11 +96,11 @@ function FlatMaterial() | |||
88 | return exportStr; | 96 | return exportStr; |
89 | } | 97 | } |
90 | 98 | ||
91 | this.import = function( importStr ) | 99 | this.import = function( importStr ) |
92 | { | 100 | { |
93 | var pu = new ParseUtils( importStr ); | 101 | var pu = new ParseUtils( importStr ); |
94 | var material = pu.nextValue( "material: " ); | 102 | var material = pu.nextValue( "material: " ); |
95 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); | 103 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); |
96 | this.setName( pu.nextValue( "name: ") ); | 104 | this.setName( pu.nextValue( "name: ") ); |
97 | 105 | ||
98 | var rtnStr; | 106 | var rtnStr; |
@@ -102,7 +110,7 @@ function FlatMaterial() | |||
102 | 110 | ||
103 | this.setProperty( "color", color); | 111 | this.setProperty( "color", color); |
104 | 112 | ||
105 | var endKey = "endMaterial\n"; | 113 | var endKey = "endMaterial\n"; |
106 | var index = importStr.indexOf( endKey ); | 114 | var index = importStr.indexOf( endKey ); |
107 | index += endKey.length; | 115 | index += endKey.length; |
108 | rtnStr = importStr.substr( index ); | 116 | rtnStr = importStr.substr( index ); |
@@ -112,9 +120,12 @@ function FlatMaterial() | |||
112 | throw new Error( "could not import material: " + importStr ); | 120 | throw new Error( "could not import material: " + importStr ); |
113 | } | 121 | } |
114 | 122 | ||
115 | return rtnStr; | 123 | return rtnStr; |
116 | } | 124 | } |
117 | } | 125 | |
126 | this.update = function( time ) | ||
127 | { | ||
128 | } | ||
118 | 129 | ||
119 | // used to create unique names | 130 | // used to create unique names |
120 | var flatMaterialCounter = 0; | 131 | var flatMaterialCounter = 0; |
@@ -126,35 +137,31 @@ var flatMaterialCounter = 0; | |||
126 | flatShaderDef = | 137 | flatShaderDef = |
127 | { | 138 | { |
128 | 'shaders': { // shader files | 139 | 'shaders': { // shader files |
129 | 'defaultVShader': "\ | 140 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", |
130 | uniform mat4 u_mvMatrix;\ | 141 | 'defaultFShader':"assets/shaders/Basic.frag.glsl", |
131 | uniform mat4 u_projMatrix;\ | ||
132 | attribute vec3 a_pos;\ | ||
133 | void main() {\ | ||
134 | gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ | ||
135 | }", | ||
136 | 'defaultFShader': "\ | ||
137 | precision highp float;\ | ||
138 | uniform vec4 color;\ | ||
139 | void main() {\ | ||
140 | gl_FragColor = color;\ | ||
141 | }", | ||
142 | }, | 142 | }, |
143 | 'techniques': { // rendering control | 143 | 'techniques': { // rendering control |
144 | 'colorMe':[ // simple color pass | 144 | 'colorMe':[ // simple color pass |
145 | { | 145 | { |
146 | 'vshader' : 'defaultVShader', | 146 | 'vshader' : 'defaultVShader', |
147 | 'fshader' : 'defaultFShader', | 147 | 'fshader' : 'defaultFShader', |
148 | 148 | ||
149 | // attributes | 149 | // attributes |
150 | 'attributes' : | 150 | 'attributes' : |
151 | { | 151 | { |
152 | 'a_pos' : { 'type' : 'vec3' } // only using position for this shader | 152 | 'vert' : { 'type' : 'vec3' }, |
153 | 'normal' : { 'type' : 'vec3' }, | ||
154 | 'texcoord' : { 'type' : 'vec2' }, | ||
153 | }, | 155 | }, |
154 | // attributes | 156 | // attributes |
155 | 'params' : | 157 | 'params' : |
156 | { | 158 | { |
157 | 'color' : { 'type' : 'vec4' } | 159 | 'color' : { 'type' : 'vec4' }, |
160 | |||
161 | //'u_limit1': { 'type': 'float' }, | ||
162 | //'u_limit2': { 'type': 'float' }, | ||
163 | //'u_limit3': { 'type': 'float' }, | ||
164 | //'u_taperAmount': { 'type': 'float' } | ||
158 | }, | 165 | }, |
159 | }, | 166 | }, |
160 | ] | 167 | ] |