diff options
author | John Mayhew | 2012-04-02 16:28:39 -0700 |
---|---|---|
committer | John Mayhew | 2012-04-02 16:28:39 -0700 |
commit | b4155fb4c33675a8a7cd37473513718043fdf0ba (patch) | |
tree | 3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/lib/rdge/materials/plasma-material.js | |
parent | 5ba9aeac94c86049423fd5d4b37b277263939c13 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/helper-classes/RDGE/rdge-compiled.js
js/helper-classes/RDGE/runtime/GLRuntime.js
js/helper-classes/RDGE/src/core/script/MeshManager.js
js/helper-classes/RDGE/src/core/script/engine.js
js/helper-classes/RDGE/src/core/script/fx/ssao.js
js/helper-classes/RDGE/src/core/script/init_state.js
js/helper-classes/RDGE/src/core/script/run_state.js
js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
js/helper-classes/RDGE/src/core/script/utilities.js
js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
js/helper-classes/RDGE/src/tools/rdge-compiled.js
js/lib/drawing/world.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/linear-gradient-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-blur-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
js/preloader/Preloader.js
Diffstat (limited to 'js/lib/rdge/materials/plasma-material.js')
-rw-r--r-- | js/lib/rdge/materials/plasma-material.js | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js index d52f4b88..02172a6b 100644 --- a/js/lib/rdge/materials/plasma-material.js +++ b/js/lib/rdge/materials/plasma-material.js | |||
@@ -17,8 +17,6 @@ var PlasmaMaterial = function PlasmaMaterial() { | |||
17 | this._dTime = 0.01; | 17 | this._dTime = 0.01; |
18 | this._speed = 1.0; | 18 | this._speed = 1.0; |
19 | 19 | ||
20 | this._color = [1,0,0,1]; | ||
21 | |||
22 | 20 | ||
23 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
24 | // Property Accessors | 22 | // Property Accessors |
@@ -30,20 +28,12 @@ var PlasmaMaterial = function PlasmaMaterial() { | |||
30 | /////////////////////////////////////////////////////////////////////// | 28 | /////////////////////////////////////////////////////////////////////// |
31 | // Material Property Accessors | 29 | // Material Property Accessors |
32 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
33 | this._propNames = ["color"]; | 31 | |
34 | this._propLabels = ["Color"]; | 32 | this.setProperty = function( prop, value ) |
35 | this._propTypes = ["color"]; | 33 | { |
36 | this._propValues = []; | 34 | // plasma has no properties |
37 | |||
38 | this._propValues[ this._propNames[0] ] = this._color; | ||
39 | |||
40 | this.setProperty = function( prop, value ) { | ||
41 | // make sure we have legitimate imput | ||
42 | if (this.validateProperty( prop, value )) { | ||
43 | this._color = value.slice(0); | ||
44 | this._shader['default'][prop].set(value); | ||
45 | } | ||
46 | }; | 35 | }; |
36 | |||
47 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
48 | 38 | ||
49 | /////////////////////////////////////////////////////////////////////// | 39 | /////////////////////////////////////////////////////////////////////// |
@@ -54,7 +44,10 @@ var PlasmaMaterial = function PlasmaMaterial() { | |||
54 | return new PlasmaMaterial(); | 44 | return new PlasmaMaterial(); |
55 | }; | 45 | }; |
56 | 46 | ||
57 | this.init = function() { | 47 | this.init = function( world) |
48 | { | ||
49 | this.setWorld( world ); | ||
50 | |||
58 | // set up the shader | 51 | // set up the shader |
59 | this._shader = new RDGE.jshader(); | 52 | this._shader = new RDGE.jshader(); |
60 | this._shader.def = plasmaShaderDef; | 53 | this._shader.def = plasmaShaderDef; |
@@ -62,23 +55,36 @@ var PlasmaMaterial = function PlasmaMaterial() { | |||
62 | 55 | ||
63 | // set the default value | 56 | // set the default value |
64 | this._time = 0; | 57 | this._time = 0; |
65 | this._shader['default'].u_time = this._time; | 58 | this._shader['default'].u_time.set( [this._time] ); |
66 | this.setProperty( "color", [this._time, 0, 0, 1] ); | ||
67 | 59 | ||
68 | // set up the material node | 60 | // set up the material node |
69 | this._materialNode = RDGE.createMaterialNode("plasmaMaterial"); | 61 | this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); |
70 | this._materialNode.setShader(this._shader); | 62 | this._materialNode.setShader(this._shader); |
71 | }; | 63 | }; |
72 | 64 | ||
73 | this.update = function( time ) { | 65 | this.update = function( time ) { |
74 | this._shader['default'].u_time = this._time; | 66 | this._shader['default'].u_time.set( [this._time] ); |
75 | var color = this.getProperty( "color" ); | ||
76 | color[0] = this._time; | ||
77 | this.setProperty( "color", color ); | ||
78 | //console.log( "update color to: " + color ); | ||
79 | this._time += this._dTime; | 67 | this._time += this._dTime; |
80 | } | 68 | }; |
69 | |||
70 | this.exportJSON = function() | ||
71 | { | ||
72 | var jObj = | ||
73 | { | ||
74 | 'material' : this.getShaderName(), | ||
75 | 'name' : this.getName(), | ||
76 | 'speed' : this._speed, | ||
77 | 'dTime' : this._dTime | ||
78 | }; | ||
79 | |||
80 | return jObj; | ||
81 | }; | ||
81 | 82 | ||
83 | this.importJSON = function( jObj ) | ||
84 | { | ||
85 | this._speed = jObj.speed; | ||
86 | this._dTime = jObj.dTime; | ||
87 | }; | ||
82 | }; | 88 | }; |
83 | 89 | ||
84 | /////////////////////////////////////////////////////////////////////////////////////// | 90 | /////////////////////////////////////////////////////////////////////////////////////// |
@@ -109,7 +115,6 @@ var plasmaShaderDef = | |||
109 | 'params' : | 115 | 'params' : |
110 | { | 116 | { |
111 | 'u_time' : { 'type' : 'float' }, | 117 | 'u_time' : { 'type' : 'float' }, |
112 | 'color' : { 'type' : 'vec4' } | ||
113 | }, | 118 | }, |
114 | 119 | ||
115 | // render states | 120 | // render states |