diff options
author | Ananya Sen | 2012-04-17 18:11:55 -0700 |
---|---|---|
committer | Ananya Sen | 2012-04-17 18:11:55 -0700 |
commit | 35abad196cc9feb76ef50c1b63032a38233a6d51 (patch) | |
tree | 914689c66d4ab6c6e088b571eade0a0e35082916 /js/lib/rdge/materials/z-invert-material.js | |
parent | 1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff) | |
parent | 616a8532099fec2a15855eac97cd85cb60c4451c (diff) | |
download | ninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/lib/rdge/materials/z-invert-material.js')
-rw-r--r-- | js/lib/rdge/materials/z-invert-material.js | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js index a0d20de5..fc7632eb 100644 --- a/js/lib/rdge/materials/z-invert-material.js +++ b/js/lib/rdge/materials/z-invert-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; |
@@ -11,102 +11,102 @@ var ZInvertMaterial = function ZInvertMaterial() { | |||
11 | /////////////////////////////////////////////////////////////////////// | 11 | /////////////////////////////////////////////////////////////////////// |
12 | // Instance variables | 12 | // Instance variables |
13 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
14 | this._name = "ZInvertMaterial"; | 14 | this._name = "ZInvertMaterial"; |
15 | this._shaderName = "zinvert"; | 15 | this._shaderName = "zinvert"; |
16 | 16 | ||
17 | this._texMap = 'assets/images/rocky-normal.jpg'; | 17 | this._texMap = 'assets/images/rocky-normal.jpg'; |
18 | 18 | ||
19 | this._time = 0.0; | 19 | this._time = 0.0; |
20 | this._dTime = 0.01; | 20 | this._dTime = 0.01; |
21 | 21 | ||
22 | /////////////////////////////////////////////////////////////////////// | 22 | /////////////////////////////////////////////////////////////////////// |
23 | // Properties | 23 | // Properties |
24 | /////////////////////////////////////////////////////////////////////// | 24 | /////////////////////////////////////////////////////////////////////// |
25 | // all defined in parent PulseMaterial.js | 25 | // all defined in parent PulseMaterial.js |
26 | // load the local default value | 26 | // load the local default value |
27 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 27 | this._propValues[this._propNames[0]] = this._texMap.slice(0); |
28 | 28 | ||
29 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
30 | // Methods | 30 | // Methods |
31 | /////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////// |
32 | // duplcate method requirde | 32 | // duplicate method required |
33 | this.dup = function( world ) { | 33 | this.dup = function (world) { |
34 | // allocate a new uber material | 34 | // allocate a new uber material |
35 | var newMat = new ZInvertMaterial(); | 35 | var newMat = new ZInvertMaterial(); |
36 | 36 | ||
37 | // copy over the current values; | 37 | // copy over the current values; |
38 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | 38 | var propNames = [], propValues = [], propTypes = [], propLabels = []; |
39 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | 39 | this.getAllProperties(propNames, propValues, propTypes, propLabels); |
40 | var n = propNames.length; | 40 | var n = propNames.length; |
41 | for (var i=0; i<n; i++) { | 41 | for (var i = 0; i < n; i++) { |
42 | newMat.setProperty( propNames[i], propValues[i] ); | 42 | newMat.setProperty(propNames[i], propValues[i]); |
43 | } | 43 | } |
44 | 44 | ||
45 | return newMat; | 45 | return newMat; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | this.init = function( world ) { | 48 | this.init = function (world) { |
49 | // save the world | 49 | // save the world |
50 | if (world) this.setWorld( world ); | 50 | if (world) this.setWorld(world); |
51 | 51 | ||
52 | // set up the shader | 52 | // set up the shader |
53 | this._shader = new jshader(); | 53 | this._shader = new RDGE.jshader(); |
54 | this._shader.def = zInvertMaterialDef; | 54 | this._shader.def = zInvertMaterialDef; |
55 | this._shader.init(); | 55 | this._shader.init(); |
56 | 56 | ||
57 | // set up the material node | 57 | // set up the material node |
58 | this._materialNode = createMaterialNode("zInvertMaterial" + "_" + world.generateUniqueNodeID()); | 58 | this._materialNode = RDGE.createMaterialNode("zInvertMaterial" + "_" + world.generateUniqueNodeID()); |
59 | this._materialNode.setShader(this._shader); | 59 | this._materialNode.setShader(this._shader); |
60 | 60 | ||
61 | this._time = 0; | 61 | this._time = 0; |
62 | if (this._shader && this._shader['default']) { | 62 | if (this._shader && this._shader['default']) { |
63 | this._shader['default'].u_time.set( [this._time] ); | 63 | this._shader['default'].u_time.set([this._time]); |
64 | } | 64 | } |
65 | 65 | ||
66 | // set the shader values in the shader | 66 | // set the shader values in the shader |
67 | this.updateTexture(); | 67 | this.updateTexture(); |
68 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 68 | this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); |
69 | this.update( 0 ); | 69 | this.update(0); |
70 | } | 70 | }; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /////////////////////////////////////////////////////////////////////////////////////// | 73 | /////////////////////////////////////////////////////////////////////////////////////// |
74 | // RDGE shader | 74 | // RDGE shader |
75 | 75 | ||
76 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 76 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
77 | var zInvertMaterialDef = | 77 | var zInvertMaterialDef = |
78 | {'shaders': | 78 | { 'shaders': |
79 | { | 79 | { |
80 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 80 | 'defaultVShader': "assets/shaders/Basic.vert.glsl", |
81 | 'defaultFShader':"assets/shaders/ZInvert.frag.glsl" | 81 | 'defaultFShader': "assets/shaders/ZInvert.frag.glsl" |
82 | }, | 82 | }, |
83 | 'techniques': | 83 | 'techniques': |
84 | { | 84 | { |
85 | 'default': | 85 | 'default': |
86 | [ | 86 | [ |
87 | { | 87 | { |
88 | 'vshader' : 'defaultVShader', | 88 | 'vshader': 'defaultVShader', |
89 | 'fshader' : 'defaultFShader', | 89 | 'fshader': 'defaultFShader', |
90 | // attributes | 90 | // attributes |
91 | 'attributes' : | 91 | 'attributes': |
92 | { | 92 | { |
93 | 'vert' : { 'type' : 'vec3' }, | 93 | 'vert': { 'type': 'vec3' }, |
94 | 'normal' : { 'type' : 'vec3' }, | 94 | 'normal': { 'type': 'vec3' }, |
95 | 'texcoord' : { 'type' : 'vec2' } | 95 | 'texcoord': { 'type': 'vec2' } |
96 | }, | 96 | }, |
97 | // parameters | 97 | // parameters |
98 | 'params' : | 98 | 'params': |
99 | { | 99 | { |
100 | 'u_tex0': { 'type' : 'tex2d' }, | 100 | 'u_tex0': { 'type': 'tex2d' }, |
101 | 'u_time' : { 'type' : 'float' }, | 101 | 'u_time': { 'type': 'float' }, |
102 | 'u_resolution' : { 'type' : 'vec2' } | 102 | 'u_resolution': { 'type': 'vec2' } |
103 | }, | 103 | }, |
104 | 104 | ||
105 | // render states | 105 | // render states |
106 | 'states' : | 106 | 'states': |
107 | { | 107 | { |
108 | 'depthEnable' : true, | 108 | 'depthEnable': true, |
109 | 'offset':[1.0, 0.1] | 109 | 'offset': [1.0, 0.1] |
110 | } | 110 | } |
111 | } | 111 | } |
112 | ] | 112 | ] |