aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:35:44 -0700
committerValerio Virgillito2012-07-09 14:35:44 -0700
commit84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch)
tree3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/lib/rdge/materials/material.js
parentc0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff)
parent40c6eb2c06b34f65a74d59ef9687251952858bab (diff)
downloadninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts: js/components/gradientpicker.reel/gradientpicker.js js/components/tools-properties/text-properties.reel/text-properties.js js/document/views/base.js js/document/views/design.js js/helper-classes/3D/StageLine.js js/helper-classes/3D/draw-utils.js js/lib/drawing/world.js js/lib/geom/circle.js js/lib/geom/line.js js/lib/geom/rectangle.js js/lib/geom/shape-primitive.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/flag-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/water-material.js js/panels/Materials/materials-library-panel.reel/materials-library-panel.html js/panels/Materials/materials-library-panel.reel/materials-library-panel.js js/panels/Materials/materials-popup.reel/materials-popup.html js/panels/Materials/materials-popup.reel/materials-popup.js js/tools/LineTool.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/material.js')
-rwxr-xr-xjs/lib/rdge/materials/material.js534
1 files changed, 267 insertions, 267 deletions
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js
index a7183187..6cfc4eb4 100755
--- a/js/lib/rdge/materials/material.js
+++ b/js/lib/rdge/materials/material.js
@@ -39,156 +39,156 @@ var Material = function GLMaterial( world ) {
39 /////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////
40 // Instance variables 40 // Instance variables
41 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
42 this._name = "GLMaterial"; 42 this._name = "GLMaterial";
43 this._shaderName = "undefined"; 43 this._shaderName = "undefined";
44 44
45 this._time = 0.0; 45 this._time = 0.0;
46 this._dTime = 0.01; 46 this._dTime = 0.01;
47 47
48 // keep a reference to the owning GLWorld 48 // keep a reference to the owning GLWorld
49 this._world = null; 49 this._world = null;
50 if(world) { 50 if(world) {
51 this._world = world; 51 this._world = world;
52 } 52 }
53 53
54 this._glTextures = []; // indexed by uniform name 54 this._glTextures = []; // indexed by uniform name
55 55
56 // vertex deformation variables 56 // vertex deformation variables
57 this._hasVertexDeformation = false; 57 this._hasVertexDeformation = false;
58 this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) 58 this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax)
59 this._vertexDeformationTolerance = 0.02; 59 this._vertexDeformationTolerance = 0.02;
60 60
61 // RDGE variables 61 // RDGE variables
62 this._shader = null; 62 this._shader = null;
63 this._materialNode = null; 63 this._materialNode = null;
64 64
65 65
66 /////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////
67 // Property Accessors 67 // Property Accessors
68 /////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////
69 69
70 this.setName = function(n) { 70 this.setName = function(n) {
71 this._name = n; 71 this._name = n;
72 }; 72 };
73 73
74 this.getName = function() { 74 this.getName = function() {
75 return this._name; 75 return this._name;
76 }; 76 };
77 77
78 this.setShaderName = function(n) { 78 this.setShaderName = function(n) {
79 this._shaderName = n; 79 this._shaderName = n;
80 }; 80 };
81 81
82 this.getShaderName = function() { 82 this.getShaderName = function() {
83 return this._shaderName; 83 return this._shaderName;
84 }; 84 };
85 85
86 this.setWorld = function(world) { 86 this.setWorld = function(world) {
87 this._world = world; 87 this._world = world;
88 }; 88 };
89 89
90 this.getWorld = function() { 90 this.getWorld = function() {
91 return this._world; 91 return this._world;
92 }; 92 };
93 93
94 this.getShader = function() { 94 this.getShader = function() {
95 return this._shader; 95 return this._shader;
96 }; 96 };
97 97
98 this.getMaterialNode = function() { 98 this.getMaterialNode = function() {
99 return this._materialNode; 99 return this._materialNode;
100 }; 100 };
101 101
102 // a material can be animated or not. default is not. 102 // a material can be animated or not. default is not.
103 // Any material needing continuous rendering should override this method 103 // Any material needing continuous rendering should override this method
104 this.isAnimated = function() { 104 this.isAnimated = function() {
105 return false; 105 return false;
106 }; 106 };
107 107
108 this.getTechniqueName = function() { 108 this.getTechniqueName = function() {
109 return 'default' 109 return 'default'
110 }; 110 };
111 111
112 // the vertex shader can apply deformations requiring refinement in 112 // the vertex shader can apply deformations requiring refinement in
113 // certain areas. 113 // certain areas.
114 this.hasVertexDeformation = function() { 114 this.hasVertexDeformation = function() {
115 return this._hasVertexDeformation; 115 return this._hasVertexDeformation;
116 }; 116 };
117 117
118 this.getVertexDeformationRange = function() { 118 this.getVertexDeformationRange = function() {
119 return this._vertexDeformationRange.slice(); 119 return this._vertexDeformationRange.slice();
120 }; 120 };
121 121
122 this.getVertexDeformationTolerance = function() { 122 this.getVertexDeformationTolerance = function() {
123 return this._vertexDeformationTolerance; 123 return this._vertexDeformationTolerance;
124 }; 124 };
125 125
126 /////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////
127 // Common Material Methods 127 // Common Material Methods
128 /////////////////////////////////////////////////////////////////////// 128 ///////////////////////////////////////////////////////////////////////
129 this.getProperty = function( propName ) { 129 this.getProperty = function( propName ) {
130 return this._propValues[propName]; 130 return this._propValues[propName];
131 }; 131 };
132 132
133 this.getPropertyCount = function() { 133 this.getPropertyCount = function() {
134 return this._propNames.length; 134 return this._propNames.length;
135 }; 135 };
136 136
137 this.getPropertyAtIndex = function( index ) { 137 this.getPropertyAtIndex = function( index ) {
138 var rtnArr = []; 138 var rtnArr = [];
139 if ((index < 0) || (index >= this.getPropertyCount())) { 139 if ((index < 0) || (index >= this.getPropertyCount())) {
140 throw new Error( "property index " + index + " is out of range for material" ); 140 throw new Error( "property index " + index + " is out of range for material" );
141 } 141 }
142 142
143 return [ this._propNames[index], this._propLabels[index], this._propTypes[index], this._propValues[index] ]; 143 return [ this._propNames[index], this._propLabels[index], this._propTypes[index], this._propValues[index] ];
144 }; 144 };
145 145
146 this.getAllProperties = function( propNames, propValues, propTypes, propLabels) { 146 this.getAllProperties = function( propNames, propValues, propTypes, propLabels) {
147 // clear all the input arrays if there is junk in them 147 // clear all the input arrays if there is junk in them
148 propNames.length = 0; 148 propNames.length = 0;
149 propValues.length = 0; 149 propValues.length = 0;
150 propTypes.length = 0; 150 propTypes.length = 0;
151 propLabels.length = 0; 151 propLabels.length = 0;
152 152
153 var nProps = this._propNames.length; 153 var nProps = this._propNames.length;
154 for (var i=0; i<nProps; i++) { 154 for (var i=0; i<nProps; i++) {
155 propNames[i] = this._propNames[i]; 155 propNames[i] = this._propNames[i];
156 propValues[i] = this._propValues[this._propNames[i]]; 156 propValues[i] = this._propValues[this._propNames[i]];
157 propTypes[i] = this._propTypes[i]; 157 propTypes[i] = this._propTypes[i];
158 propLabels[i] = this._propLabels[i]; 158 propLabels[i] = this._propLabels[i];
159 } 159 }
160 }; 160 };
161 161
162 this.hasProperty = function( prop ) 162 this.hasProperty = function( prop )
163 { 163 {
164 var propNames = [], dummy = []; 164 var propNames = [], dummy = [];
165 this.getAllProperties( propNames, dummy, dummy, dummy ) 165 this.getAllProperties( propNames, dummy, dummy, dummy )
166 for (var i=0; i<propNames.length; i++) 166 for (var i=0; i<propNames.length; i++)
167 { 167 {
168 if (prop === propNames[i]) return true; 168 if (prop === propNames[i]) return true;
169 } 169 }
170 }; 170 };
171 171
172 this.getPropertyType = function( prop ) 172 this.getPropertyType = function( prop )
173 { 173 {
174 var n = this.getPropertyCount(); 174 var n = this.getPropertyCount();
175 for (var i=0; i<n; i++) 175 for (var i=0; i<n; i++)
176 { 176 {
177 if (prop === this._propNames[i]) return this._propTypes[i]; 177 if (prop === this._propNames[i]) return this._propTypes[i];
178