diff options
author | hwc487 | 2012-07-09 16:08:02 -0700 |
---|---|---|
committer | hwc487 | 2012-07-09 16:08:02 -0700 |
commit | 5085d0f67df89a21715308956004164597a6ba79 (patch) | |
tree | 2c896163143a66331205a39b0a3b1b45d51bf12a /js/lib/rdge/materials/twist-material.js | |
parent | 51f1691f792dbda9b740ded8aa0457c9406db156 (diff) | |
parent | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff) | |
download | ninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts:
js/helper-classes/3D/StageLine.js
Diffstat (limited to 'js/lib/rdge/materials/twist-material.js')
-rw-r--r-- | js/lib/rdge/materials/twist-material.js | 94 |
1 files changed, 52 insertions, 42 deletions
diff --git a/js/lib/rdge/materials/twist-material.js b/js/lib/rdge/materials/twist-material.js index 20e49713..5b6dfb8f 100644 --- a/js/lib/rdge/materials/twist-material.js +++ b/js/lib/rdge/materials/twist-material.js | |||
@@ -51,19 +51,19 @@ var TwistMaterial = function TwistMaterial() { | |||
51 | /////////////////////////////////////////////////////////////////////// | 51 | /////////////////////////////////////////////////////////////////////// |
52 | // Material Property Accessors | 52 | // Material Property Accessors |
53 | /////////////////////////////////////////////////////////////////////// | 53 | /////////////////////////////////////////////////////////////////////// |
54 | var u_tex0_index = 0, u_speed_index = 1; | 54 | var u_tex0_index = 0, u_speed_index = 1; |
55 | this._propNames = ["u_tex0", "u_speed" ]; | 55 | this._propNames = ["u_tex0", "u_speed" ]; |
56 | this._propLabels = ["Texture map", "Speed" ]; | 56 | this._propLabels = ["Texture map", "Speed" ]; |
57 | this._propTypes = ["file", "float" ]; | 57 | this._propTypes = ["file", "float" ]; |
58 | this._propValues = []; | 58 | this._propValues = []; |
59 | this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); | 59 | this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); |
60 | this._propValues[this._propNames[u_speed_index]] = 1.0; | 60 | this._propValues[this._propNames[u_speed_index]] = 1.0; |
61 | 61 | ||
62 | /////////////////////////////////////////////////////////////////////// | 62 | /////////////////////////////////////////////////////////////////////// |
63 | // Material Property Accessors | 63 | // Material Property Accessors |
64 | /////////////////////////////////////////////////////////////////////// | 64 | /////////////////////////////////////////////////////////////////////// |
65 | this.isAnimated = function() { return true; }; | 65 | this.isAnimated = function() { return true; }; |
66 | this.getShaderDef = function() { return twistMaterialDef; }; | 66 | this.getShaderDef = function() { return twistMaterialDef; }; |
67 | 67 | ||
68 | /////////////////////////////////////////////////////////////////////// | 68 | /////////////////////////////////////////////////////////////////////// |
69 | // Methods | 69 | // Methods |
@@ -91,6 +91,16 @@ var TwistMaterial = function TwistMaterial() { | |||
91 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); | 91 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
92 | this.update(0); | 92 | this.update(0); |
93 | }; | 93 | }; |
94 | |||
95 | this.resetToDefault = function() | ||
96 | { | ||
97 | this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); | ||
98 | this._propValues[this._propNames[u_speed_index]] = 1.0; | ||
99 | |||
100 | var nProps = this._propNames.length; | ||
101 | for (var i=0; i<nProps; i++) | ||
102 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | ||
103 | }; | ||
94 | }; | 104 | }; |
95 | 105 | ||
96 | /////////////////////////////////////////////////////////////////////////////////////// | 106 | /////////////////////////////////////////////////////////////////////////////////////// |
@@ -99,42 +109,42 @@ var TwistMaterial = function TwistMaterial() { | |||
99 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 109 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
100 | var twistMaterialDef = | 110 | var twistMaterialDef = |
101 | { 'shaders': | 111 | { 'shaders': |
102 | { | 112 | { |
103 | 'defaultVShader': "assets/shaders/Basic.vert.glsl", | 113 | 'defaultVShader': "assets/shaders/Basic.vert.glsl", |
104 | 'defaultFShader': "assets/shaders/Twist.frag.glsl" | 114 | 'defaultFShader': "assets/shaders/Twist.frag.glsl" |
105 | }, | 115 | }, |
106 | 'techniques': | 116 | 'techniques': |
107 | { | 117 | { |
108 | 'default': | 118 | 'default': |
109 | [ | 119 | [ |
110 | { | 120 | { |
111 | 'vshader': 'defaultVShader', | 121 | 'vshader': 'defaultVShader', |
112 | 'fshader': 'defaultFShader', | 122 | 'fshader': 'defaultFShader', |
113 | // attributes | 123 | // attributes |
114 | 'attributes': | 124 | 'attributes': |
115 | { | 125 | { |
116 | 'vert': { 'type': 'vec3' }, | 126 | 'vert': { 'type': 'vec3' }, |
117 | 'normal': { 'type': 'vec3' }, | 127 | 'normal': { 'type': 'vec3' }, |
118 | 'texcoord': { 'type': 'vec2' } | 128 | 'texcoord': { 'type': 'vec2' } |
119 | }, | 129 | }, |
120 | // parameters | 130 | // parameters |
121 | 'params': | 131 | 'params': |
122 | { | 132 | { |
123 | 'u_tex0': { 'type': 'tex2d' }, | 133 | 'u_tex0': { 'type': 'tex2d' }, |
124 | 'u_time': { 'type': 'float' }, | 134 | 'u_time': { 'type': 'float' }, |
125 | 'u_speed': { 'type': 'float' }, | 135 | 'u_speed': { 'type': 'float' }, |
126 | 'u_resolution': { 'type': 'vec2' } | 136 | 'u_resolution': { 'type': 'vec2' } |
127 | }, | 137 | }, |
128 | 138 | ||
129 | // render states | 139 | // render states |
130 | 'states': | 140 | 'states': |
131 | { | 141 | { |
132 | 'depthEnable': true, | 142 | 'depthEnable': true, |
133 | 'offset': [1.0, 0.1] | 143 | 'offset': [1.0, 0.1] |
134 | } | 144 | } |
135 | } | 145 | } |
136 | ] | 146 | ] |
137 | } | 147 | } |
138 | }; | 148 | }; |
139 | 149 | ||
140 | TwistMaterial.prototype = new PulseMaterial(); | 150 | TwistMaterial.prototype = new PulseMaterial(); |