aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/fly-material.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 11:52:06 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch)
tree8f0f55557bd0c47a84e49c1977c950645d284607 /js/lib/rdge/materials/fly-material.js
parentaedd14b18695d031f695d27dfbd94df5614495bb (diff)
downloadninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz
Expand tabs
Diffstat (limited to 'js/lib/rdge/materials/fly-material.js')
-rw-r--r--js/lib/rdge/materials/fly-material.js136
1 files changed, 68 insertions, 68 deletions
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index b4bf0972..d53532d9 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -35,13 +35,13 @@ var FlyMaterial = function FlyMaterial() {
35 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
36 // Instance variables 36 // Instance variables
37 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
38 this._name = "Fly"; 38 this._name = "Fly";
39 this._shaderName = "fly"; 39 this._shaderName = "fly";
40 40
41 this._defaultTexMap = 'assets/images/rocky-normal.jpg'; 41 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
42 42
43 this._time = 0.0; 43 this._time = 0.0;
44 this._dTime = 0.01; 44 this._dTime = 0.01;
45 45
46 // array textures indexed by shader uniform name 46 // array textures indexed by shader uniform name
47 this._glTextures = []; 47 this._glTextures = [];
@@ -49,50 +49,50 @@ var FlyMaterial = function FlyMaterial() {
49 /////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////
50 // Properties 50 // Properties
51 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
52 // all defined in parent PulseMaterial.js 52 // all defined in parent PulseMaterial.js
53 // load the local default value 53 // load the local default value
54 var u_tex0_index = 0, u_speed_index = 1; 54 var u_tex0_index = 0, u_speed_index = 1;
55 this._propNames = ["u_tex0", "u_speed" ]; 55 this._propNames = ["u_tex0", "u_speed" ];
56 this._propLabels = ["Texture map", "Speed" ]; 56 this._propLabels = ["Texture map", "Speed" ];
57 this._propTypes = ["file", "float" ]; 57 this._propTypes = ["file", "float" ];
58 this._propValues = []; 58 this._propValues = [];
59 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); 59 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
60 this._propValues[this._propNames[u_speed_index]] = 1.0; 60 this._propValues[this._propNames[u_speed_index]] = 1.0;
61 61
62 /////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////
63 // Material Property Accessors 63 // Material Property Accessors
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 this.isAnimated = function() { return true; }; 65 this.isAnimated = function() { return true; };
66 this.getShaderDef = function() { return flyMaterialDef; }; 66 this.getShaderDef = function() { return flyMaterialDef; };
67 67
68 /////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////
69 // Methods 69 // Methods
70 /////////////////////////////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////
71 // duplcate method requirde 71 // duplcate method requirde
72 72
73 this.init = function( world ) { 73 this.init = function( world ) {
74 // save the world 74 // save the world
75 if (world) this.setWorld( world ); 75 if (world) this.setWorld( world );
76 76
77 // set up the shader 77 // set up the shader
78 this._shader = new RDGE.jshader(); 78 this._shader = new RDGE.jshader();
79 this._shader.def = flyMaterialDef; 79 this._shader.def = flyMaterialDef;
80 this._shader.init(); 80 this._shader.init();
81 81
82 // set up the material node 82 // set up the material node
83 this._materialNode = RDGE.createMaterialNode("flyMaterial" + "_" + world.generateUniqueNodeID()); 83 this._materialNode = RDGE.createMaterialNode("flyMaterial" + "_" + world.generateUniqueNodeID());
84 this._materialNode.setShader(this._shader); 84 this._materialNode.setShader(this._shader);
85 85
86 this._time = 0; 86 this._time = 0;
87 if (this._shader && this._shader['default']) { 87 if (this._shader && this._shader['default']) {
88 this._shader['default'].u_time.set( [this._time] ); 88 this._shader['default'].u_time.set( [this._time] );
89 } 89 }
90 90
91 // set the shader values in the shader 91 // set the shader values in the shader
92 this.setShaderValues(); 92 this.setShaderValues();
93 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 93 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
94 this.update( 0 ); 94 this.update( 0 );
95 }; 95 };
96}; 96};
97 97
98/////////////////////////////////////////////////////////////////////////////////////// 98///////////////////////////////////////////////////////////////////////////////////////
@@ -102,42 +102,42 @@ var FlyMaterial = function FlyMaterial() {
102var flyMaterialDef = 102var flyMaterialDef =
103{ 103{
104 'shaders': 104 'shaders':
105 { 105 {
106 'defaultVShader':"assets/shaders/Basic.vert.glsl", 106 'defaultVShader':"assets/shaders/Basic.vert.glsl",
107 'defaultFShader':"assets/shaders/Fly.frag.glsl" 107 'defaultFShader':"assets/shaders/Fly.frag.glsl"
108 }, 108 },
109 'techniques': 109 'techniques':
110 { 110 {
111 'default': 111 'default':
112 [ 112 [
113 { 113 {
114 'vshader' : 'defaultVShader', 114 'vshader' : 'defaultVShader',
115 'fshader' : 'defaultFShader', 115 'fshader' : 'defaultFShader',
116 // attributes 116 // attributes
117 'attributes' : 117 'attributes' :
118 { 118 {
119 'vert' : { 'type' : 'vec3' }, 119 'vert' : { 'type' : 'vec3' },
120 'normal' : { 'type' : 'vec3' }, 120 'normal' : { 'type' : 'vec3' },
121 'texcoord' : { 'type' : 'vec2' } 121 'texcoord' : { 'type' : 'vec2' }
122 }, 122 },
123 // parameters 123 // parameters
124 'params' : 124 'params' :
125 { 125 {
126 'u_tex0': { 'type' : 'tex2d' }, 126 'u_tex0': { 'type' : 'tex2d' },
127 'u_time' : { 'type' : 'float' }, 127 'u_time' : { 'type' : 'float' },
128 'u_speed' : { 'type' : 'float' }, 128 'u_speed' : { 'type' : 'float' },
129 'u_resolution' : { 'type' : 'vec2' }, 129 'u_resolution' : { 'type' : 'vec2' },
130 }, 130 },
131 131
132 // render states 132 // render states
133 'states' : 133 'states' :
134 { 134 {
135 'depthEnable' : true, 135 'depthEnable' : true,
136 'offset':[1.0, 0.1] 136 'offset':[1.0, 0.1]
137 } 137 }
138 } 138 }
139 ] 139 ]
140 } 140 }
141}; 141};
142 142
143FlyMaterial.prototype = new PulseMaterial(); 143FlyMaterial.prototype = new PulseMaterial();