001: /*
002: * $RCSfile: Cone.java,v $
003: *
004: * @(#)Cone.java 1.24 98/11/05 20:34:08
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.3 $
033: * $Date: 2006/03/28 14:58:09 $
034: * $State: Exp $
035: */
036: /*
037: *@Author: Rick Goldberg
038: *@Author: Doug Gehringer
039: *@Author: Nikolai V. Chr.
040: *
041: */
042: package org.jdesktop.j3d.loaders.vrml97.impl;
043:
044: import javax.media.j3d.BoundingBox;
045: import javax.vecmath.Point3d;
046:
047: /** Description of the Class */
048: public class Cone extends GroupGeom {
049:
050: // field
051: SFFloat bottomRadius;
052: SFFloat height;
053: SFBool side;
054: SFBool bottom;
055:
056: BoundingBox bounds;
057:
058: /**
059: *Constructor for the Cone object
060: *
061: *@param loader Description of the Parameter
062: */
063: public Cone(Loader loader) {
064: super (loader);
065: bottomRadius = new SFFloat(1.0f);
066: height = new SFFloat(2.0f);
067: side = new SFBool(true);
068: bottom = new SFBool(true);
069: initFields();
070: }
071:
072: /**
073: *Constructor for the Cone object
074: *
075: *@param loader Description of the Parameter
076: *@param bottomRadius Description of the Parameter
077: *@param height Description of the Parameter
078: *@param side Description of the Parameter
079: *@param bottom Description of the Parameter
080: */
081: Cone(Loader loader, SFFloat bottomRadius, SFFloat height,
082: SFBool side, SFBool bottom) {
083: super (loader);
084: this .bottomRadius = bottomRadius;
085: this .height = height;
086: this .side = side;
087: this .bottom = bottom;
088: initFields();
089: }
090:
091: /** Description of the Method */
092: void initFields() {
093: bottomRadius.init(this , FieldSpec, Field.FIELD, "bottomRadius");
094: height.init(this , FieldSpec, Field.FIELD, "height");
095: side.init(this , FieldSpec, Field.FIELD, "side");
096: bottom.init(this , FieldSpec, Field.FIELD, "bottom");
097: }
098:
099: /**
100: * Description of the Method
101: *
102: *@param eventInName Description of the Parameter
103: *@param time Description of the Parameter
104: */
105: public void notifyMethod(String eventInName, double time) {
106: ;
107: }
108:
109: /**
110: * Description of the Method
111: *
112: *@return Description of the Return Value
113: */
114: public Object clone() {
115: return new Cone(loader, (SFFloat) bottomRadius.clone(),
116: (SFFloat) height.clone(), (SFBool) side.clone(),
117: (SFBool) bottom.clone());
118: }
119:
120: /** Description of the Method */
121: public void initImpl() {
122: ;
123: }
124:
125: /**
126: * Description of the Method
127: *
128: *@param ap Description of the Parameter
129: *@return Description of the Return Value
130: */
131: public javax.media.j3d.Group initGroupImpl(
132: javax.media.j3d.Appearance ap) {
133: implGroup = new com.sun.j3d.utils.geometry.Cone(
134: bottomRadius.value,
135: height.value,
136: com.sun.j3d.utils.geometry.Primitive.GENERATE_NORMALS
137: | com.sun.j3d.utils.geometry.Primitive.GEOMETRY_NOT_SHARED
138: | com.sun.j3d.utils.geometry.Primitive.GENERATE_TEXTURE_COORDS,
139: 30, 4, ap);
140:
141: ((javax.media.j3d.Node) implGroup)
142: .clearCapability(javax.media.j3d.Node.ENABLE_PICK_REPORTING);
143:
144: // The util constructs a group with the side, and bottom as
145: // children. Handle removing the elements by moving from the end of
146: // the group to the beginning
147: if (loader.debug) {
148: System.out.println("Cone group before edit: ");
149: loader.treePrinter.print(implGroup);
150: }
151: if (!bottom.value) {
152: if (loader.debug) {
153: System.out.println("no bottom");
154: }
155: ((javax.media.j3d.Group) implGroup)
156: .removeChild(com.sun.j3d.utils.geometry.Cone.CAP);
157: }
158: if (!side.value) {
159: if (loader.debug) {
160: System.out.println("no side");
161: }
162: ((javax.media.j3d.Group) implGroup)
163: .removeChild(com.sun.j3d.utils.geometry.Cone.BODY);
164: }
165: if (loader.debug) {
166: System.out.println("Cone group after edit: ");
167: loader.treePrinter.print(implGroup);
168: }
169:
170: bounds = new BoundingBox(new Point3d(-bottomRadius.value,
171: -height.value / 2.0, -bottomRadius.value), new Point3d(
172: bottomRadius.value, height.value / 2.0,
173: bottomRadius.value));
174: return implGroup;
175: }
176:
177: /**
178: * Gets the boundingBox attribute of the Cone object
179: *
180: *@return The boundingBox value
181: */
182: public BoundingBox getBoundingBox() {
183: return bounds;
184: }
185:
186: /**
187: * Gets the implGeom attribute of the Cone object
188: *
189: *@return The implGeom value
190: */
191: public javax.media.j3d.Geometry getImplGeom() {
192: // should not be called
193: throw new NullPointerException();
194: }
195:
196: // this should perhaps be renamed haveTextureCoords().
197: /**
198: * Description of the Method
199: *
200: *@return Description of the Return Value
201: */
202: public boolean haveTexture() {
203: return true;
204: }
205:
206: /**
207: * Gets the type attribute of the Cone object
208: *
209: *@return The type value
210: */
211: public String getType() {
212: return "Cone";
213: }
214:
215: }
|