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/keleidoscope-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/keleidoscope-material.js')
-rw-r--r-- | js/lib/rdge/materials/keleidoscope-material.js | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/js/lib/rdge/materials/keleidoscope-material.js b/js/lib/rdge/materials/keleidoscope-material.js index 8ad02963..9d395370 100644 --- a/js/lib/rdge/materials/keleidoscope-material.js +++ b/js/lib/rdge/materials/keleidoscope-material.js | |||
@@ -35,13 +35,13 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() { | |||
35 | /////////////////////////////////////////////////////////////////////// | 35 | /////////////////////////////////////////////////////////////////////// |
36 | // Instance variables | 36 | // Instance variables |
37 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
38 | this._name = "Keleidoscope"; | 38 | this._name = "Keleidoscope"; |
39 | this._shaderName = "keleidoscope"; | 39 | this._shaderName = "keleidoscope"; |
40 | 40 | ||
41 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; | 41 | this._defaultTexMap = 'assets/images/rocky-normal.jpg'; |
42 | 42 | ||
43 | this._time = 0.0; | 43 | this._time = 0.0; |
44 | this._dTime = 0.01; | 44 | this._dTime = 0.01; |
45 | 45 | ||
46 | // array textures indexed by shader uniform name | 46 | // array textures indexed by shader uniform name |
47 | this._glTextures = []; | 47 | this._glTextures = []; |
@@ -49,21 +49,21 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() { | |||
49 | /////////////////////////////////////////////////////////////////////// | 49 | /////////////////////////////////////////////////////////////////////// |
50 | // Properties | 50 | // Properties |
51 | /////////////////////////////////////////////////////////////////////// | 51 | /////////////////////////////////////////////////////////////////////// |
52 | // all defined in parent PulseMaterial.js | 52 | // all defined in parent PulseMaterial.js |
53 | // load the local default value | 53 | // load the local default value |
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 keleidoscopeMaterialDef; } | 66 | this.getShaderDef = function() { return keleidoscopeMaterialDef; } |
67 | 67 | ||
68 | /////////////////////////////////////////////////////////////////////// | 68 | /////////////////////////////////////////////////////////////////////// |
69 | 69 | ||
@@ -71,31 +71,31 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() { | |||
71 | /////////////////////////////////////////////////////////////////////// | 71 | /////////////////////////////////////////////////////////////////////// |
72 | // Methods | 72 | // Methods |
73 | /////////////////////////////////////////////////////////////////////// | 73 | /////////////////////////////////////////////////////////////////////// |
74 | // duplcate method requirde | 74 | // duplcate method requirde |
75 | 75 | ||
76 | this.init = function( world ) { | 76 | this.init = function( world ) { |
77 | // save the world | 77 | // save the world |
78 | if (world) this.setWorld( world ); | 78 | if (world) this.setWorld( world ); |
79 | 79 | ||
80 | // set up the shader | 80 | // set up the shader |
81 | this._shader = new RDGE.jshader(); | 81 | this._shader = new RDGE.jshader(); |
82 | this._shader.def = keleidoscopeMaterialDef; | 82 | this._shader.def = keleidoscopeMaterialDef; |
83 | this._shader.init(); | 83 | this._shader.init(); |
84 | 84 | ||
85 | // set up the material node | 85 | // set up the material node |
86 | this._materialNode = RDGE.createMaterialNode("keleidoscopeMaterial" + "_" + world.generateUniqueNodeID()); | 86 | this._materialNode = RDGE.createMaterialNode("keleidoscopeMaterial" + "_" + world.generateUniqueNodeID()); |
87 | this._materialNode.setShader(this._shader); | 87 | this._materialNode.setShader(this._shader); |
88 | 88 | ||
89 | this._time = 0; | 89 | this._time = 0; |
90 | if (this._shader && this._shader['default']) { | 90 | if (this._shader && this._shader['default']) { |
91 | this._shader['default'].u_time.set( [this._time] ); | 91 | this._shader['default'].u_time.set( [this._time] ); |
92 | } | 92 | } |
93 | 93 | ||
94 | // set the shader values in the shader | 94 | // set the shader values in the shader |
95 | this.setShaderValues(); | 95 | this.setShaderValues(); |
96 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 96 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); |
97 | this.update( 0 ); | 97 | this.update( 0 ); |
98 | }; | 98 | }; |
99 | 99 | ||
100 | this.resetToDefault = function() | 100 | this.resetToDefault = function() |
101 | { | 101 | { |
@@ -105,51 +105,51 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() { | |||
105 | var nProps = this._propNames.length; | 105 | var nProps = this._propNames.length; |
106 | for (var i=0; i<nProps; i++) | 106 | for (var i=0; i<nProps; i++) |
107 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | 107 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); |
108 | }; | 108 | }; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | /////////////////////////////////////////////////////////////////////////////////////// | 111 | /////////////////////////////////////////////////////////////////////////////////////// |
112 | // RDGE shader | 112 | // RDGE shader |
113 | 113 | ||
114 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 114 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
115 | var keleidoscopeMaterialDef = | 115 | var keleidoscopeMaterialDef = |
116 | {'shaders': | 116 | {'shaders': |
117 | { | 117 | { |
118 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 118 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", |
119 | 'defaultFShader':"assets/shaders/Keleidoscope.frag.glsl" | 119 | 'defaultFShader':"assets/shaders/Keleidoscope.frag.glsl" |
120 | }, | 120 | }, |
121 | 'techniques': | 121 | 'techniques': |
122 | { | 122 | { |
123 | 'default': | 123 | 'default': |
124 | [ | 124 | [ |
125 | { | 125 | { |
126 | 'vshader' : 'defaultVShader', | 126 | 'vshader' : 'defaultVShader', |
127 | 'fshader' : 'defaultFShader', | 127 | 'fshader' : 'defaultFShader', |
128 | // attributes | 128 | // attributes |
129 | 'attributes' : | 129 | 'attributes' : |
130 | { | 130 | { |
131 | 'vert' : { 'type' : 'vec3' }, | 131 | 'vert' : { 'type' : 'vec3' }, |
132 | 'normal' : { 'type' : 'vec3' }, | 132 | 'normal' : { 'type' : 'vec3' }, |
133 | 'texcoord' : { 'type' : 'vec2' } | 133 | 'texcoord' : { 'type' : 'vec2' } |
134 | }, | 134 | }, |
135 | // parameters | 135 | // parameters |
136 | 'params' : | 136 | 'params' : |
137 | { | 137 | { |
138 | 'u_tex0': { 'type' : 'tex2d' }, | 138 | 'u_tex0': { 'type' : 'tex2d' }, |
139 | 'u_speed' : { 'type' : 'float' }, | 139 | 'u_speed' : { 'type' : 'float' }, |
140 | 'u_time' : { 'type' : 'float' }, | 140 | 'u_time' : { 'type' : 'float' }, |
141 | 'u_resolution' : { 'type' : 'vec2' }, | 141 | 'u_resolution' : { 'type' : 'vec2' }, |
142 | }, | 142 | }, |
143 | 143 | ||
144 | // render states | 144 | // render states |
145 | 'states' : | 145 | 'states' : |
146 | { | 146 | { |
147 | 'depthEnable' : true, | 147 | 'depthEnable' : true, |
148 | 'offset':[1.0, 0.1] | 148 | 'offset':[1.0, 0.1] |
149 | } | 149 | } |
150 | } | 150 | } |
151 | ] | 151 | ] |
152 | } | 152 | } |
153 | }; | 153 | }; |
154 | 154 | ||
155 | KeleidoscopeMaterial.prototype = new PulseMaterial(); | 155 | KeleidoscopeMaterial.prototype = new PulseMaterial(); |