aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/backup-delete/Materials/FlatMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/backup-delete/Materials/FlatMaterial.js')
-rwxr-xr-xjs/helper-classes/backup-delete/Materials/FlatMaterial.js165
1 files changed, 0 insertions, 165 deletions
diff --git a/js/helper-classes/backup-delete/Materials/FlatMaterial.js b/js/helper-classes/backup-delete/Materials/FlatMaterial.js
deleted file mode 100755
index eb8970b8..00000000
--- a/js/helper-classes/backup-delete/Materials/FlatMaterial.js
+++ /dev/null
@@ -1,165 +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// Class GLMaterial
10// RDGE representation of a material.
11///////////////////////////////////////////////////////////////////////
12function FlatMaterial()
13{
14 // initialize the inherited members
15 this.inheritedFrom = GLMaterial;
16 this.inheritedFrom();
17
18 ///////////////////////////////////////////////////////////////////////
19 // Instance variables
20 ///////////////////////////////////////////////////////////////////////
21 this._name = "FlatMaterial";
22 this._shaderName = "flat";
23
24 this._color = [1,0,0,1];
25
26 ///////////////////////////////////////////////////////////////////////
27 // Property Accessors
28 ///////////////////////////////////////////////////////////////////////
29 this.getColor = function() { return this._color; };
30 this.getShaderName = function() { return this._shaderName; };
31
32 this.isAnimated = function() { return false; };
33 this.hasVertexDeformation = function() { return true; };
34 this._hasVertexDeformation = true;
35 this._vertexDeformationTolerance = 0.2;
36
37 //////////////////////////////////s/////////////////////////////////////
38 // Methods
39 ///////////////////////////////////////////////////////////////////////
40 // duplcate method requirde
41 this.dup = function() { return new FlatMaterial(); } ;
42
43 this.init = function( world )
44 {
45 // save the world
46 if (world)
47 {
48 this.setWorld( world );
49
50 // set up the shader
51 this._shader = new jshader();
52 this._shader.def = flatShaderDef;
53 this._shader.init();
54
55 // set the defaults
56 this._shader.colorMe.color.set( this.getColor() );
57
58 // set up the material node
59 this._materialNode = createMaterialNode("flatMaterial_" + world.generateUniqueNodeID() );
60 this._materialNode.setShader(this._shader);
61 }
62 else
63 throw new Error( "GLWorld not supplied to material initialization" );
64 };
65
66
67 ///////////////////////////////////////////////////////////////////////
68 // Material Property Accessors
69 ///////////////////////////////////////////////////////////////////////
70 this._propNames = ["color"];
71 this._propLabels = ["Color"];
72 this._propTypes = ["color"];
73 this._propValues = [];
74
75 this._propValues[ this._propNames[0] ] = this._color;
76
77 this.setProperty = function( prop, value )
78 {
79 // make sure we have legitimate input
80 if (this.validateProperty( prop, value ))
81 {
82 this._propValues[prop] = value;
83 if (this._shader && this._shader.colorMe)
84 this._shader.colorMe[prop].set(value);
85 }
86 };
87 ///////////////////////////////////////////////////////////////////////
88
89 this.export = function()
90 {
91 // this function should be overridden by subclasses
92 var exportStr = "material: " + this.getShaderName() + "\n";
93 exportStr += "name: " + this.getName() + "\n";
94 exportStr += "color: " + String(this._propValues["color"]) + "\n";
95 exportStr += "endMaterial\n";
96
97 return exportStr;
98 };
99
100 this.import = function( importStr )
101 {
102 var pu = new ParseUtils( importStr );
103 var material = pu.nextValue( "material: " );
104 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
105 this.setName( pu.nextValue( "name: ") );
106
107 var rtnStr;
108 try
109 {
110 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
111
112 this.setProperty( "color", color);
113
114 var endKey = "endMaterial\n";
115 var index = importStr.indexOf( endKey );
116 index += endKey.length;
117 rtnStr = importStr.substr( index );
118 }
119 catch (e)
120 {
121 throw new Error( "could not import material: " + importStr );
122 }
123
124 return rtnStr;
125 };
126
127 this.update = function( time )
128 {
129 };
130
131}
132
133///////////////////////////////////////////////////////////////////////////////////////
134// RDGE shader
135
136// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
137flatShaderDef =
138{
139 'shaders': { // shader files
140 'defaultVShader':"assets/shaders/Basic.vert.glsl",
141 'defaultFShader':"assets/shaders/Basic.frag.glsl"
142 },
143 'techniques': { // rendering control
144 'colorMe':[ // simple color pass
145 {
146 'vshader' : 'defaultVShader',
147 'fshader' : 'defaultFShader',
148
149 // attributes
150 'attributes' :
151 {
152 'vert' : { 'type' : 'vec3' },
153 'normal' : { 'type' : 'vec3' },
154 'texcoord' : { 'type' : 'vec2' }
155 },
156 // attributes
157 'params' :
158 {
159 'color' : { 'type' : 'vec4' }
160 }
161 }
162 ]
163 }
164};
165