aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/TwistMaterial.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-13 11:59:19 -0800
committerArmen Kesablyan2012-02-13 11:59:19 -0800
commit90d0c8c0e98d062c628c061fe5765ce991fda409 (patch)
tree9780e9dcf475bf319f3cacc1a1ad52fcf9f133af /js/helper-classes/RDGE/Materials/TwistMaterial.js
parent8110e01dc5093ac6baf621103dcaa5f769e5be92 (diff)
parente142611e22718b1f1d1696902ad9161ec5f33f98 (diff)
downloadninja-90d0c8c0e98d062c628c061fe5765ce991fda409.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts: css/ninja.css js/stage/stage.reel/stage.html js/tools/TextTool.js node_modules/labs/rich-text-editor.reel/rich-text-editor.css node_modules/labs/rich-text-editor.reel/rich-text-editor.html node_modules/labs/rich-text-editor.reel/rich-text-editor.js node_modules/labs/rich-text-editor.reel/rich-text-resizer.js node_modules/labs/rich-text-editor.reel/rich-text-sanitizer.js Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/Materials/TwistMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/TwistMaterial.js146
1 files changed, 0 insertions, 146 deletions
diff --git a/js/helper-classes/RDGE/Materials/TwistMaterial.js b/js/helper-classes/RDGE/Materials/TwistMaterial.js
deleted file mode 100644
index c3094621..00000000
--- a/js/helper-classes/RDGE/Materials/TwistMaterial.js
+++ /dev/null
@@ -1,146 +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///////////////////////////////////////////////////////////////////////
13function 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 // set up the shader
66 this._shader = new jshader();
67 this._shader.def = twistMaterialDef;
68 this._shader.init();
69
70 // set up the material node
71 this._materialNode = createMaterialNode("twistMaterial");
72 this._materialNode.setShader(this._shader);
73
74 this._time = 0;
75 if (this._shader && this._shader.default)
76 this._shader.default.u_time.set( [this._time] );
77
78 // set the shader values in the shader
79 this.updateTexture();
80 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
81 this.update( 0 );
82 }
83
84 this.update = function( time )
85 {
86 var material = this._materialNode;
87 if (material)
88 {
89 var technique = material.shaderProgram.default;
90 var renderer = g_Engine.getContext().renderer;
91 if (renderer && technique)
92 {
93 if (this._shader && this._shader.default)
94 this._shader.default.u_time.set( [this._time] );
95 this._time = time;
96 }
97 }
98 }
99}
100
101///////////////////////////////////////////////////////////////////////////////////////
102// RDGE shader
103
104// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
105var twistMaterialDef =
106{'shaders':
107 {
108 'defaultVShader':"assets/shaders/Basic.vert.glsl",
109 'defaultFShader':"assets/shaders/Twist.frag.glsl"
110 },
111 'techniques':
112 {
113 'default':
114 [
115 {
116 'vshader' : 'defaultVShader',
117 'fshader' : 'defaultFShader',
118 // attributes
119 'attributes' :
120 {
121 'vert' : { 'type' : 'vec3' },
122 'normal' : { 'type' : 'vec3' },
123 'texcoord' : { 'type' : 'vec2' }
124 },
125 // parameters
126 'params' :
127 {
128 'u_tex0': { 'type' : 'tex2d' },
129 'u_time' : { 'type' : 'float' },
130 'u_resolution' : { 'type' : 'vec2' },
131 },
132
133 // render states
134 'states' :
135 {
136 'depthEnable' : true,
137 'offset':[1.0, 0.1]
138 },
139 },
140 ]
141 }
142};
143
144
145
146