001: /*
002: * $RCSfile: OrientationInterpolator.java,v $
003: *
004: * @(#)OrientationInterpolator.java 1.18 98/11/05 20:34:50
005: *
006: * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007: *
008: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009: * modify and redistribute this software in source and binary code form,
010: * provided that i) this copyright notice and license appear on all copies of
011: * the software; and ii) Licensee does not utilize the software in a manner
012: * which is disparaging to Sun.
013: *
014: * This software is provided "AS IS," without a warranty of any kind. ALL
015: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024: * POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: *
032: * $Revision: 1.2 $
033: * $Date: 2005/02/03 23:06:59 $
034: * $State: Exp $
035: */
036: /*
037: * @Author: Rick Goldberg
038: * @Author: Doug Gehringer
039: *
040: */
041: package org.jdesktop.j3d.loaders.vrml97.impl;
042:
043: /** Description of the Class */
044: public class OrientationInterpolator extends Interpolator {
045:
046: // eventIn
047: SFFloat fraction;
048:
049: // exposedField
050: // MFFloat key; // From Interpolator
051: MFRotation keyValue;
052:
053: // eventOut
054:
055: SFRotation value;
056:
057: float[] v1, v2;
058: int i, j;
059:
060: /**
061: *Constructor for the OrientationInterpolator object
062: *
063: *@param loader Description of the Parameter
064: */
065: public OrientationInterpolator(Loader loader) {
066: super (loader);
067: fraction = new SFFloat(0.0f);
068: key = new MFFloat();
069: keyValue = new MFRotation();
070: value = new SFRotation(0.0f, 0.0f, 1.0f, 0.0f);
071: initFields();
072: }
073:
074: /**
075: *Constructor for the OrientationInterpolator object
076: *
077: *@param loader Description of the Parameter
078: *@param key Description of the Parameter
079: *@param keyValue Description of the Parameter
080: */
081: OrientationInterpolator(Loader loader, MFFloat key,
082: MFRotation keyValue) {
083: super (loader);
084: // initialize the interpolator to the right
085: // value. otherwise do it manually;
086: this .fraction = new SFFloat(0.0f);
087: this .key = key;
088: this .keyValue = keyValue;
089: this .value = new SFRotation(0.0f, 0.0f, 1.0f, 0.0f);
090: initFields();
091: }
092:
093: /**
094: * Description of the Method
095: *
096: *@param eventInName Description of the Parameter
097: *@param time Description of the Parameter
098: */
099: public void notifyMethod(String eventInName, double time) {
100: if (eventInName.equals("fraction")) {
101: //System.out.println("OrientationInterpolator: fraction");
102: if (key.mfloat.length > 0) {
103: setIndexFract(fraction.value);
104: //System.out.println("OrientationInterpolator: " +
105: // "fraction.value = " + fraction.value + " iL = " + iL);
106: v1 = keyValue.rots[iL].rot;
107: v2 = keyValue.rots[iL + 1].rot;
108: value.rot[0] = (v1[0] * af) + (v2[0] * f);
109: value.rot[1] = (v1[1] * af) + (v2[1] * f);
110: value.rot[2] = (v1[2] * af) + (v2[2] * f);
111: value.rot[3] = (v1[3] * af) + (v2[3] * f);
112: }
113: value.route();
114: }
115:
116: }
117:
118: /**
119: * Description of the Method
120: *
121: *@return Description of the Return Value
122: */
123: public Object clone() {
124: return new OrientationInterpolator(loader, (MFFloat) key
125: .clone(), (MFRotation) keyValue.clone());
126: }
127:
128: /**
129: * Gets the type attribute of the OrientationInterpolator object
130: *
131: *@return The type value
132: */
133: public String getType() {
134: return "OrientationInterpolator";
135: }
136:
137: /** Description of the Method */
138: void initFields() {
139: fraction.init(this , FieldSpec, Field.EVENT_IN, "fraction");
140: key.init(this , FieldSpec, Field.EXPOSED_FIELD, "key");
141: keyValue.init(this , FieldSpec, Field.EXPOSED_FIELD, "keyValue");
142: value.init(this , FieldSpec, Field.EVENT_OUT, "value");
143: }
144:
145: }
|