diff options
author | Eric Guzman | 2012-04-02 15:36:08 -0700 |
---|---|---|
committer | Eric Guzman | 2012-04-02 15:36:08 -0700 |
commit | 0241bf331b7e06e206a54be441edf2f4c7261f63 (patch) | |
tree | b7e2f9cad73eed4fc616cf1841cd0be02bd955d4 /js/lib/rdge | |
parent | dde5b5054f93db493e5d4d502e677f5781334b08 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-0241bf331b7e06e206a54be441edf2f4c7261f63.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 40 | ||||
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 300 | ||||
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 21 | ||||
-rw-r--r-- | js/lib/rdge/materials/julia-material.js | 6 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 53 | ||||
-rw-r--r-- | js/lib/rdge/materials/mandel-material.js | 6 | ||||
-rw-r--r-- | js/lib/rdge/materials/plasma-material.js | 18 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 44 | ||||
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 73 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 54 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 27 | ||||
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 28 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 180 | ||||
-rw-r--r-- | js/lib/rdge/materials/water-material.js | 103 |
14 files changed, 924 insertions, 29 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index fa6f5300..2ef83227 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -152,6 +152,46 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
152 | } | 152 | } |
153 | }; | 153 | }; |
154 | 154 | ||
155 | this.exportJSON = function() | ||
156 | { | ||
157 | var jObj = | ||
158 | { | ||
159 | 'material' : this.getShaderName(), | ||
160 | 'name' : this.getName(), | ||
161 | 'lightDiff' : this.getLightDiff(), | ||
162 | 'diffuseTexture' : this.getDiffuseTexture(), | ||
163 | 'specularTexture' : this.getSpecularTexture(), | ||
164 | 'normalMap' : this.getNormalTexture() | ||
165 | }; | ||
166 | |||
167 | return jObj; | ||
168 | }; | ||
169 | |||
170 | this.importJSON = function( jObj ) | ||
171 | { | ||
172 | if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); | ||
173 | this.setName( jObj.name ); | ||
174 | |||
175 | try | ||
176 | { | ||
177 | var lightDiff = jObj.lightDiff, | ||
178 | dt = jObj.diffuseTexture, | ||
179 | st = jObj.specularTexture, | ||
180 | nt = jObj.normalMap; | ||
181 | |||
182 | this.setProperty( "lightDiff", lightDiff); | ||
183 | this.setProperty( "diffuseTexture", dt ); | ||
184 | this.setProperty( "specularTexture", st ); | ||
185 | this.setProperty( "normalMap", nt ); | ||
186 | } | ||
187 | catch (e) | ||
188 | { | ||
189 | throw new Error( "could not import BumpMetal material: " + jObj ); | ||
190 | } | ||
191 | |||
192 | return; | ||
193 | }; | ||
194 | |||
155 | this.export = function() | 195 | this.export = function() |
156 | { | 196 | { |
157 | // every material needs the base type and instance name | 197 | // every material needs the base type and instance name |
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js new file mode 100644 index 00000000..85088f91 --- /dev/null +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -0,0 +1,300 @@ | |||
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 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; | ||
8 | var Material = require("js/lib/rdge/materials/material").Material; | ||
9 | /////////////////////////////////////////////////////////////////////// | ||
10 | // Class GLMaterial | ||
11 | // RDGE representation of a material. | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | var CloudMaterial = function CloudMaterial() { | ||
14 | /////////////////////////////////////////////////////////////////////// | ||
15 | // Instance variables | ||
16 | /////////////////////////////////////////////////////////////////////// | ||
17 | this._name = "CloudMaterial"; | ||
18 | this._shaderName = "cloud"; | ||
19 | |||
20 | this._texMap = 'assets/images/cloud2.jpg'; | ||
21 | this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; | ||
22 | |||
23 | this._time = 0.0; | ||
24 | this._dTime = 0.01; | ||
25 | |||
26 | /////////////////////////////////////////////////////////////////////// | ||
27 | // Property Accessors | ||
28 | /////////////////////////////////////////////////////////////////////// | ||
29 | this.getName = function() { return this._name; }; | ||
30 | this.getShaderName = function() { return this._shaderName; }; | ||
31 | |||
32 | this.getTextureMap = function() { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null }; | ||
33 | this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); }; | ||
34 | |||
35 | this.setDiffuseColor = function(c) { this._propValues[this._propNames[1]] = c.slice(0); this.updateColor(); }; | ||
36 | this.getDiffuseColor = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null; }; | ||
37 | |||
38 | this.isAnimated = function() { return true; }; | ||
39 | |||
40 | /////////////////////////////////////////////////////////////////////// | ||
41 | // Material Property Accessors | ||
42 | /////////////////////////////////////////////////////////////////////// | ||
43 | this._propNames = ["texmap", "diffusecolor"]; | ||
44 | this._propLabels = ["Texture map", "Diffuse Color"]; | ||
45 | this._propTypes = ["file", "color"]; | ||
46 | this._propValues = []; | ||
47 | |||
48 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | ||
49 | this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); | ||
50 | |||
51 | this.setProperty = function( prop, value ) | ||
52 | { | ||
53 | if (prop === 'color') prop = 'diffusecolor'; | ||
54 | |||
55 | // make sure we have legitimate imput | ||
56 | var ok = this.validateProperty( prop, value ); | ||
57 | if (!ok) { | ||
58 | console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value ); | ||
59 | } | ||
60 | |||
61 | switch (prop) | ||
62 | { | ||
63 | case "texmap": | ||
64 | this.setTextureMap(value); | ||
65 | break; | ||
66 | |||
67 | case "diffusecolor": | ||
68 | this.setDiffuseColor( value ); | ||
69 | break; | ||
70 | |||
71 | case "color": | ||
72 | break; | ||
73 | } | ||
74 | }; | ||
75 | /////////////////////////////////////////////////////////////////////// | ||
76 | |||
77 | |||
78 | /////////////////////////////////////////////////////////////////////// | ||
79 | // Methods | ||
80 | /////////////////////////////////////////////////////////////////////// | ||
81 | // duplcate method requirde | ||
82 | this.dup = function( world ) | ||
83 | { | ||
84 | // save the world | ||
85 | if (world) this.setWorld( world ); | ||
86 | |||
87 | // allocate a new uber material | ||
88 | var newMat = new CloudMaterial(); | ||
89 | |||
90 | // copy over the current values; | ||
91 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
92 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
93 | var n = propNames.length; | ||
94 | for (var i=0; i<n; i++) { | ||
95 | newMat.setProperty( propNames[i], propValues[i] ); | ||
96 | } | ||
97 | |||
98 | return newMat; | ||
99 | }; | ||
100 | |||
101 | this.init = function( world ) | ||
102 | { | ||
103 | // save the world | ||
104 | if (world) this.setWorld( world ); | ||
105 | |||
106 | // this variable declared above is inherited set to a smaller delta. | ||
107 | // the cloud material runs a little faster | ||
108 | this._dTime = 0.01; | ||
109 | |||
110 | // set up the shader | ||
111 | this._shader = new jshader(); | ||
112 | this._shader.def = cloudMaterialDef; | ||
113 | this._shader.init(); | ||
114 | |||
115 | // set up the material node | ||
116 | this._materialNode = createMaterialNode("cloudMaterial" + "_" + world.generateUniqueNodeID()); | ||
117 | this._materialNode.setShader(this._shader); | ||
118 | |||
119 | this._time = 0; | ||
120 | if (this._shader && this._shader['default']) { | ||
121 | this._shader['default'].u_time.set( [this._time] ); | ||
122 | this._shader['default'].u_DiffuseColor.set( this._diffuseColor ); | ||
123 | } | ||
124 | |||
125 | // set the shader values in the shader | ||
126 | this.updateTexture(); | ||
127 | this.update( 0 ); | ||
128 | }; | ||
129 | |||
130 | this.updateColor = function() | ||
131 | { | ||
132 | var material = this._materialNode; | ||
133 | if (material) | ||
134 | { | ||
135 | var technique = material.shaderProgram['default']; | ||
136 | var renderer = g_Engine.getContext().renderer; | ||
137 | if (renderer && technique) { | ||
138 | var color = this._propValues[this._propNames[1]]; | ||
139 | technique.u_DiffuseColor.set( this._diffuseColor ); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | this.updateTexture |