diff options
Diffstat (limited to 'js/lib/rdge/materials/taper-material.js')
-rw-r--r-- | js/lib/rdge/materials/taper-material.js | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index f6aa782c..b4ff07d3 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js | |||
@@ -1,7 +1,31 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | All Rights Reserved. |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | BSD License. |
5 | |||
6 | Redistribution and use in source and binary forms, with or without | ||
7 | modification, are permitted provided that the following conditions are met: | ||
8 | |||
9 | - Redistributions of source code must retain the above copyright notice, | ||
10 | this list of conditions and the following disclaimer. | ||
11 | - Redistributions in binary form must reproduce the above copyright | ||
12 | notice, this list of conditions and the following disclaimer in the | ||
13 | documentation and/or other materials provided with the distribution. | ||
14 | - Neither the name of Motorola Mobility nor the names of its contributors | ||
15 | may be used to endorse or promote products derived from this software | ||
16 | without specific prior written permission. | ||
17 | |||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
28 | POSSIBILITY OF SUCH DAMAGE. | ||
5 | </copyright> */ | 29 | </copyright> */ |
6 | 30 | ||
7 | var Material = require("js/lib/rdge/materials/material").Material; | 31 | var Material = require("js/lib/rdge/materials/material").Material; |
@@ -38,6 +62,8 @@ var TaperMaterial = function TaperMaterial() | |||
38 | this._hasVertexDeformation = true; | 62 | this._hasVertexDeformation = true; |
39 | this._vertexDeformationTolerance = 0.02; // should be a property | 63 | this._vertexDeformationTolerance = 0.02; // should be a property |
40 | 64 | ||
65 | this.getVertexDeformationTolerance = function() { return this._propValues[this._propNames[7]]; }; | ||
66 | |||
41 | /////////////////////////////////////////////////////////////////////// | 67 | /////////////////////////////////////////////////////////////////////// |
42 | // Methods | 68 | // Methods |
43 | /////////////////////////////////////////////////////////////////////// | 69 | /////////////////////////////////////////////////////////////////////// |
@@ -62,13 +88,30 @@ var TaperMaterial = function TaperMaterial() | |||
62 | this.setShaderValues(); | 88 | this.setShaderValues(); |
63 | }; | 89 | }; |
64 | 90 | ||
91 | this.resetToDefault = function() | ||
92 | { | ||
93 | this._propValues[this._propNames[0]] = 0.25; | ||
94 | this._propValues[this._propNames[1]] = 0.50; | ||
95 | this._propValues[this._propNames[2]] = 0.75; | ||
96 | this._propValues[this._propNames[3]] = -1; | ||
97 | this._propValues[this._propNames[4]] = 1; | ||
98 | this._propValues[this._propNames[5]] = 0.0; | ||
99 | this._propValues[this._propNames[6]] = 0.9; | ||
100 | this._propValues[this._propNames[7]] = this._vertexDeformationTolerance; | ||
101 | this._propValues[this._propNames[8]] = 1.0; | ||
102 | |||
103 | var nProps = this._propNames.length; | ||
104 | for (var i=0; i<nProps; i++) | ||
105 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | ||
106 | }; | ||
107 | |||
65 | 108 | ||
66 | /////////////////////////////////////////////////////////////////////// | 109 | /////////////////////////////////////////////////////////////////////// |
67 | // Material Property Accessors | 110 | // Material Property Accessors |
68 | /////////////////////////////////////////////////////////////////////// | 111 | /////////////////////////////////////////////////////////////////////// |
69 | this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "u_speed" ]; | 112 | this._propNames = [ "u_limit1", "u_limit2", "u_limit3", "u_minVal", "u_maxVal", "u_center", "u_taperAmount", "facettol", "u_speed" ]; |
70 | this._propLabels = [ "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount", "Speed" ]; | 113 | this._propLabels = [ "Minimum Parameter Value", "Center Paramater Value", "Maximum Parameter Value", "Minimum Data Bounds", "Maximum Data Bounds", "Center", "Taper Amount", "Faceting Tolerance", "Speed" ]; |
71 | this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float" ]; | 114 | this._propTypes = [ "float", "float", "float", "float", "float", "float", "float", "float", "float" ]; |
72 | this._propValues = []; | 115 | this._propValues = []; |
73 | 116 | ||
74 | // initialize the property values | 117 | // initialize the property values |
@@ -79,7 +122,8 @@ var TaperMaterial = function TaperMaterial() | |||
79 | this._propValues[this._propNames[4]] = 1; | 122 | this._propValues[this._propNames[4]] = 1; |
80 | this._propValues[this._propNames[5]] = 0.0; | 123 | this._propValues[this._propNames[5]] = 0.0; |
81 | this._propValues[this._propNames[6]] = 0.9; | 124 | this._propValues[this._propNames[6]] = 0.9; |
82 | this._propValues[this._propNames[7]] = 1.0; | 125 | this._propValues[this._propNames[7]] = this._vertexDeformationTolerance; |
126 | this._propValues[this._propNames[8]] = 1.0; | ||
83 | 127 | ||
84 | this.update = function (time) { | 128 | this.update = function (time) { |
85 | var speed = this._propValues["u_speed"]; | 129 | var speed = this._propValues["u_speed"]; |
@@ -135,6 +179,7 @@ taperShaderDef = { | |||
135 | 'u_maxVal': { 'type': 'float' }, | 179 | 'u_maxVal': { 'type': 'float' }, |
136 | 'u_center': { 'type': 'float' }, | 180 | 'u_center': { 'type': 'float' }, |
137 | 'u_taperAmount': { 'type': 'float' }, | 181 | 'u_taperAmount': { 'type': 'float' }, |
182 | 'facettol': { 'type': 'float' }, | ||
138 | 'u_speed': { 'type': 'float' } | 183 | 'u_speed': { 'type': 'float' } |
139 | } | 184 | } |
140 | } | 185 | } |