001: /*
002: * $RCSfile: Collision.java,v $
003: *
004: * @(#)Collision.java 1.18 98/11/05 20:34:07
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:52 $
034: * $State: Exp $
035: */
036: /*
037: *@Author: Rick Goldberg
038: *@Author: Doug Gehringer
039: */
040: package org.jdesktop.j3d.loaders.vrml97.impl;
041:
042: /** Description of the Class */
043: public class Collision extends Group {
044: // eventIn MFNode addChildren from Group
045: // eventIn MFNode removeChildren from Group
046: // exposedField MFNode children [] from Group
047: // field SFVec3f bboxCenter from Group
048: // field SFVec3f bboxSize from Group
049:
050: // exposedField
051: SFBool collide;
052:
053: // field
054: SFNode proxy;// the proxy geometry for collision detection, not drawn
055:
056: // eventOut
057: SFTime collideTime;
058:
059: javax.media.j3d.Group impl;
060:
061: /**
062: *Constructor for the Collision object
063: *
064: *@param loader Description of the Parameter
065: */
066: public Collision(Loader loader) {
067: super (loader);
068:
069: // exposedField
070: collide = new SFBool(true);
071:
072: // need to turn detection on or off ( which means add or subtract
073: // this proxy from the avatars collide list
074: proxy = new SFNode(null);
075:
076: // eventOut
077: collideTime = new SFTime(0.0);
078:
079: initCollisionFields();
080: }
081:
082: /**
083: *Constructor for the Collision object
084: *
085: *@param loader Description of the Parameter
086: *@param children Description of the Parameter
087: *@param bboxCenter Description of the Parameter
088: *@param bboxSize Description of the Parameter
089: *@param collide Description of the Parameter
090: *@param proxy Description of the Parameter
091: */
092: Collision(Loader loader, MFNode children, SFVec3f bboxCenter,
093: SFVec3f bboxSize, SFBool collide, SFNode proxy) {
094: super (loader, children, bboxCenter, bboxSize);
095: this .collide = collide;
096: this .proxy = proxy;
097:
098: collideTime = new SFTime(0.0);
099:
100: initCollisionFields();
101: }
102:
103: /** Description of the Method */
104: void initImpl() {
105: impl = new javax.media.j3d.Group();
106: impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
107: impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_WRITE);
108: impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_EXTEND);
109: impl
110: .setCapability(javax.media.j3d.Node.ALLOW_LOCAL_TO_VWORLD_READ);
111: implNode = implGroup = impl;
112: super .replaceChildren();// init the implGroup for clone()
113: implReady = true;
114: }
115:
116: /**
117: * Description of the Method
118: *
119: *@param eventInName Description of the Parameter
120: *@param time Description of the Parameter
121: */
122: public void notifyMethod(String eventInName, double time) {
123: if (eventInName == "collide") {
124: //SFBool collideOn = (SFBool)FieldSpec.get(eventInName);
125: // if collideOn check avatars collide list if not there add to it
126: // otherwise remove it.
127: if (collide.getValue() == true) {
128: ;
129: } else {
130: ;
131: }
132: } else {
133: super .notifyMethod(eventInName, time);
134: }
135: }
136:
137: /**
138: * Gets the type attribute of the Collision object
139: *
140: *@return The type value
141: */
142: public String getType() {
143: return "Collision";
144: }
145:
146: /** Description of the Method */
147: void initCollisionFields() {
148: collide.init(this , FieldSpec, Field.EXPOSED_FIELD, "collide");
149: proxy.init(this , FieldSpec, Field.FIELD, "proxy");
150: collideTime.init(this , FieldSpec, Field.EVENT_OUT,
151: "collideTime");
152: }
153:
154: /**
155: * Description of the Method
156: *
157: *@return Description of the Return Value
158: */
159: public Object clone() {
160: return new Collision(loader, (MFNode) children.clone(),
161: (SFVec3f) bboxCenter.clone(), (SFVec3f) bboxSize
162: .clone(), (SFBool) collide.clone(),
163: (SFNode) proxy.clone());
164: }
165:
166: }
|