diff options
author | Eric Guzman | 2012-02-13 10:30:26 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-13 10:30:26 -0800 |
commit | 672e6f61647b1b8a5f6f5831284fa44bcb7be883 (patch) | |
tree | 0c15656f1f82f194bfcab68634a88f68fd3d42cb /js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js | |
parent | 586c3f7bbea04e62638e5ed8cdce9933e88c0b67 (diff) | |
parent | e142611e22718b1f1d1696902ad9161ec5f33f98 (diff) | |
download | ninja-672e6f61647b1b8a5f6f5831284fa44bcb7be883.tar.gz |
Merge branch 'refs/heads/master' into PresetsPanel
Diffstat (limited to 'js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js b/js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js deleted file mode 100644 index 8f94f47b..00000000 --- a/js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | |||
9 | /////////////////////////////////////////////////////////////////////// | ||
10 | // Class GLMaterial | ||
11 | // RDGE representation of a material. | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | function KeleidoscopeMaterial() | ||
14 | { | ||
15 | // initialize the inherited members | ||
16 | this.inheritedFrom = PulseMaterial; | ||
17 | this.inheritedFrom(); | ||
18 | |||
19 | /////////////////////////////////////////////////////////////////////// | ||
20 | // Instance variables | ||
21 | /////////////////////////////////////////////////////////////////////// | ||
22 | this._name = "KeleidoscopeMaterial"; | ||
23 | this._shaderName = "keleidoscope"; | ||
24 | |||
25 | this._texMap = 'assets/images/rocky-normal.jpg'; | ||
26 | |||
27 | this._time = 0.0; | ||
28 | this._dTime = 0.01; | ||
29 | |||
30 | /////////////////////////////////////////////////////////////////////// | ||
31 | // Properties | ||
32 | /////////////////////////////////////////////////////////////////////// | ||
33 | // all defined in parent PulseMaterial.js | ||
34 | // load the local default value | ||
35 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | ||
36 | |||
37 | /////////////////////////////////////////////////////////////////////// | ||
38 | // Material Property Accessors | ||
39 | /////////////////////////////////////////////////////////////////////// | ||
40 | |||
41 | /////////////////////////////////////////////////////////////////////// | ||
42 | |||
43 | |||
44 | /////////////////////////////////////////////////////////////////////// | ||
45 | // Methods | ||
46 | /////////////////////////////////////////////////////////////////////// | ||
47 | // duplcate method requirde | ||
48 | this.dup = function( world ) | ||
49 | { | ||
50 | // allocate a new uber material | ||
51 | var newMat = new KeleidoscopeMaterial(); | ||
52 | |||
53 | // copy over the current values; | ||
54 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
55 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
56 | var n = propNames.length; | ||
57 | for (var i=0; i<n; i++) | ||
58 | newMat.setProperty( propNames[i], propValues[i] ); | ||
59 | |||
60 | return newMat; | ||
61 | } | ||
62 | |||
63 | this.init = function( world ) | ||
64 | { | ||
65 | // set up the shader | ||
66 | this._shader = new jshader(); | ||
67 | this._shader.def = keleidoscopeMaterialDef; | ||
68 | this._shader.init(); | ||
69 | |||
70 | // set up the material node | ||
71 | this._materialNode = createMaterialNode("keleidoscopeMaterial"); | ||
72 | this._materialNode.setShader(this._shader); | ||
73 | |||
74 | this._time = 0; | ||
75 | if (this._shader && this._shader.default) | ||
76 | this._shader.default.u_time.set( [this._time] ); | ||
77 | |||
78 | // set the shader values in the shader | ||
79 | this.updateTexture(); | ||
80 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | ||
81 | this.update( 0 ); | ||
82 | } | ||
83 | |||
84 | this.update = function( time ) | ||
85 | { | ||
86 | var material = this._materialNode; | ||
87 | if (material) | ||
88 | { | ||
89 | var technique = material.shaderProgram.default; | ||
90 | var renderer = g_Engine.getContext().renderer; | ||
91 | if (renderer && technique) | ||
92 | { | ||
93 | if (this._shader && this._shader.default) | ||
94 | this._shader.default.u_time.set( [this._time] ); | ||
95 | this._time = time; | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /////////////////////////////////////////////////////////////////////////////////////// | ||
102 | // RDGE shader | ||
103 | |||
104 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | ||
105 | var keleidoscopeMaterialDef = | ||
106 | {'shaders': | ||
107 | { | ||
108 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | ||
109 | 'defaultFShader':"assets/shaders/Keleidoscope.frag.glsl" | ||
110 | }, | ||
111 | 'techniques': | ||
112 | { | ||
113 | 'default': | ||
114 | [ | ||
115 | { | ||
116 | 'vshader' : 'defaultVShader', | ||
117 | 'fshader' : 'defaultFShader', | ||
118 | // attributes | ||
119 | 'attributes' : | ||
120 | { | ||
121 | 'vert' : { 'type' : 'vec3' }, | ||
122 | 'normal' : { 'type' : 'vec3' }, | ||
123 | 'texcoord' : { 'type' : 'vec2' } | ||
124 | }, | ||
125 | // parameters | ||
126 | 'params' : | ||
127 | { | ||
128 | 'u_tex0': { 'type' : 'tex2d' }, | ||
129 | 'u_time' : { 'type' : 'float' }, | ||
130 | 'u_resolution' : { 'type' : 'vec2' }, | ||
131 | }, | ||
132 | |||
133 | // render states | ||
134 | 'states' : | ||
135 | { | ||
136 | 'depthEnable' : true, | ||
137 | 'offset':[1.0, 0.1] | ||
138 | }, | ||
139 | }, | ||
140 | ] | ||
141 | } | ||
142 | }; | ||
143 | |||
144 | |||
145 | |||
146 | |||