From 0f31002ca696c1ef303d2926a504afd27305e94f Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 4 Apr 2012 05:52:54 -0700 Subject: Added Flag material --- js/lib/geom/rectangle.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index e511d5f4..51947ff1 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -943,13 +943,13 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, } //refine the mesh for vertex deformations -// if (material) { -// if (material.hasVertexDeformation()) { -// var paramRange = material.getVertexDeformationRange(); -// var tolerance = material.getVertexDeformationTolerance(); -// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); -// } -// } + if (material) { + if (material.hasVertexDeformation()) { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } // create the RDGE primitive return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); @@ -1175,13 +1175,13 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, } //refine the mesh for vertex deformations -// if (material) { -// if (material.hasVertexDeformation()) { -// var paramRange = material.getVertexDeformationRange(); -// var tolerance = material.getVertexDeformationTolerance(); -// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); -// } -// } + if (material) { + if (material.hasVertexDeformation()) { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } // create the RDGE primitive return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); @@ -1259,15 +1259,15 @@ RectangleGeometry.create = function( ctr, width, height, material ) { RectangleGeometry.pushIndices( 0, 3, 2 ); //refine the mesh for vertex deformations -// if (material) -// { -// if (material.hasVertexDeformation()) -// { -// var paramRange = material.getVertexDeformationRange(); -// var tolerance = material.getVertexDeformationTolerance(); -// nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); -// } -// } + if (material) + { + if (material.hasVertexDeformation()) + { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } // create the RDGE primitive return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); -- cgit v1.2.3 From c1a6cacf364d79cbf23b41e7089a1a6d39afea85 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 10 Apr 2012 10:12:49 -0700 Subject: Cloud material --- js/lib/geom/rectangle.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 51947ff1..f41c27f6 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -1280,11 +1280,41 @@ RectangleGeometry.pushIndices = RectangleFill.pushIndices; RectangleGeometry.getVertex = RectangleFill.getVertex; RectangleGeometry.getUV = RectangleFill.getUV; +RectangleGeometry.init = function() +{ + this.vertices = []; + this.normals = []; + this.uvs = []; + this.indices = []; +} + +RectangleGeometry.addQuad = function( verts, normals, uvs ) +{ + for (var i=0; i<4; i++) + { + RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]); + RectangleGeometry.pushNormal( normals[i] ); + RectangleGeometry.pushUV( uvs[i] ); + } + + RectangleGeometry.pushIndices( 0, 1, 2 ); + RectangleGeometry.pushIndices( 2, 3, 0 ); +} + +RectangleGeometry.buildPrimitive = function() +{ + var nVertices = this.vertices.length; + return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); +} + + + Rectangle.prototype = new GeomObj(); if (typeof exports === "object") { exports.Rectangle = Rectangle; + exports.RectangleGeometry = RectangleGeometry; } -- cgit v1.2.3 From 331b2ad4d602016f9bb3d03be759fd81fed50c10 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 13 Apr 2012 07:08:42 -0700 Subject: Cloud Material --- js/lib/geom/rectangle.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index f41c27f6..d4dd8033 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -12,7 +12,11 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; // GL representation of a rectangle. // Derived from class GeomObj /////////////////////////////////////////////////////////////////////// -var Rectangle = function GLRectangle() { +var Rectangle = function GLRectangle() +{ + if (!MaterialsModel) + MaterialsModel = require("js/models/materials-model").MaterialsModel; + // CONSTANTS this.N_TRIANGLES = 15; -- cgit v1.2.3 From 8992d9baf542135e910bb59328a592d9e330703a Mon Sep 17 00:00:00 2001 From: hwc487 Date: Sun, 15 Apr 2012 05:16:34 -0700 Subject: Cloud Material --- js/lib/geom/rectangle.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index d4dd8033..70f6b01b 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -1294,6 +1294,7 @@ RectangleGeometry.init = function() RectangleGeometry.addQuad = function( verts, normals, uvs ) { + var offset = this.vertices.length/3; for (var i=0; i<4; i++) { RectangleGeometry.pushVertex( verts[i][0], verts[i][1], verts[i][2]); @@ -1301,13 +1302,13 @@ RectangleGeometry.addQuad = function( verts, normals, uvs ) RectangleGeometry.pushUV( uvs[i] ); } - RectangleGeometry.pushIndices( 0, 1, 2 ); - RectangleGeometry.pushIndices( 2, 3, 0 ); + RectangleGeometry.pushIndices( 0+offset, 1+offset, 2+offset ); + RectangleGeometry.pushIndices( 2+offset, 3+offset, 0+offset ); } RectangleGeometry.buildPrimitive = function() { - var nVertices = this.vertices.length; + var nVertices = this.vertices.length/3; return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); } -- cgit v1.2.3 From f13d0f45f6b449764898e99db309c43b51a33476 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 19 Apr 2012 13:39:54 -0700 Subject: chaned textures --- js/lib/geom/rectangle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index ef91d158..304b9c19 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -1214,7 +1214,7 @@ RectangleGeometry.addQuad = function( verts, normals, uvs ) RectangleGeometry.buildPrimitive = function() { var nVertices = this.vertices.length/3; - return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); + return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices); } -- cgit v1.2.3 From 25a2e1c5eb21a18caccc7a9435d835a3f5e7f3a0 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 14 May 2012 10:37:03 -0700 Subject: More merge problems --- js/lib/geom/rectangle.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 22cbb5d4..ab0d7022 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -14,13 +14,12 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; // Derived from class GeomObj /////////////////////////////////////////////////////////////////////// exports.Rectangle = Object.create(GeomObj, { -{ - if (!MaterialsModel) - MaterialsModel = require("js/models/materials-model").MaterialsModel; - // CONSTANTS N_TRIANGLES: { value : 15, writable: false }, // TODO - This is not being used anywhere. Remove? + //if (!MaterialsModel) + // MaterialsModel = require("js/models/materials-model").MaterialsModel; + /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// @@ -1180,8 +1179,10 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, } //refine the mesh for vertex deformations - if (material) { - if (material.hasVertexDeformation()) { + if (material) + { + if (material.hasVertexDeformation()) + { var paramRange = material.getVertexDeformationRange(); var tolerance = material.getVertexDeformationTolerance(); nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); -- cgit v1.2.3 From 6c994c4b90023cecf4fd0caafb404b859fe28f54 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 6 Jun 2012 16:34:41 -0700 Subject: material cleanup and rearchitecture --- js/lib/geom/rectangle.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'js/lib/geom/rectangle.js') diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 42d51e74..81a8556d 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -73,16 +73,19 @@ exports.Rectangle = Object.create(GeomObj, { this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; if(strokeMaterial) { - this._strokeMaterial = strokeMaterial; + this._strokeMaterial = strokeMaterial.dup(); } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } + if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); + if(fillMaterial) { - this._fillMaterial = fillMaterial; + this._fillMaterial = fillMaterial.dup(); } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } + if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); } }, @@ -289,19 +292,23 @@ exports.Rectangle = Object.create(GeomObj, { var strokeMaterialName = jObj.strokeMat; var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); + var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); if (!strokeMat) { console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } this._strokeMaterial = strokeMat; + if (this._strokeMaterial.hasProperty( 'color' )) + this._strokeMaterial.setProperty( 'color', this._strokeColor ); - var fillMat = MaterialsModel.getMaterial( fillMaterialName ); + var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); if (!fillMat) { console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } this._fillMaterial = fillMat; + if (this._fillMaterial.hasProperty( 'color' )) + this._fillMaterial.setProperty( 'color', this._fillColor ); this.importMaterialsJSON( jObj.materials ); } -- cgit v1.2.3