diff options
author | Jon Reid | 2012-03-06 14:15:18 -0800 |
---|---|---|
committer | Jon Reid | 2012-03-06 14:15:18 -0800 |
commit | 78d42c7cbf9205ed2e4faee1d8ddf02a4725edd3 (patch) | |
tree | c395b703f21431dcb4432c725f4c860431add61b /js/helper-classes/RDGE/Materials/MandelMaterial.js | |
parent | fa8b81d4f436c0b8564c8dcdd22d8dd6d5bccfaa (diff) | |
parent | 60bba95eaffa8b5c741c6c85fb84b327cd75d6c3 (diff) | |
download | ninja-78d42c7cbf9205ed2e4faee1d8ddf02a4725edd3.tar.gz |
Merge branch 'Timeline-uber' into timeline-serialized
Diffstat (limited to 'js/helper-classes/RDGE/Materials/MandelMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/MandelMaterial.js | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/js/helper-classes/RDGE/Materials/MandelMaterial.js b/js/helper-classes/RDGE/Materials/MandelMaterial.js deleted file mode 100644 index 25b08404..00000000 --- a/js/helper-classes/RDGE/Materials/MandelMaterial.js +++ /dev/null | |||
@@ -1,151 +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 MandelMaterial() | ||
14 | { | ||
15 | // initialize the inherited members | ||
16 | this.inheritedFrom = PulseMaterial; | ||
17 | this.inheritedFrom(); | ||
18 | |||
19 | /////////////////////////////////////////////////////////////////////// | ||
20 | // Instance variables | ||
21 | /////////////////////////////////////////////////////////////////////// | ||
22 | this._name = "MandelMaterial"; | ||
23 | this._shaderName = "mandel"; | ||
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 | // no properties | ||
34 | this._propNames = []; | ||
35 | this._propLabels = []; | ||
36 | this._propTypes = []; | ||
37 | this._propValues = []; | ||
38 | |||
39 | /////////////////////////////////////////////////////////////////////// | ||
40 | // Material Property Accessors | ||
41 | /////////////////////////////////////////////////////////////////////// | ||
42 | |||
43 | /////////////////////////////////////////////////////////////////////// | ||
44 | |||
45 | this.isAnimated = function() { return true; } | ||
46 | |||
47 | /////////////////////////////////////////////////////////////////////// | ||
48 | // Methods | ||
49 | /////////////////////////////////////////////////////////////////////// | ||
50 | // duplcate method requirde | ||
51 | this.dup = function( world ) | ||
52 | { | ||
53 | // allocate a new uber material | ||
54 | var newMat = new MandelMaterial(); | ||
55 | |||
56 | // copy over the current values; | ||
57 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
58 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
59 | var n = propNames.length; | ||
60 | for (var i=0; i<n; i++) | ||
61 | newMat.setProperty( propNames[i], propValues[i] ); | ||
62 | |||
63 | return newMat; | ||
64 | } | ||
65 | |||
66 | this.init = function( world ) | ||
67 | { | ||
68 | // save the world | ||
69 | if (world) this.setWorld( world ); | ||
70 | |||
71 | // set up the shader | ||
72 | this._shader = new jshader(); | ||
73 | this._shader.def = MandelMaterialDef; | ||
74 | this._shader.init(); | ||
75 | |||
76 | // set up the material node | ||
77 | this._materialNode = createMaterialNode("mandelMaterial"); | ||
78 | this._materialNode.setShader(this._shader); | ||
79 | |||
80 | this._time = 0; | ||
81 | if (this._shader && this._shader.default) | ||
82 | this._shader.default.u_time.set( [this._time] ); | ||
83 | |||
84 | // set the shader values in the shader | ||
85 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | ||
86 | this.update( 0 ); | ||
87 | } | ||
88 | |||
89 | this.update = function( time ) | ||
90 | { | ||
91 | var material = this._materialNode; | ||
92 | if (material) | ||
93 | { | ||
94 | var technique = material.shaderProgram.default; | ||
95 | var renderer = g_Engine.getContext().renderer; | ||
96 | if (renderer && technique) | ||
97 | { | ||
98 | if (this._shader && this._shader.default) | ||
99 | this._shader.default.u_time.set( [this._time] ); | ||
100 | this._time = time; | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | |||
106 | /////////////////////////////////////////////////////////////////////////////////////// | ||
107 | // RDGE shader | ||
108 | |||
109 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | ||
110 | var MandelMaterialDef = | ||
111 | {'shaders': | ||
112 | { | ||
113 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | ||
114 | 'defaultFShader':"assets/shaders/Mandel.frag.glsl" | ||
115 | }, | ||
116 | 'techniques': | ||
117 | { | ||
118 | 'default': | ||
119 | [ | ||
120 | { | ||
121 | 'vshader' : 'defaultVShader', | ||
122 | 'fshader' : 'defaultFShader', | ||
123 | // attributes | ||
124 | 'attributes' : | ||
125 | { | ||
126 | 'vert' : { 'type' : 'vec3' }, | ||
127 | 'normal' : { 'type' : 'vec3' }, | ||
128 | 'texcoord' : { 'type' : 'vec2' } | ||
129 | }, | ||
130 | // parameters | ||
131 | 'params' : | ||
132 | { | ||
133 | 'u_tex0': { 'type' : 'tex2d' }, | ||
134 | 'u_time' : { 'type' : 'float' }, | ||
135 | 'u_resolution' : { 'type' : 'vec2' }, | ||
136 | }, | ||
137 | |||
138 | // render states | ||
139 | 'states' : | ||
140 | { | ||
141 | 'depthEnable' : true, | ||
142 | 'offset':[1.0, 0.1] | ||
143 | }, | ||
144 | }, | ||
145 | ] | ||
146 | } | ||
147 | }; | ||
148 | |||
149 | |||
150 | |||
151 | |||