diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/lib/rdge/materials/flag-material.js | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/flag-material.js')
-rw-r--r-- | js/lib/rdge/materials/flag-material.js | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/js/lib/rdge/materials/flag-material.js b/js/lib/rdge/materials/flag-material.js index eb5e59df..7ad8b6e9 100644 --- a/js/lib/rdge/materials/flag-material.js +++ b/js/lib/rdge/materials/flag-material.js | |||
@@ -37,19 +37,19 @@ var FlagMaterial = function FlagMaterial() { | |||
37 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
38 | // Instance variables | 38 | // Instance variables |
39 | /////////////////////////////////////////////////////////////////////// | 39 | /////////////////////////////////////////////////////////////////////// |
40 | this._name = "Flag"; | 40 | this._name = "Flag"; |
41 | this._shaderName = "flag"; | 41 | this._shaderName = "flag"; |
42 | 42 | ||
43 | this._texMap = 'assets/images/us_flag.png'; | 43 | this._texMap = 'assets/images/us_flag.png'; |
44 | 44 | ||
45 | this._time = 0.0; | 45 | this._time = 0.0; |
46 | this._dTime = 0.1; | 46 | this._dTime = 0.1; |
47 | 47 | ||
48 | this._speed = 1.0; | 48 | this._speed = 1.0; |
49 | this._waveWidth = 1.0; | 49 | this._waveWidth = 1.0; |
50 | this._waveHeight = 1.0; | 50 | this._waveHeight = 1.0; |
51 | 51 | ||
52 | this._hasVertexDeformation = true; | 52 | this._hasVertexDeformation = true; |
53 | 53 | ||
54 | // array textures indexed by shader uniform name | 54 | // array textures indexed by shader uniform name |
55 | this._glTextures = []; | 55 | this._glTextures = []; |
@@ -57,51 +57,51 @@ var FlagMaterial = function FlagMaterial() { | |||
57 | /////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////// |
58 | // Properties | 58 | // Properties |
59 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
60 | // all defined in parent PulseMaterial.js | 60 | // all defined in parent PulseMaterial.js |
61 | // load the local default value | 61 | // load the local default value |
62 | this._propNames = ["u_tex0", "u_waveWidth", "u_waveHeight", "u_speed" ]; | 62 | this._propNames = ["u_tex0", "u_waveWidth", "u_waveHeight", "u_speed" ]; |
63 | this._propLabels = ["Texture map", "Wave Width", "Wave Height", "Speed" ]; | 63 | this._propLabels = ["Texture map", "Wave Width", "Wave Height", "Speed" ]; |
64 | this._propTypes = ["file", "float", "float", "float" ]; | 64 | this._propTypes = ["file", "float", "float", "float" ]; |
65 | this._propValues = []; | 65 | this._propValues = []; |
66 | 66 | ||
67 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 67 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); |
68 | this._propValues[ this._propNames[1] ] = this._waveWidth; | 68 | this._propValues[ this._propNames[1] ] = this._waveWidth; |
69 | this._propValues[ this._propNames[2] ] = this._waveHeight; | 69 | this._propValues[ this._propNames[2] ] = this._waveHeight; |
70 | this._propValues[ this._propNames[3] ] = this._speed; | 70 | this._propValues[ this._propNames[3] ] = this._speed; |
71 | 71 | ||
72 | 72 | ||
73 | // a material can be animated or not. default is not. | 73 | // a material can be animated or not. default is not. |
74 | // Any material needing continuous rendering should override this method | 74 | // Any material needing continuous rendering should override this method |
75 | this.isAnimated = function() { return true; }; | 75 | this.isAnimated = function() { return true; }; |
76 | this.getShaderDef = function() { return flagMaterialDef; } | 76 | this.getShaderDef = function() { return flagMaterialDef; } |
77 | 77 | ||
78 | /////////////////////////////////////////////////////////////////////// | 78 | /////////////////////////////////////////////////////////////////////// |
79 | // Methods | 79 | // Methods |
80 | /////////////////////////////////////////////////////////////////////// | 80 | /////////////////////////////////////////////////////////////////////// |
81 | // duplcate method requirde | 81 | // duplcate method requirde |
82 | 82 | ||
83 | this.init = function( world ) | 83 | this.init = function( world ) |
84 | { | 84 | { |
85 | // save the world | 85 | // save the world |
86 | if (world) this.setWorld( world ); | 86 | if (world) this.setWorld( world ); |
87 | 87 | ||
88 | // set up the shader | 88 | // set up the shader |
89 | this._shader = new RDGE.jshader(); | 89 | this._shader = new RDGE.jshader(); |
90 | this._shader.def = flagMaterialDef; | 90 | this._shader.def = flagMaterialDef; |
91 | this._shader.init(); | 91 | this._shader.init(); |
92 | 92 | ||
93 | // set up the material node | 93 | // set up the material node |
94 | this._materialNode = RDGE.createMaterialNode("flagMaterial" + "_" + world.generateUniqueNodeID()); | 94 | this._materialNode = RDGE.createMaterialNode("flagMaterial" + "_" + world.generateUniqueNodeID()); |
95 | this._materialNode.setShader(this._shader); | 95 | this._materialNode.setShader(this._shader); |
96 | 96 | ||
97 | this._time = 0; | 97 | this._time = 0; |
98 | if (this._shader && this._shader['default']) | 98 | if (this._shader && this._shader['default']) |
99 | this._shader['default'].u_time.set( [this._time] ); | 99 | this._shader['default'].u_time.set( [this._time] ); |
100 | 100 | ||
101 | // set the shader values in the shader | 101 | // set the shader values in the shader |
102 | this.setShaderValues(); | 102 | this.setShaderValues(); |
103 | this.update( 0 ); | 103 | this.update( 0 ); |
104 | } | 104 | } |
105 | 105 | ||
106 | this.resetToDefault = function() | 106 | this.resetToDefault = function() |
107 | { | 107 | { |
@@ -113,52 +113,52 @@ var FlagMaterial = function FlagMaterial() { | |||
113 | var nProps = this._propNames.length; | 113 | var nProps = this._propNames.length; |
114 | for (var i=0; i<nProps; i++) | 114 | for (var i=0; i<nProps; i++) |
115 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | 115 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); |
116 | }; | 116 | }; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | /////////////////////////////////////////////////////////////////////////////////////// | 119 | /////////////////////////////////////////////////////////////////////////////////////// |
120 | // RDGE shader | 120 | // RDGE shader |
121 | 121 | ||
122 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 122 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
123 | var flagMaterialDef = | 123 | var flagMaterialDef = |
124 | {'shaders': | 124 | {'shaders': |
125 | { | 125 | { |
126 | 'defaultVShader':"assets/shaders/Flag.vert.glsl", | 126 | 'defaultVShader':"assets/shaders/Flag.vert.glsl", |
127 | 'defaultFShader':"assets/shaders/Flag.frag.glsl" | 127 | 'defaultFShader':"assets/shaders/Flag.frag.glsl" |
128 | }, | 128 | }, |
129 | 'techniques': | 129 | 'techniques': |
130 | { | 130 | { |
131 | 'default': | 131 | 'default': |
132 | [ | 132 | [ |
133 | { | 133 | { |
134 | 'vshader' : 'defaultVShader', | 134 | 'vshader' : 'defaultVShader', |
135 | 'fshader' : 'defaultFShader', | 135 | 'fshader' : 'defaultFShader', |
136 | // attributes | 136 | // attributes |
137 | 'attributes' : | 137 | 'attributes' : |
138 | { | 138 | { |
139 | 'vert' : { 'type' : 'vec3' }, | 139 | 'vert' : { 'type' : 'vec3' }, |
140 | 'normal' : { 'type' : 'vec3' }, | 140 | 'normal' : { 'type' : 'vec3' }, |
141 | 'texcoord' : { 'type' : 'vec2' } | 141 | 'texcoord' : { 'type' : 'vec2' } |
142 | }, | 142 | }, |
143 | // parameters | 143 | // parameters |
144 | 'params' : | 144 | 'params' : |
145 | { | 145 | { |
146 | 'u_tex0': { 'type' : 'tex2d' }, | 146 | 'u_tex0': { 'type' : 'tex2d' }, |
147 | 'u_time' : { 'type' : 'float' }, | 147 | 'u_time' : { 'type' : 'float' }, |
148 | 'u_speed' : { 'type' : 'float' }, | 148 | 'u_speed' : { 'type' : 'float' }, |
149 | 'u_waveWidth' : { 'type' : 'float' }, | 149 | 'u_waveWidth' : { 'type' : 'float' }, |
150 | 'u_waveHeight' : { 'type' : 'float' } | 150 | 'u_waveHeight' : { 'type' : 'float' } |
151 | }, | 151 | }, |
152 | 152 | ||
153 | // render states | 153 | // render states |
154 | 'states' : | 154 | 'states' : |
155 | { | 155 | { |
156 | 'depthEnable' : true, | 156 | 'depthEnable' : true, |
157 | 'offset':[1.0, 0.1] | 157 | 'offset':[1.0, 0.1] |
158 | } | 158 | } |
159 | } | 159 | } |
160 | ] | 160 | ] |
161 | } | 161 | } |
162 | }; | 162 | }; |
163 | 163 | ||
164 | FlagMaterial.prototype = new PulseMaterial(); | 164 | FlagMaterial.prototype = new PulseMaterial(); |