diff options
author | Jose Antonio Marquez | 2012-02-11 22:37:34 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-11 22:37:34 -0800 |
commit | 9f2356c48b831d32d7278648656fe44b98bc4a1f (patch) | |
tree | 58459a2e2e45ff2f4ffa9042740040ee17d91dfb /js/helper-classes/RDGE/Materials/TwistMaterial.js | |
parent | 5eb38b8bd779c7fb6e59b966135f8d306378f034 (diff) | |
parent | e142611e22718b1f1d1696902ad9161ec5f33f98 (diff) | |
download | ninja-9f2356c48b831d32d7278648656fe44b98bc4a1f.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into FileIO
Conflicts:
js/ninja.reel/ninja.html
Diffstat (limited to 'js/helper-classes/RDGE/Materials/TwistMaterial.js')
-rwxr-xr-x | js/helper-classes/RDGE/Materials/TwistMaterial.js | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/js/helper-classes/RDGE/Materials/TwistMaterial.js b/js/helper-classes/RDGE/Materials/TwistMaterial.js deleted file mode 100755 index b113965b..00000000 --- a/js/helper-classes/RDGE/Materials/TwistMaterial.js +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | /* <copyright> | ||
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/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | |||
9 | /////////////////////////////////////////////////////////////////////// | ||
10 | // Class GLMaterial | ||
11 | // RDGE representation of a material. | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | function TwistMaterial() | ||
14 | { | ||
15 | // initialize the inherited members | ||
16 | this.inheritedFrom = PulseMaterial; | ||
17 | this.inheritedFrom(); | ||
18 | |||
19 | /////////////////////////////////////////////////////////////////////// | ||
20 | // Instance variables | ||
21 | /////////////////////////////////////////////////////////////////////// | ||
22 | this._name = "TwistMaterial"; | ||
23 | this._shaderName = "twist"; | ||
24 | |||
25 | this._texMap = 'assets/images/rocky-normal.jpg'; | ||
26 | |||
27 | this._time = 0.0; | ||
28 | this._dTime = 0.01; | ||
29 | |||
30 | /////////////////////////////////////////////////////////////////////// | ||
31 | // Properties | ||
32 | /////////////////////////////////////////////////////////////////////// | ||
33 | // all defined in parent PulseMaterial.js | ||
34 | // load the local default value | ||
35 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | ||
36 | |||
37 | /////////////////////////////////////////////////////////////////////// | ||
38 | // Material Property Accessors | ||
39 | /////////////////////////////////////////////////////////////////////// | ||
40 | |||
41 | /////////////////////////////////////////////////////////////////////// | ||
42 | |||
43 | |||
44 | /////////////////////////////////////////////////////////////////////// | ||
45 | // Methods | ||
46 | /////////////////////////////////////////////////////////////////////// | ||
47 | // duplcate method requirde | ||
48 | this.dup = function( world ) | ||
49 | { | ||
50 | // allocate a new uber material | ||
51 | var newMat = new TwistMaterial(); | ||
52 | |||
53 | // copy over the current values; | ||
54 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
55 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
56 | var n = propNames.length; | ||
57 | for (var i=0; i<n; i++) | ||
58 | newMat.setProperty( propNames[i], propValues[i] ); | ||
59 | |||
60 | return newMat; | ||
61 | } | ||
62 | |||
63 | this.init = function( world ) | ||
64 | { | ||
65 | // save the world | ||
66 | if (world) this.setWorld( world ); | ||
67 | |||
68 | // set up the shader | ||
69 | this._shader = new jshader(); | ||
70 | this._shader.def = twistMaterialDef; | ||
71 | this._shader.init(); | ||
72 | |||
73 | // set up the material node | ||
74 | this._materialNode = createMaterialNode("twistMaterial"); | ||
75 | this._materialNode.setShader(this._shader); | ||
76 | |||
77 | this._time = 0; | ||
78 | if (this._shader && this._shader.default) | ||
79 | this._shader.default.u_time.set( [this._time] ); | ||
80 | |||
81 | // set the shader values in the shader | ||
82 | this.updateTexture(); | ||
83 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | ||
84 | this.update( 0 ); | ||
85 | } | ||
86 | |||
87 | this.update = function( time ) | ||
88 | { | ||
89 | var material = this._materialNode; | ||
90 | if (material) | ||
91 | { | ||
92 | var technique = material.shaderProgram.default; | ||
93 | var renderer = g_Engine.getContext().renderer; | ||
94 | if (renderer && technique) | ||
95 | { | ||
96 | if (this._shader && this._shader.default) | ||
97 | this._shader.default.u_time.set( [this._time] ); | ||
98 | this._time = time; | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /////////////////////////////////////////////////////////////////////////////////////// | ||
105 | // RDGE shader | ||
106 | |||
107 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | ||
108 | var twistMaterialDef = | ||
109 | {'shaders': | ||
110 | { | ||
111 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | ||
112 | 'defaultFShader':"assets/shaders/Twist.frag.glsl" | ||
113 | }, | ||
114 | 'techniques': | ||
115 | { | ||
116 | 'default': | ||
117 | [ | ||
118 | { | ||
119 | 'vshader' : 'defaultVShader', | ||
120 | 'fshader' : 'defaultFShader', | ||
121 | // attributes | ||
122 | 'attributes' : | ||
123 | { | ||
124 | 'vert' : { 'type' : 'vec3' }, | ||
125 | 'normal' : { 'type' : 'vec3' }, | ||
126 | 'texcoord' : { 'type' : 'vec2' } | ||
127 | }, | ||
128 | // parameters | ||
129 | 'params' : | ||
130 | { | ||
131 | 'u_tex0': { 'type' : 'tex2d' }, | ||
132 | 'u_time' : { 'type' : 'float' }, | ||
133 | 'u_resolution' : { 'type' : 'vec2' }, | ||
134 | }, | ||
135 | |||
136 | // render states | ||
137 | 'states' : | ||
138 | { | ||
139 | 'depthEnable' : true, | ||
140 | 'offset':[1.0, 0.1] | ||
141 | }, | ||
142 | }, | ||
143 | ] | ||
144 | } | ||
145 | }; | ||
146 | |||
147 | |||
148 | |||
149 | |||