aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/plasma-material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-20 11:17:47 -0700
committerValerio Virgillito2012-06-20 11:17:47 -0700
commit3f5aa43b5b545cd551c5585ef5f2d478c2d49cad (patch)
treefe5beec45a8d7f45a90659e95c4f13a679ae35d5 /js/lib/rdge/materials/plasma-material.js
parent5c4ff40d7950282a179dcfd49c5ea9234e0a8185 (diff)
parentfcb6309915161d16a74a4385b905742f35b7d62d (diff)
downloadninja-3f5aa43b5b545cd551c5585ef5f2d478c2d49cad.tar.gz
Merge branch 'refs/heads/master' into montage-v11-integration
Conflicts: js/io/system/ninjalibrary.json Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/plasma-material.js')
-rw-r--r--js/lib/rdge/materials/plasma-material.js61
1 files changed, 30 insertions, 31 deletions
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 02172a6b..10c29c99 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -10,39 +10,46 @@ var PlasmaMaterial = function PlasmaMaterial() {
10 /////////////////////////////////////////////////////////////////////// 10 ///////////////////////////////////////////////////////////////////////
11 // Instance variables 11 // Instance variables
12 /////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////
13 this._name = "PlasmaMaterial"; 13 this._name = "Plasma";
14 this._shaderName = "plasma"; 14 this._shaderName = "plasma";
15 15
16 this._time = 0.0; 16 this._time = 0.0;
17 this._dTime = 0.01; 17 this._dTime = 0.01;
18 this._speed = 1.0; 18 this._speed = 1.0;
19 19
20 this._wave = 0.0;
21 this._wave1 = 0.6;
22 this._wave2 = 0.8;
23
24 ///////////////////////////////////////////////////////////////////////
25 // Properties
26 ///////////////////////////////////////////////////////////////////////
27 this._propNames = ["u_wave", "u_wave1", "u_wave2", "u_speed"];
28 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"];
29 this._propTypes = ["float", "float", "float", "float"];
30
31 this._propValues = [];
32 this._propValues[ this._propNames[0] ] = this._wave;
33 this._propValues[ this._propNames[1] ] = this._wave1;
34 this._propValues[ this._propNames[2] ] = this._wave2;
35 this._propValues[ this._propNames[3] ] = this._speed;
36
20 37
21 /////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////
22 // Property Accessors 39 // Property Accessors
23 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
24 this.getShaderName = function() { return this._shaderName; }; 41 this.getShaderName = function() { return this._shaderName; };
25
26 this.isAnimated = function() { return true; }; 42 this.isAnimated = function() { return true; };
43 this.getShaderDef = function() { return plasmaShaderDef; };
27 44
28 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
29 // Material Property Accessors 46 // Material Property Accessors
30 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
31 48
32 this.setProperty = function( prop, value )
33 {
34 // plasma has no properties
35 };
36
37 ///////////////////////////////////////////////////////////////////////
38
39 /////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////
40 // Methods 50 // Methods
41 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
42 // duplcate method requirde 52 // duplcate method requirde
43 this.dup = function() {
44 return new PlasmaMaterial();
45 };
46 53
47 this.init = function( world) 54 this.init = function( world)
48 { 55 {
@@ -60,31 +67,19 @@ var PlasmaMaterial = function PlasmaMaterial() {
60 // set up the material node 67 // set up the material node
61 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); 68 this._materialNode = RDGE.createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID());
62 this._materialNode.setShader(this._shader); 69 this._materialNode.setShader(this._shader);
70
71 this._time = 0;
72 if (this._shader && this._shader['default']) {
73 this._shader['default'].u_time.set( [this._time] );
74 }
75
76 this.setShaderValues();
63 }; 77 };
64 78
65 this.update = function( time ) { 79 this.update = function( time ) {
66 this._shader['default'].u_time.set( [this._time] ); 80 this._shader['default'].u_time.set( [this._time] );
67 this._time += this._dTime; 81 this._time += this._dTime;
68 }; 82 };
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 };
82
83 this.importJSON = function( jObj )
84 {
85 this._speed = jObj.speed;
86 this._dTime = jObj.dTime;
87 };
88}; 83};
89 84
90/////////////////////////////////////////////////////////////////////////////////////// 85///////////////////////////////////////////////////////////////////////////////////////
@@ -115,6 +110,10 @@ var plasmaShaderDef =
115 'params' : 110 'params' :
116 { 111 {
117 'u_time' : { 'type' : 'float' }, 112 'u_time' : { 'type' : 'float' },
113 'u_speed': { 'type' : 'float' },
114 'u_wave' : { 'type' : 'float' },
115 'u_wave1': { 'type' : 'float' },
116 'u_wave2': { 'type' : 'float' }
118 }, 117 },
119 118
120 // render states 119 // render states