aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js83
1 files changed, 59 insertions, 24 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 490a9a6f..fc6043d6 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -13,7 +13,11 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13// GL representation of a rectangle. 13// GL representation of a rectangle.
14// Derived from class GeomObj 14// Derived from class GeomObj
15/////////////////////////////////////////////////////////////////////// 15///////////////////////////////////////////////////////////////////////
16var Rectangle = function GLRectangle() { 16var Rectangle = function GLRectangle()
17{
18 if (!MaterialsModel)
19 MaterialsModel = require("js/models/materials-model").MaterialsModel;
20
17 // CONSTANTS 21 // CONSTANTS
18 this.N_TRIANGLES = 15; 22 this.N_TRIANGLES = 15;
19 23
@@ -870,13 +874,13 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad,
870 } 874 }
871 875
872 //refine the mesh for vertex deformations 876 //refine the mesh for vertex deformations
873// if (material) { 877 if (material) {
874// if (material.hasVertexDeformation()) { 878 if (material.hasVertexDeformation()) {
875// var paramRange = material.getVertexDeformationRange(); 879 var paramRange = material.getVertexDeformationRange();
876// var tolerance = material.getVertexDeformationTolerance(); 880 var tolerance = material.getVertexDeformationTolerance();
877// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 881 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
878// } 882 }
879// } 883 }
880 884
881 // create the RDGE primitive 885 // create the RDGE primitive
882 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 886 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1102,13 +1106,13 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad,
1102 } 1106 }
1103 1107
1104 //refine the mesh for vertex deformations 1108 //refine the mesh for vertex deformations
1105// if (material) { 1109 if (material) {
1106// if (material.hasVertexDeformation()) { 1110 if (material.hasVertexDeformation()) {
1107// var paramRange = material.getVertexDeformationRange(); 1111 var paramRange = material.getVertexDeformationRange();
1108// var tolerance = material.getVertexDeformationTolerance(); 1112 var tolerance = material.getVertexDeformationTolerance();
1109// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1113 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1110// } 1114 }
1111// } 1115 }
1112 1116
1113 // create the RDGE primitive 1117 // create the RDGE primitive
1114 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1118 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1186,15 +1190,15 @@ RectangleGeometry.create = function( ctr, width, height, material ) {
1186 RectangleGeometry.pushIndices( 0, 3, 2 ); 1190 RectangleGeometry.pushIndices( 0, 3, 2 );
1187 1191
1188 //refine the mesh for vertex deformations 1192 //refine the mesh for vertex deformations
1189// if (material) 1193 if (material)
1190// { 1194 {
1191// if (material.hasVertexDeformation()) 1195 if (material.hasVertexDeformation())
1192// { 1196 {
1193// var paramRange = material.getVertexDeformationRange(); 1197 var paramRange = material.getVertexDeformationRange();
1194// var tolerance = material.getVertexDeformationTolerance(); 1198 var tolerance = material.getVertexDeformationTolerance();
1195// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1199 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1196// } 1200 }
1197// } 1201 }
1198 1202
1199 // create the RDGE primitive 1203 // create the RDGE primitive
1200 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1204 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1207,11 +1211,42 @@ RectangleGeometry.pushIndices = RectangleFill.pushIndices;
1207RectangleGeometry.getVertex = RectangleFill.getVertex; 1211RectangleGeometry.getVertex = RectangleFill.getVertex;
1208RectangleGeometry.getUV = RectangleFill.getUV; 1212RectangleGeometry.getUV = RectangleFill.getUV;
1209 1213
1214RectangleGeometry.init = function()
1215{
1216 this.vertices = [];
1217 this.normals = [];
1218 this.uvs = [];
1219 this.indices = [];
1220}
1221
1222RectangleGeometry.addQuad = function( verts, normals, uvs )
1223{
1224 var offset = this.vertices.length/3;
1225 for (var i=0; i<4; i++)
1226 {
1227 RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]);
1228 RectangleGeometry.pushNormal( normals[i] );
1229 RectangleGeometry.pushUV( uvs[i] );
1230 }
1231
1232 RectangleGeometry.pushIndices( 0+offset, 1+offset, 2+offset );
1233 RectangleGeometry.pushIndices( 2+offset, 3+offset, 0+offset );
1234}
1235
1236RectangleGeometry.buildPrimitive = function()
1237{
1238 var nVertices = this.vertices.length/3;
1239 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
1240}
1241
1242
1243
1210 1244
1211Rectangle.prototype = new GeomObj(); 1245Rectangle.prototype = new GeomObj();
1212 1246
1213if (typeof exports === "object") { 1247if (typeof exports === "object") {
1214 exports.Rectangle = Rectangle; 1248 exports.Rectangle = Rectangle;
1249 exports.RectangleGeometry = RectangleGeometry;
1215} 1250}
1216 1251
1217 1252