From b6a8f72f670a8edee35554a4ca3a0618c526d651 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 5 Apr 2012 05:30:55 -0700 Subject: Re-added taper and twist-vert materials. --- js/lib/rdge/materials/pulse-material.js | 1 - js/lib/rdge/materials/taper-material.js | 12 +++++-- js/lib/rdge/materials/twist-vert-material.js | 53 +++++----------------------- js/lib/rdge/texture.js | 45 ++--------------------- js/models/materials-model.js | 4 +++ 5 files changed, 24 insertions(+), 91 deletions(-) (limited to 'js') diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index f7f6c7ae..276f7de6 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -308,7 +308,6 @@ var pulseMaterialDef = } }; -// doing the inheritance here introtudes bugs. Local instance variables are overwritten in the base class //PulseMaterial.prototype = new Material(); if (typeof exports === "object") { diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index 15b7b2b0..efba3807 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js @@ -4,15 +4,17 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; +var Material = require("js/lib/rdge/materials/material").Material; +var Texture = require("js/lib/rdge/texture").Texture; + /////////////////////////////////////////////////////////////////////// // Class GLMaterial // RDGE representation of a material. /////////////////////////////////////////////////////////////////////// -function TaperMaterial() +var TaperMaterial = function TaperMaterial() { // initialize the inherited members - this.inheritedFrom = GLMaterial; + this.inheritedFrom = Material; this.inheritedFrom(); /////////////////////////////////////////////////////////////////////// @@ -250,3 +252,7 @@ taperShaderDef = } }; + +if (typeof exports === "object") { + exports.TaperMaterial = TaperMaterial; +} diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js index 802690a2..f093fbca 100644 --- a/js/lib/rdge/materials/twist-vert-material.js +++ b/js/lib/rdge/materials/twist-vert-material.js @@ -4,15 +4,17 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; +var Material = require("js/lib/rdge/materials/material").Material; +var Texture = require("js/lib/rdge/texture").Texture; + /////////////////////////////////////////////////////////////////////// // Class GLMaterial // RDGE representation of a material. /////////////////////////////////////////////////////////////////////// -function TwistVertMaterial() +var TwistVertMaterial = function TwistVertMaterial() { // initialize the inherited members - this.inheritedFrom = GLMaterial; + this.inheritedFrom = Material; this.inheritedFrom(); /////////////////////////////////////////////////////////////////////// @@ -131,47 +133,6 @@ function TwistVertMaterial() } } - this.export = function() - { - // this function should be overridden by subclasses - var exportStr = "material: " + this.getShaderName() + "\n"; - exportStr += "name: " + this.getName() + "\n"; - - if (this._shader) - exportStr += "color: " + String(this._shader.twistMe.color) + "\n"; - else - exportStr += "color: " + this.getColor() + "\n"; - exportStr += "endMaterial\n"; - - return exportStr; - } - - this.import = function( importStr ) - { - var pu = new MaterialParser( importStr ); - var material = pu.nextValue( "material: " ); - if (material != this.getShaderName()) throw new Error( "ill-formed material" ); - this.setName( pu.nextValue( "name: ") ); - - var rtnStr; - try - { - var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); - - this.setProperty( "color", color); - - var endKey = "endMaterial\n"; - var index = importStr.indexOf( endKey ); - index += endKey.length; - rtnStr = importStr.substr( index ); - } - catch (e) - { - throw new Error( "could not import material: " + importStr ); - } - - return rtnStr; - } this.update = function( time ) { @@ -277,3 +238,7 @@ twistVertShaderDef = } }; +if (typeof exports === "object") { + exports.TwistVertMaterial = TwistVertMaterial; +} + diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js index 2e76f2c0..d2f66efa 100644 --- a/js/lib/rdge/texture.js +++ b/js/lib/rdge/texture.js @@ -216,23 +216,7 @@ function Texture( dstWorld, texMapName, wrap, mips ) return; } - /* - var srcCtx; - if (!this._is3D) - { - srcCtx = srcCanvas.getContext("2d"); - imageData = srcCtx.getImageData( 0, 0, width, height ); - renderCtx.putImageData( imageData, 0, 0 ); - } - else - { - srcCtx = srcCanvas.getContext("experimental-webgl"); - if (srcCtx) - { - renderCtx.drawImage(srcCanvas, 0, 0); - } - } - */ + // copy the source canvas to the context to be used in the texture renderCtx.drawImage(srcCanvas, 0, 0); ///////////////// @@ -240,7 +224,7 @@ function Texture( dstWorld, texMapName, wrap, mips ) renderer.commitTexture( tex ); return tex; -} + } this.isPowerOfTwo = function(x) { @@ -278,31 +262,6 @@ function Texture( dstWorld, texMapName, wrap, mips ) } } - /* - this.findWorld = function( id, elt ) - { - if (elt.id && elt.id === id) - { - if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) - { - var world = elt.elementModel.shapeModel.GLWorld; - return world; - } - } - - if (elt.children) - { - var nKids = elt.children.length; - for (var i=0; i