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/taper-material.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'js/lib/rdge/materials/taper-material.js') 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; +} -- 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/rdge/materials/taper-material.js | 102 ++++++++++++++++---------------- 1 file changed, 52 insertions(+), 50 deletions(-) (limited to 'js/lib/rdge/materials/taper-material.js') diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index 7938336b..c491fe61 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js @@ -23,14 +23,11 @@ var TaperMaterial = function TaperMaterial() this._name = "TaperMaterial"; this._shaderName = "taper"; - this._color = [1, 0, 0, 1]; - this._deltaTime = 0.0; /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - this.getColor = function () { return this._color; }; this.getShaderName = function () { return this._shaderName; }; this.isAnimated = function () { return true; }; @@ -42,7 +39,6 @@ var TaperMaterial = function TaperMaterial() // Methods /////////////////////////////////////////////////////////////////////// // duplcate method requirde - this.dup = function () { return new TaperMaterial(); }; this.init = function (world) { this.setWorld(world); @@ -52,9 +48,6 @@ var TaperMaterial = function TaperMaterial() this._shader.def = taperShaderDef; this._shader.init(); - // set the defaults - this._shader.colorMe.color.set(this.getColor()); - // set up the material node this._materialNode = RDGE.createMaterialNode("taperMaterial" + "_" + world.generateUniqueNodeID()); this._materialNode.setShader(this._shader); @@ -67,41 +60,46 @@ var TaperMaterial = function TaperMaterial() /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// - this._propNames = ["color", "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount"]; - this._propLabels = ["Color", "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount"]; - this._propTypes = ["color", "float", "float", "float", "float", "float", "float", "float"]; + this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "u_speed" ]; + this._propLabels = [ "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount", "Speed" ]; + this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float" ]; this._propValues = []; // initialize the property values - this._propValues[this._propNames[0]] = this._color.slice(); - this._propValues[this._propNames[1]] = 0.25; - this._propValues[this._propNames[2]] = 0.50; - this._propValues[this._propNames[3]] = 0.75; - this._propValues[this._propNames[4]] = -1; - this._propValues[this._propNames[5]] = 1; - this._propValues[this._propNames[6]] = 0.0; - this._propValues[this._propNames[7]] = 0.9; - - this.setProperty = function (prop, value) { + this._propValues[this._propNames[0]] = 0.25; + this._propValues[this._propNames[1]] = 0.50; + this._propValues[this._propNames[2]] = 0.75; + this._propValues[this._propNames[3]] = -1; + this._propValues[this._propNames[4]] = 1; + this._propValues[this._propNames[5]] = 0.0; + this._propValues[this._propNames[6]] = 0.9; + this._propValues[this._propNames[7]] = 1.0; + + this.setProperty = function (prop, value) + { // make sure we have legitimate input - if (this.validateProperty(prop, value)) { - switch (prop) { - case "color": this._propValues[prop] = value.slice(); break; - default: this._propValues[prop] = value; break; - } + if (this.validateProperty(prop, value)) + this._propValues[prop] = value; - this.updateShaderValues(); - } + this.updateShaderValues(); }; - /////////////////////////////////////////////////////////////////////// + this.exportJSON = function () { var jObj = { 'material': this.getShaderName(), - 'name': this.getName(), - 'color': this._propValues["color"] + 'name': this.getName() }; + var n = this._propNames.length; + for (var i=0; i