diff options
Diffstat (limited to 'js/lib/rdge/materials/relief-tunnel-material.js')
-rw-r--r-- | js/lib/rdge/materials/relief-tunnel-material.js | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 24fc885f..cb433562 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js | |||
@@ -1,8 +1,8 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 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/> | 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. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | 7 | ||
8 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | 8 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; |
@@ -13,104 +13,104 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() | |||
13 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
14 | // Instance variables | 14 | // Instance variables |
15 | /////////////////////////////////////////////////////////////////////// | 15 | /////////////////////////////////////////////////////////////////////// |
16 | this._name = "ReliefTunnelMaterial"; | 16 | this._name = "ReliefTunnelMaterial"; |
17 | this._shaderName = "reliefTunnel"; | 17 | this._shaderName = "reliefTunnel"; |
18 | 18 | ||
19 | this._texMap = 'assets/images/rocky-normal.jpg'; | 19 | this._texMap = 'assets/images/rocky-normal.jpg'; |
20 | 20 | ||
21 | this._time = 0.0; | 21 | this._time = 0.0; |
22 | this._dTime = 0.01; | 22 | this._dTime = 0.01; |
23 | 23 | ||
24 | /////////////////////////////////////////////////////////////////////// | 24 | /////////////////////////////////////////////////////////////////////// |
25 | // Properties | 25 | // Properties |
26 | /////////////////////////////////////////////////////////////////////// | 26 | /////////////////////////////////////////////////////////////////////// |
27 | // all defined in parent PulseMaterial.js | 27 | // all defined in parent PulseMaterial.js |
28 | // load the local default value | 28 | // load the local default value |
29 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 29 | this._propValues[this._propNames[0]] = this._texMap.slice(0); |
30 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
31 | // Methods | 31 | // Methods |
32 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
33 | // duplcate method requirde | 33 | // duplcate method requirde |
34 | this.dup = function( world ) { | 34 | this.dup = function (world) { |
35 | // allocate a new uber material | 35 | // allocate a new uber material |
36 | var newMat = new ReliefTunnelMaterial(); | 36 | var newMat = new ReliefTunnelMaterial(); |
37 | 37 | ||
38 | // copy over the current values; | 38 | // copy over the current values; |
39 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | 39 | var propNames = [], propValues = [], propTypes = [], propLabels = []; |
40 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | 40 | this.getAllProperties(propNames, propValues, propTypes, propLabels); |
41 | var n = propNames.length; | 41 | var n = propNames.length; |
42 | for (var i=0; i<n; i++) { | 42 | for (var i = 0; i < n; i++) { |
43 | newMat.setProperty( propNames[i], propValues[i] ); | 43 | newMat.setProperty(propNames[i], propValues[i]); |
44 | } | 44 | } |
45 | 45 | ||
46 | return newMat; | 46 | return newMat; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | this.init = function( world ) { | 49 | this.init = function (world) { |
50 | // save the world | 50 | // save the world |
51 | if (world) this.setWorld( world ); | 51 | if (world) this.setWorld(world); |
52 | 52 | ||
53 | // set up the shader | 53 | // set up the shader |
54 | this._shader = new jshader(); | 54 | this._shader = new RDGE.jshader(); |
55 | this._shader.def = reliefTunnelMaterialDef; | 55 | this._shader.def = reliefTunnelMaterialDef; |
56 | this._shader.init(); | 56 | this._shader.init(); |
57 | 57 | ||
58 | // set up the material node | 58 | // set up the material node |
59 | this._materialNode = createMaterialNode("reliefTunnelMaterial" + "_" + world.generateUniqueNodeID()); | 59 | this._materialNode = RDGE.createMaterialNode("reliefTunnelMaterial" + "_" + world.generateUniqueNodeID()); |
60 | this._materialNode.setShader(this._shader); | 60 | this._materialNode.setShader(this._shader); |
61 | 61 | ||
62 | this._time = 0; | 62 | this._time = 0; |
63 | if (this._shader && this._shader['default']) { | 63 | if (this._shader && this._shader['default']) { |
64 | this._shader['default'].u_time.set( [this._time] ); | 64 | this._shader['default'].u_time.set([this._time]); |
65 | } | 65 | } |
66 | 66 | ||
67 | var texMapName = this._propValues[this._propNames[0]]; | 67 | var texMapName = this._propValues[this._propNames[0]]; |
68 | this._glTex = new Texture( world, texMapName ); | 68 | this._glTex = new Texture( world, texMapName ); |
69 | 69 | ||
70 | // set the shader values in the shader | 70 | // set the shader values in the shader |
71 | this.updateTexture(); | 71 | this.updateTexture(); |
72 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 72 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
73 | this.update( 0 ); | 73 | this.update(0); |
74 | } | 74 | }; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | /////////////////////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////////////////////// |
78 | // RDGE shader | 78 | // RDGE shader |
79 | 79 | ||
80 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 80 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
81 | var reliefTunnelMaterialDef = | 81 | var reliefTunnelMaterialDef = |
82 | {'shaders': | 82 | { 'shaders': |
83 | { | 83 | { |
84 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 84 | 'defaultVShader': "assets/shaders/Basic.vert.glsl", |
85 | 'defaultFShader':"assets/shaders/ReliefTunnel.frag.glsl" | 85 | 'defaultFShader': "assets/shaders/ReliefTunnel.frag.glsl" |
86 | }, | 86 | }, |
87 | 'techniques': | 87 | 'techniques': |
88 | { | 88 | { |
89 | 'default': | 89 | 'default': |
90 | [ | 90 | [ |
91 | { | 91 | { |
92 | 'vshader' : 'defaultVShader', | 92 | 'vshader': 'defaultVShader', |
93 | 'fshader' : 'defaultFShader', | 93 | 'fshader': 'defaultFShader', |
94 | // attributes | 94 | // attributes |
95 | 'attributes' : | 95 | 'attributes': |
96 | { | 96 | { |
97 | 'vert' : { 'type' : 'vec3' }, | 97 | 'vert': { 'type': 'vec3' }, |
98 | 'normal' : { 'type' : 'vec3' }, | 98 | 'normal': { 'type': 'vec3' }, |
99 | 'texcoord' : { 'type' : 'vec2' } | 99 | 'texcoord': { 'type': 'vec2' } |
100 | }, | 100 | }, |
101 | // parameters | 101 | // parameters |
102 | 'params' : | 102 | 'params': |
103 | { | 103 | { |
104 | 'u_tex0': { 'type' : 'tex2d' }, | 104 | 'u_tex0': { 'type': 'tex2d' }, |
105 | 'u_time' : { 'type' : 'float' }, | 105 | 'u_time': { 'type': 'float' }, |
106 | 'u_resolution' : { 'type' : 'vec2' } | 106 | 'u_resolution': { 'type': 'vec2' } |
107 | }, | 107 | }, |
108 | 108 | ||
109 | // render states | 109 | // render states |
110 | 'states' : | 110 | 'states': |
111 | { | 111 | { |
112 | 'depthEnable' : true, | 112 | 'depthEnable': true, |
113 | 'offset':[1.0, 0.1] | 113 | 'offset': [1.0, 0.1] |
114 | } | 114 | } |
115 | } | 115 | } |
116 | ] | 116 | ] |