aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/FlatMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials/FlatMaterial.js')
-rwxr-xr-xjs/helper-classes/RDGE/Materials/FlatMaterial.js161
1 files changed, 0 insertions, 161 deletions
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js
deleted file mode 100755
index 570e7f9e..00000000
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ /dev/null
@@ -1,161 +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()
44 {
45 // set up the shader
46 this._shader = new jshader();
47 this._shader.def = flatShaderDef;
48 this._shader.init();
49
50 // set the defaults
51 this._shader.colorMe.color.set( this.getColor() );
52
53 // set up the material node
54 this._materialNode = createMaterialNode("flatMaterial");
55 this._materialNode.setShader(this._shader);
56 };
57
58
59 ///////////////////////////////////////////////////////////////////////
60 // Material Property Accessors
61 ///////////////////////////////////////////////////////////////////////
62 this._propNames = ["color"];
63 this._propLabels = ["Color"];
64 this._propTypes = ["color"];
65 this._propValues = [];
66
67 this._propValues[ this._propNames[0] ] = this._color;
68
69 this.setProperty = function( prop, value )
70 {
71 // make sure we have legitimate input
72 if (this.validateProperty( prop, value ))
73 {
74 this._propValues[prop] = value;
75 if (this._shader && this._shader.colorMe)
76 this._shader.colorMe[prop].set(value);
77 }
78 };
79 ///////////////////////////////////////////////////////////////////////
80
81 this.export = function()
82 {
83 // this function should be overridden by subclasses
84 var exportStr = "material: " + this.getShaderName() + "\n";
85 exportStr += "name: " + this.getName() + "\n";
86
87 if (this._shader)
88 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
89 else
90 exportStr += "color: " + this.getColor() + "\n";
91 exportStr += "endMaterial\n";
92
93 return exportStr;
94 };
95
96 this.import = function( importStr )
97 {
98 var pu = new ParseUtils( importStr );
99 var material = pu.nextValue( "material: " );
100 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
101 this.setName( pu.nextValue( "name: ") );
102
103 var rtnStr;
104 try
105 {
106 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
107
108 this.setProperty( "color", color);
109
110 var endKey = "endMaterial\n";
111 var index = importStr.indexOf( endKey );
112 index += endKey.length;
113 rtnStr = importStr.substr( index );
114 }
115 catch (e)
116 {
117 throw new Error( "could not import material: " + importStr );
118 }
119
120 return rtnStr;
121 };
122
123 this.update = function( time )
124 {
125 };
126
127}
128
129///////////////////////////////////////////////////////////////////////////////////////
130// RDGE shader
131
132// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
133flatShaderDef =
134{
135 'shaders': { // shader files
136 'defaultVShader':"assets/shaders/Basic.vert.glsl",
137 'defaultFShader':"assets/shaders/Basic.frag.glsl"
138 },
139 'techniques': { // rendering control
140 'colorMe':[ // simple color pass
141 {
142 'vshader' : 'defaultVShader',
143 'fshader' : 'defaultFShader',
144
145 // attributes
146 'attributes' :
147 {
148 'vert' : { 'type' : 'vec3' },
149 'normal' : { 'type' : 'vec3' },
150 'texcoord' : { 'type' : 'vec2' }
151 },
152 // attributes
153 'params' :
154 {
155 'color' : { 'type' : 'vec4' }
156 }
157 }
158 ]
159 }
160};
161