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.js81
1 files changed, 58 insertions, 23 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index d75abb05..22cbb5d4 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -14,6 +14,10 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel;
14// Derived from class GeomObj 14// Derived from class GeomObj
15/////////////////////////////////////////////////////////////////////// 15///////////////////////////////////////////////////////////////////////
16exports.Rectangle = Object.create(GeomObj, { 16exports.Rectangle = Object.create(GeomObj, {
17{
18 if (!MaterialsModel)
19 MaterialsModel = require("js/models/materials-model").MaterialsModel;
20
17 // CONSTANTS 21 // CONSTANTS
18 N_TRIANGLES: { value : 15, writable: false }, // TODO - This is not being used anywhere. Remove? 22 N_TRIANGLES: { value : 15, writable: false }, // TODO - This is not being used anywhere. Remove?
19 23
@@ -944,13 +948,13 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad,
944 } 948 }
945 949
946 //refine the mesh for vertex deformations 950 //refine the mesh for vertex deformations
947// if (material) { 951 if (material) {
948// if (material.hasVertexDeformation()) { 952 if (material.hasVertexDeformation()) {
949// var paramRange = material.getVertexDeformationRange(); 953 var paramRange = material.getVertexDeformationRange();
950// var tolerance = material.getVertexDeformationTolerance(); 954 var tolerance = material.getVertexDeformationTolerance();
951// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 955 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
952// } 956 }
953// } 957 }
954 958
955 // create the RDGE primitive 959 // create the RDGE primitive
956 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 960 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1176,13 +1180,13 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad,
1176 } 1180 }
1177 1181
1178 //refine the mesh for vertex deformations 1182 //refine the mesh for vertex deformations
1179// if (material) { 1183 if (material) {
1180// if (material.hasVertexDeformation()) { 1184 if (material.hasVertexDeformation()) {
1181// var paramRange = material.getVertexDeformationRange(); 1185 var paramRange = material.getVertexDeformationRange();
1182// var tolerance = material.getVertexDeformationTolerance(); 1186 var tolerance = material.getVertexDeformationTolerance();
1183// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1187 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1184// } 1188 }
1185// } 1189 }
1186 1190
1187 // create the RDGE primitive 1191 // create the RDGE primitive
1188 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1192 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1260,15 +1264,15 @@ RectangleGeometry.create = function( ctr, width, height, material ) {
1260 RectangleGeometry.pushIndices( 0, 3, 2 ); 1264 RectangleGeometry.pushIndices( 0, 3, 2 );
1261 1265
1262 //refine the mesh for vertex deformations 1266 //refine the mesh for vertex deformations
1263// if (material) 1267 if (material)
1264// { 1268 {
1265// if (material.hasVertexDeformation()) 1269 if (material.hasVertexDeformation())
1266// { 1270 {
1267// var paramRange = material.getVertexDeformationRange(); 1271 var paramRange = material.getVertexDeformationRange();
1268// var tolerance = material.getVertexDeformationTolerance(); 1272 var tolerance = material.getVertexDeformationTolerance();
1269// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); 1273 nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance );
1270// } 1274 }
1271// } 1275 }
1272 1276
1273 // create the RDGE primitive 1277 // create the RDGE primitive
1274 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); 1278 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
@@ -1281,5 +1285,36 @@ RectangleGeometry.pushIndices = RectangleFill.pushIndices;
1281RectangleGeometry.getVertex = RectangleFill.getVertex; 1285RectangleGeometry.getVertex = RectangleFill.getVertex;
1282RectangleGeometry.getUV = RectangleFill.getUV; 1286RectangleGeometry.getUV = RectangleFill.getUV;
1283 1287
1288RectangleGeometry.init = function()
1289{
1290 this.vertices = [];
1291 this.normals = [];
1292 this.uvs = [];
1293 this.indices = [];
1294}
1295
1296RectangleGeometry.addQuad = function( verts, normals, uvs )
1297{
1298 var offset = this.vertices.length/3;
1299 for (var i=0; i<4; i++)
1300 {
1301 RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]);
1302 RectangleGeometry.pushNormal( normals[i] );
1303 RectangleGeometry.pushUV( uvs[i] );
1304 }
1305
1306 RectangleGeometry.pushIndices( 0+offset, 1+offset, 2+offset );
1307 RectangleGeometry.pushIndices( 2+offset, 3+offset, 0+offset );
1308}
1309
1310RectangleGeometry.buildPrimitive = function()
1311{
1312 var nVertices = this.vertices.length/3;
1313 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
1314}
1315
1316
1317
1318 exports.RectangleGeometry = RectangleGeometry;
1284 1319
1285 1320