diff options
author | hwc487 | 2012-06-06 16:34:41 -0700 |
---|---|---|
committer | hwc487 | 2012-06-06 16:34:41 -0700 |
commit | 6c994c4b90023cecf4fd0caafb404b859fe28f54 (patch) | |
tree | 75a4d813441ca6a3eb529dc88a749776459bb76e /js/lib/rdge | |
parent | 920436977433ea55c01ce1e73895d1db0a6abac1 (diff) | |
download | ninja-6c994c4b90023cecf4fd0caafb404b859fe28f54.tar.gz |
material cleanup and rearchitecture
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 2 | ||||
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 17 | ||||
-rw-r--r-- | js/lib/rdge/materials/deform-material.js | 16 | ||||
-rw-r--r-- | js/lib/rdge/materials/flag-material.js | 16 | ||||
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 18 | ||||
-rw-r--r-- | js/lib/rdge/materials/fly-material.js | 1 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 219 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 189 | ||||
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 102 | ||||
-rw-r--r-- | js/lib/rdge/materials/water-material.js | 45 |
10 files changed, 297 insertions, 328 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 4d19c9c1..30624f7b 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -108,8 +108,6 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
108 | /////////////////////////////////////////////////////////////////////// | 108 | /////////////////////////////////////////////////////////////////////// |
109 | // Methods | 109 | // Methods |
110 | /////////////////////////////////////////////////////////////////////// | 110 | /////////////////////////////////////////////////////////////////////// |
111 | // duplcate method requirde | ||
112 | this.dup = function() { return new BumpMetalMaterial(); }; | ||
113 | 111 | ||
114 | this.init = function( world ) | 112 | this.init = function( world ) |
115 | { | 113 | { |
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js index 2c7fced2..2153b857 100644 --- a/js/lib/rdge/materials/cloud-material.js +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -106,23 +106,6 @@ var CloudMaterial = function CloudMaterial() | |||
106 | /////////////////////////////////////////////////////////////////////// | 106 | /////////////////////////////////////////////////////////////////////// |
107 | // duplicate method required | 107 | // duplicate method required |
108 | /**************************************************************/ | 108 | /**************************************************************/ |
109 | this.dup = function (world) { | ||
110 | // save the world | ||
111 | if (world) this.setWorld(world); | ||
112 | |||
113 | // allocate a new uber material | ||
114 | var newMat = new CloudMaterial(); | ||
115 | |||
116 | // copy over the current values; | ||
117 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
118 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | ||
119 | var n = propNames.length; | ||
120 | for (var i = 0; i < n; i++) { | ||
121 | newMat.setProperty(propNames[i], propValues[i]); | ||
122 | } | ||
123 | |||
124 | return newMat; | ||
125 | }; | ||
126 | 109 | ||
127 | this.init = function (world) { | 110 | this.init = function (world) { |
128 | var GLWorld = require("js/lib/drawing/world").World, | 111 | var GLWorld = require("js/lib/drawing/world").World, |
diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index c7f9cadc..70742c77 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js | |||
@@ -37,22 +37,6 @@ var DeformMaterial = function DeformMaterial() { | |||
37 | // Methods | 37 | // Methods |
38 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
39 | // duplcate method requirde | 39 | // duplcate method requirde |
40 | this.dup = function (world) | ||
41 | { | ||
42 | // get the current values; | ||
43 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
44 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | ||
45 | |||
46 | // allocate a new material | ||
47 | var newMat = new DeformMaterial(); | ||
48 | |||
49 | // copy over the current values; | ||
50 | var n = propNames.length; | ||
51 | for (var i = 0; i < n; i++) | ||
52 | newMat.setProperty(propNames[i], propValues[i]); | ||
53 | |||
54 | return newMat; | ||
55 | }; | ||
56 | 40 | ||
57 | this.init = function (world) { | 41 | this.init = function (world) { |
58 | // save the world | 42 | // save the world |
diff --git a/js/lib/rdge/materials/flag-material.js b/js/lib/rdge/materials/flag-material.js index d1788fb8..aaf36ebf 100644 --- a/js/lib/rdge/materials/flag-material.js +++ b/js/lib/rdge/materials/flag-material.js | |||
@@ -51,22 +51,6 @@ var FlagMaterial = function FlagMaterial() { | |||
51 | // Methods | 51 | // Methods |
52 | /////////////////////////////////////////////////////////////////////// | 52 | /////////////////////////////////////////////////////////////////////// |
53 | // duplcate method requirde | 53 | // duplcate method requirde |
54 | this.dup = function( world ) | ||
55 | { | ||
56 | // get the current values; | ||
57 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
58 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | ||
59 | |||
60 | // allocate a new uber material | ||
61 | var newMat = new FlagMaterial(); | ||
62 | |||
63 | // copy over the current values; | ||
64 | var n = propNames.length; | ||
65 | for (var i = 0; i < n; i++) | ||
66 | newMat.setProperty(propNames[i], propValues[i]); | ||
67 | |||
68 | return newMat; | ||
69 | }; | ||
70 | 54 | ||
71 | this.setProperty = function( prop, value ) | 55 | this.setProperty = function( prop, value ) |
72 | { | 56 | { |
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js index 40da9305..e5498b65 100755 --- a/js/lib/rdge/materials/flat-material.js +++ b/js/lib/rdge/materials/flat-material.js | |||
@@ -34,7 +34,22 @@ var FlatMaterial = function FlatMaterial() { | |||
34 | // Methods | 34 | // Methods |
35 | /////////////////////////////////////////////////////////////////////// | 35 | /////////////////////////////////////////////////////////////////////// |
36 | // duplcate method requirde | 36 | // duplcate method requirde |
37 | this.dup = function () { return new FlatMaterial(); }; | 37 | this.dup = function( world ) |
38 | { | ||
39 | // get the current values; | ||
40 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
41 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | ||
42 | |||
43 | // allocate a new material | ||
44 | var newMat = new FlatMaterial(); | ||
45 | |||
46 | // copy over the current values; | ||
47 | var n = propNames.length; | ||
48 | for (var i = 0; i < n; i++) | ||
49 | newMat.setProperty(propNames[i], propValues[i]); | ||
50 | |||
51 | return newMat; | ||
52 | }; | ||
38 | 53 | ||
39 | this.init = function (world) { | 54 | this.init = function (world) { |
40 | // save the world | 55 | // save the world |
@@ -72,6 +87,7 @@ var FlatMaterial = function FlatMaterial() { | |||
72 | // make sure we have legitimate input | 87 | // make sure we have legitimate input |
73 | if (this.validateProperty(prop, value)) { | 88 | if (this.validateProperty(prop, value)) { |
74 | this._propValues[prop] = value; | 89 | this._propValues[prop] = value; |
90 | if (prop === 'color') this._color = value.slice(); | ||
75 | if (this._shader && this._shader.colorMe) { | 91 | if (this._shader && this._shader.colorMe) { |
76 | this._shader.colorMe[prop].set(value); | 92 | this._shader.colorMe[prop].set(value); |
77 | } | 93 | } |
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js index ca38cc83..5e14f3af 100644 --- a/js/lib/rdge/materials/fly-material.js +++ b/js/lib/rdge/materials/fly-material.js | |||
@@ -106,6 +106,7 @@ var flyMaterialDef = | |||
106 | { | 106 | { |
107 | 'u_tex0': { 'type' : 'tex2d' }, | 107 | 'u_tex0': { 'type' : 'tex2d' }, |
108 | 'u_time' : { 'type' : 'float' }, | 108 | 'u_time' : { 'type' : 'float' }, |
109 | 'u_speed' : { 'type' : 'float' }, | ||
109 | 'u_resolution' : { 'type' : 'vec2' }, | 110 | 'u_resolution' : { 'type' : 'vec2' }, |
110 | }, | 111 | }, |
111 | 112 | ||
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 856513e2..d2586b58 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -4,6 +4,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Texture = require("js/lib/rdge/texture").Texture; | ||
8 | |||
9 | |||
7 | /////////////////////////////////////////////////////////////////////// | 10 | /////////////////////////////////////////////////////////////////////// |
8 | // Class GLMaterial | 11 | // Class GLMaterial |
9 | // GL representation of a material. | 12 | // GL representation of a material. |
@@ -15,19 +18,16 @@ var Material = function GLMaterial( world ) { | |||
15 | this._name = "GLMaterial"; | 18 | this._name = "GLMaterial"; |
16 | this._shaderName = "undefined"; | 19 | this._shaderName = "undefined"; |
17 | 20 | ||
21 | this._time = 0.0; | ||
22 | this._dTime = 0.01; | ||
23 | |||
18 | // keep a reference to the owning GLWorld | 24 | // keep a reference to the owning GLWorld |
19 | this._world = null; | 25 | this._world = null; |
20 | if(world) { | 26 | if(world) { |
21 | this._world = world; | 27 | this._world = world; |
22 | } | 28 | } |
23 | 29 | ||
24 | this._shininess = 60; | 30 | this._glTextures = []; // indexed by uniform name |
25 | |||
26 | this._ambient = [0.0, 0.0, 0.0, 1.0]; | ||
27 | this._diffuse = [0.0, 0.0, 0.0, 1.0]; | ||
28 | this._specular = [0.0, 0.0, 0.0, 1.0]; | ||
29 | |||
30 | this._texture = null; | ||
31 | 31 | ||
32 | // vertex deformation variables | 32 | // vertex deformation variables |
33 | this._hasVertexDeformation = false; | 33 | this._hasVertexDeformation = false; |
@@ -46,13 +46,6 @@ var Material = function GLMaterial( world ) { | |||
46 | /////////////////////////////////////////////////////////////////////// | 46 | /////////////////////////////////////////////////////////////////////// |
47 | // Property Accessors | 47 | // Property Accessors |
48 | /////////////////////////////////////////////////////////////////////// | 48 | /////////////////////////////////////////////////////////////////////// |
49 | this.getShininess = function() { | ||
50 | return this._shininess; | ||
51 | }; | ||
52 | |||
53 | this.setShininess = function(s) { | ||
54 | this._shininess = s; | ||
55 | }; | ||
56 | 49 | ||
57 | this.setName = function(n) { | 50 | this.setName = function(n) { |
58 | this._name = n; | 51 | this._name = n; |
@@ -78,30 +71,6 @@ var Material = function GLMaterial( world ) { | |||
78 | return this._world; | 71 | return this._world; |