aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/JuliaMaterial.js
diff options
context:
space:
mode:
authorEric Guzman2012-02-13 10:29:49 -0800
committerEric Guzman2012-02-13 10:29:49 -0800
commite4893f7d3c3b9bd7967973197c3ffb5d3a075c91 (patch)
treef3d4fd9d96ba0dcf846fbf66153fb443bd60f767 /js/helper-classes/RDGE/Materials/JuliaMaterial.js
parentef032412216d437ce1c7dfc9050ab41adf0594c0 (diff)
parente142611e22718b1f1d1696902ad9161ec5f33f98 (diff)
downloadninja-e4893f7d3c3b9bd7967973197c3ffb5d3a075c91.tar.gz
Merge branch 'refs/heads/master' into TreeComponents
Diffstat (limited to 'js/helper-classes/RDGE/Materials/JuliaMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/JuliaMaterial.js147
1 files changed, 0 insertions, 147 deletions
diff --git a/js/helper-classes/RDGE/Materials/JuliaMaterial.js b/js/helper-classes/RDGE/Materials/JuliaMaterial.js
deleted file mode 100644
index 69884d18..00000000
--- a/js/helper-classes/RDGE/Materials/JuliaMaterial.js
+++ /dev/null
@@ -1,147 +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///////////////////////////////////////////////////////////////////////
13function JuliaMaterial()
14{
15 // initialize the inherited members
16 this.inheritedFrom = PulseMaterial;
17 this.inheritedFrom();
18
19 ///////////////////////////////////////////////////////////////////////
20 // Instance variables
21 ///////////////////////////////////////////////////////////////////////
22 this._name = "JuliaMaterial";
23 this._shaderName = "julia";
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
46 ///////////////////////////////////////////////////////////////////////
47 // Methods
48 ///////////////////////////////////////////////////////////////////////
49 // duplcate method requirde
50 this.dup = function( world )
51 {
52 // allocate a new uber material
53 var newMat = new JuliaMaterial();
54
55 // copy over the current values;
56 var propNames = [], propValues = [], propTypes = [], propLabels = [];
57 this.getAllProperties( propNames, propValues, propTypes, propLabels);
58 var n = propNames.length;
59 for (var i=0; i<n; i++)
60 newMat.setProperty( propNames[i], propValues[i] );
61
62 return newMat;
63 }
64
65 this.init = function( world )
66 {
67 // set up the shader
68 this._shader = new jshader();
69 this._shader.def = JuliaMaterialDef;
70 this._shader.init();
71
72 // set up the material node
73 this._materialNode = createMaterialNode("juliaMaterial");
74 this._materialNode.setShader(this._shader);
75
76 this._time = 0;
77 if (this._shader && this._shader.default)
78 this._shader.default.u_time.set( [this._time] );
79
80 // set the shader values in the shader
81 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
82 this.update( 0 );
83 }
84
85 this.update = function( time )
86 {
87 var material = this._materialNode;
88 if (material)
89 {
90 var technique = material.shaderProgram.default;
91 var renderer = g_Engine.getContext().renderer;
92 if (renderer && technique)
93 {
94 if (this._shader && this._shader.default)
95 this._shader.default.u_time.set( [this._time] );
96 this._time = time;
97 }
98 }
99 }
100}
101
102///////////////////////////////////////////////////////////////////////////////////////
103// RDGE shader
104
105// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
106var JuliaMaterialDef =
107{'shaders':
108 {
109 'defaultVShader':"assets/shaders/Basic.vert.glsl",
110 'defaultFShader':"assets/shaders/Julia.frag.glsl"
111 },
112 'techniques':
113 {
114 'default':
115 [
116 {
117 'vshader' : 'defaultVShader',
118 'fshader' : 'defaultFShader',
119 // attributes
120 'attributes' :
121 {
122 'vert' : { 'type' : 'vec3' },
123 'normal' : { 'type' : 'vec3' },
124 'texcoord' : { 'type' : 'vec2' }
125 },
126 // parameters
127 'params' :
128 {
129 'u_tex0': { 'type' : 'tex2d' },
130 'u_time' : { 'type' : 'float' },
131 'u_resolution' : { 'type' : 'vec2' },
132 },
133
134 // render states
135 'states' :
136 {
137 'depthEnable' : true,
138 'offset':[1.0, 0.1]
139 },
140 },
141 ]
142 }
143};
144
145
146
147