001: /*
002: * $RCSfile: OrientedShape3D.java,v $
003: *
004: * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.7 $
028: * $Date: 2008/02/28 20:17:27 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035:
036: /**
037: * The OrientedShape3D leaf node is a Shape3D node that is oriented
038: * along a specified axis or about a specified point. It defines an
039: * alignment mode and a rotation point or axis. This will cause
040: * the local +<i>z</i> axis of the object to point at the viewer's eye
041: * position. This is done regardless of the transforms above this
042: * OrientedShape3D node in the scene graph. It optionally defines a
043: * scale value along with a constant scale enable flag that causes
044: * this node to be scale invariant, subject only to its scale.
045: *
046: * <p>
047: * OrientedShape3D is similar in functionality to the Billboard
048: * behavior, but OrientedShape3D nodes will orient themselves
049: * correctly for each view, and they can be used within a SharedGroup.
050: *
051: * <p>
052: * If the alignment mode is ROTATE_ABOUT_AXIS, then the rotation will be
053: * around the specified axis. If the alignment mode is
054: * ROTATE_ABOUT_POINT, then the rotation will be about the specified
055: * point, with an additional rotation to align the +<i>y</i> axis of the
056: * TransformGroup with the +<i>y</i> axis in the View.
057: *
058: * <p>
059: * If the constant scale enable flag is set, the object will be drawn
060: * the same size in absolute screen coordinates (meters), regardless
061: * of the following: any transforms above this OrientedShape3D node in
062: * the scene graph, the view scale, the window scale, or the effects
063: * of perspective correction. This is done by scaling the geometry
064: * about the local origin of this node, such that 1 unit in local
065: * coordinates is equal to the number of meters specified by this
066: * node's scale value. If the constant scale enable flag is set to
067: * false, then the scale is not used. The default scale is 1.0
068: * meters.
069: *
070: * <p>
071: * OrientedShape3D nodes are ideal for drawing screen-aligned text or
072: * for drawing roughly-symmetrical objects. A typical use might
073: * consist of a quadrilateral that contains a texture of a tree.
074: *
075: * <p>
076: * Note that in a multiple View system, picking and interestion test
077: * is done with the primary View only.
078: *
079: * @see Billboard
080: *
081: * @since Java 3D 1.2
082: */
083:
084: public class OrientedShape3D extends Shape3D {
085:
086: /**
087: * Specifies that rotation should be about the specified axis.
088: * @see #setAlignmentMode
089: */
090: public static final int ROTATE_ABOUT_AXIS = 0;
091:
092: /**
093: * Specifies that rotation should be about the specified point and
094: * that the children's Y-axis should match the view object's Y-axis.
095: * @see #setAlignmentMode
096: */
097: public static final int ROTATE_ABOUT_POINT = 1;
098:
099: /**
100: * Specifies that no rotation is done. The OrientedShape3D will
101: * not be aligned to the view.
102: * @see #setAlignmentMode
103: *
104: * @since Java 3D 1.3
105: */
106: public static final int ROTATE_NONE = 2;
107:
108: /**
109: * Specifies that this OrientedShape3D node
110: * allows reading its alignment mode information.
111: */
112: public static final int ALLOW_MODE_READ = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_MODE_READ;
113:
114: /**
115: * Specifies that this OrientedShape3D node
116: * allows writing its alignment mode information.
117: */
118: public static final int ALLOW_MODE_WRITE = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_MODE_WRITE;
119:
120: /**
121: * Specifies that this OrientedShape3D node
122: * allows reading its alignment axis information.
123: */
124: public static final int ALLOW_AXIS_READ = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_AXIS_READ;
125:
126: /**
127: * Specifies that this OrientedShape3D node
128: * allows writing its alignment axis information.
129: */
130: public static final int ALLOW_AXIS_WRITE = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_AXIS_WRITE;
131:
132: /**
133: * Specifies that this OrientedShape3D node
134: * allows reading its rotation point information.
135: */
136: public static final int ALLOW_POINT_READ = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_POINT_READ;
137:
138: /**
139: * Specifies that this OrientedShape3D node
140: * allows writing its rotation point information.
141: */
142: public static final int ALLOW_POINT_WRITE = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_POINT_WRITE;
143:
144: /**
145: * Specifies that this OrientedShape3D node
146: * allows reading its scale and constant scale enable information.
147: *
148: * @since Java 3D 1.3
149: */
150: public static final int ALLOW_SCALE_READ = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_SCALE_READ;
151:
152: /**
153: * Specifies that this OrientedShape3D node
154: * allows writing its scale and constant scale enable information.
155: *
156: * @since Java 3D 1.3
157: */
158: public static final int ALLOW_SCALE_WRITE = CapabilityBits.ORIENTED_SHAPE3D_ALLOW_SCALE_WRITE;
159:
160: // Array for setting default read capabilities
161: private static final int[] readCapabilities = { ALLOW_MODE_READ,
162: ALLOW_AXIS_READ, ALLOW_POINT_READ, ALLOW_SCALE_READ };
163:
164: /**
165: * Constructs an OrientedShape3D node with default parameters.
166: * The default values are as follows:
167: * <ul>
168: * alignment mode : ROTATE_ABOUT_AXIS<br>
169: * alignment axis : Y-axis (0,1,0)<br>
170: * rotation point : (0,0,1)<br>
171: * constant scale enable : false<br>
172: * scale : 1.0<br>
173: *</ul>
174: */
175: public OrientedShape3D() {
176: super ();
177: // set default read capabilities
178: setDefaultReadCapabilities(readCapabilities);
179: }
180:
181: /**
182: * Constructs an OrientedShape3D node with the specified geometry
183: * component, appearance component, mode, and axis.
184: * The specified axis must not be parallel to the <i>Z</i>
185: * axis--(0,0,<i>z</i>) for any value of <i>z</i>. It is not
186: * possible for the +<i>Z</i> axis to point at the viewer's eye
187: * position by rotating about itself. The target transform will
188: * be set to the identity if the axis is (0,0,<i>z</i>).
189: *
190: * @param geometry the geometry component with which to initialize
191: * this shape node
192: * @param appearance the appearance component of the shape node
193: * @param mode alignment mode, one of: ROTATE_ABOUT_AXIS,
194: * ROTATE_ABOUT_POINT, or ROTATE_NONE
195: * @param axis the ray about which the OrientedShape3D rotates
196: */
197: public OrientedShape3D(Geometry geometry, Appearance appearance,
198: int mode, Vector3f axis) {
199:
200: super (geometry, appearance);
201:
202: // set default read capabilities
203: setDefaultReadCapabilities(readCapabilities);
204:
205: ((OrientedShape3DRetained) retained).initAlignmentMode(mode);
206: ((OrientedShape3DRetained) retained).initAlignmentAxis(axis);
207: }
208:
209: /**
210: * Constructs an OrientedShape3D node with the specified geometry
211: * component, appearance component, mode, and rotation point.
212: *
213: * @param geometry the geometry component with which to initialize
214: * this shape node
215: * @param appearance the appearance component of the shape node
216: * @param mode alignment mode, one of: ROTATE_ABOUT_AXIS,
217: * ROTATE_ABOUT_POINT, or ROTATE_NONE
218: * @param point the position about which the OrientedShape3D rotates
219: */
220: public OrientedShape3D(Geometry geometry, Appearance appearance,
221: int mode, Point3f point) {
222:
223: super (geometry, appearance);
224:
225: // set default read capabilities
226: setDefaultReadCapabilities(readCapabilities);
227:
228: ((OrientedShape3DRetained) retained).initAlignmentMode(mode);
229: ((OrientedShape3DRetained) retained).initRotationPoint(point);
230:
231: }
232:
233: /**
234: * Constructs an OrientedShape3D node with the specified geometry
235: * component, appearance component, mode, axis, constant scale
236: * enable flag, and scale
237: * The specified axis must not be parallel to the <i>Z</i>
238: * axis--(0,0,<i>z</i>) for any value of <i>z</i>. It is not
239: * possible for the +<i>Z</i> axis to point at the viewer's eye
240: * position by rotating about itself. The target transform will
241: * be set to the identity if the axis is (0,0,<i>z</i>).
242: *
243: * @param geometry the geometry component with which to initialize
244: * this shape node
245: * @param appearance the appearance component of the shape node
246: * @param mode alignment mode, one of: ROTATE_ABOUT_AXIS,
247: * ROTATE_ABOUT_POINT, or ROTATE_NONE
248: * @param axis the ray about which the OrientedShape3D rotates
249: * @param constantScaleEnable a flag indicating whether to enable
250: * constant scale
251: * @param scale scale value used when constant scale is enabled
252: *
253: * @since Java 3D 1.3
254: */
255: public OrientedShape3D(Geometry geometry, Appearance appearance,
256: int mode, Vector3f axis, boolean constantScaleEnable,
257: double scale) {
258:
259: super (geometry, appearance);
260:
261: // set default read capabilities
262: setDefaultReadCapabilities(readCapabilities);
263:
264: ((OrientedShape3DRetained) retained).initAlignmentMode(mode);
265: ((OrientedShape3DRetained) retained).initAlignmentAxis(axis);
266: ((OrientedShape3DRetained) retained)
267: .initConstantScaleEnable(constantScaleEnable);
268: ((OrientedShape3DRetained) retained).initScale(scale);
269: }
270:
271: /**
272: * Constructs an OrientedShape3D node with the specified geometry
273: * component, appearance component, mode, and rotation point.
274: *
275: * @param geometry the geometry component with which to initialize
276: * this shape node
277: * @param appearance the appearance component of the shape node
278: * @param mode alignment mode, one of: ROTATE_ABOUT_AXIS,
279: * ROTATE_ABOUT_POINT, or ROTATE_NONE
280: * @param point the position about which the OrientedShape3D rotates
281: * @param constantScaleEnable a flag indicating whether to enable
282: * constant scale
283: * @param scale scale value used when constant scale is enabled
284: *
285: * @since Java 3D 1.3
286: */
287: public OrientedShape3D(Geometry geometry, Appearance appearance,
288: int mode, Point3f point, boolean constantScaleEnable,
289: double scale) {
290:
291: super (geometry, appearance);
292:
293: // set default read capabilities
294: setDefaultReadCapabilities(readCapabilities);
295:
296: ((OrientedShape3DRetained) retained).initAlignmentMode(mode);
297: ((OrientedShape3DRetained) retained).initRotationPoint(point);
298: ((OrientedShape3DRetained) retained)
299: .initConstantScaleEnable(constantScaleEnable);
300: ((OrientedShape3DRetained) retained).initScale(scale);
301: }
302:
303: /**
304: * Creates the retained mode OrientedShape3DRetained object that this
305: * OrientedShape3D object will point to.
306: */
307: void createRetained() {
308: retained = new OrientedShape3DRetained();
309: retained.setSource(this );
310: }
311:
312: /**
313: * Sets the alignment mode.
314: *
315: * @param mode alignment mode, one of: ROTATE_ABOUT_AXIS,
316: * ROTATE_ABOUT_POINT, or ROTATE_NONE
317: *
318: * @exception CapabilityNotSetException if appropriate capability is
319: * not set and this object is part of live or compiled scene graph
320: */
321: public void setAlignmentMode(int mode) {
322: if (isLiveOrCompiled())
323: if (!this .getCapability(ALLOW_MODE_WRITE))
324: throw new CapabilityNotSetException(J3dI18N
325: .getString("OrientedShape3D0"));
326: if (isLive())
327: ((OrientedShape3DRetained) retained).setAlignmentMode(mode);
328: else
329: ((OrientedShape3DRetained) retained)
330: .initAlignmentMode(mode);
331: }
332:
333: /**
334: * Retrieves the alignment mode.
335: *
336: * @return one of: ROTATE_ABOUT_AXIS, ROTATE_ABOUT_POINT,
337: * or ROTATE_NONE
338: *
339: * @exception CapabilityNotSetException if appropriate capability is
340: * not set and this object is part of live or compiled scene graph
341: */
342: public int getAlignmentMode() {
343: if (isLiveOrCompiled())
344: if (!this .getCapability(ALLOW_MODE_READ))
345: throw new CapabilityNotSetException(J3dI18N
346: .getString("OrientedShape3D1"));
347: return ((OrientedShape3DRetained) retained).getAlignmentMode();
348: }
349:
350: /**
351: * Sets the new alignment axis. This is the ray about which this
352: * OrientedShape3D rotates when the mode is ROTATE_ABOUT_AXIS.
353: * The specified axis must not be parallel to the <i>Z</i>
354: * axis--(0,0,<i>z</i>) for any value of <i>z</i>. It is not
355: * possible for the +<i>Z</i> axis to point at the viewer's eye
356: * position by rotating about itself. The target transform will
357: * be set to the identity if the axis is (0,0,<i>z</i>).
358: *
359: * @param axis the new alignment axis
360: *
361: * @exception CapabilityNotSetException if appropriate capability is
362: * not set and this object is part of live or compiled scene graph
363: */
364: public void setAlignmentAxis(Vector3f axis) {
365: if (isLiveOrCompiled())
366: if (!this .getCapability(ALLOW_AXIS_WRITE))
367: throw new CapabilityNotSetException(J3dI18N
368: .getString("OrientedShape3D2"));
369: if (isLive())
370: ((OrientedShape3DRetained) retained).setAlignmentAxis(axis);
371: else
372: ((OrientedShape3DRetained) retained)
373: .initAlignmentAxis(axis);
374: }
375:
376: /**
377: * Sets the new alignment axis. This is the ray about which this
378: * OrientedShape3D rotates when the mode is ROTATE_ABOUT_AXIS.
379: * The specified axis must not be parallel to the <i>Z</i>
380: * axis--(0,0,<i>z</i>) for any value of <i>z</i>. It is not
381: * possible for the +<i>Z</i> axis to point at the viewer's eye
382: * position by rotating about itself. The target transform will
383: * be set to the identity if the axis is (0,0,<i>z</i>).
384: *
385: * @param x the x component of the alignment axis
386: * @param y the y component of the alignment axis
387: * @param z the z component of the alignment axis
388: *
389: * @exception CapabilityNotSetException if appropriate capability is
390: * not set and this object is part of live or compiled scene graph
391: */
392: public void setAlignmentAxis(float x, float y, float z) {
393: if (isLiveOrCompiled())
394: if (!this .getCapability(ALLOW_AXIS_WRITE))
395: throw new CapabilityNotSetException(J3dI18N
396: .getString("OrientedShape3D2"));
397: if (isLive())
398: ((OrientedShape3DRetained) retained).setAlignmentAxis(x, y,
399: z);
400: else
401: ((OrientedShape3DRetained) retained).initAlignmentAxis(x,
402: y, z);
403: }
404:
405: /**
406: * Retrieves the alignment axis of this OrientedShape3D node,
407: * and copies it into the specified vector.
408: *
409: * @param axis the vector that will contain the alignment axis
410: *
411: * @exception CapabilityNotSetException if appropriate capability is
412: * not set and this object is part of live or compiled scene graph
413: */
414: public void getAlignmentAxis(Vector3f axis) {
415: if (isLiveOrCompiled())
416: if (!this .getCapability(ALLOW_AXIS_READ))
417: throw new CapabilityNotSetException(J3dI18N
418: .getString("OrientedShape3D3"));
419: ((OrientedShape3DRetained) retained).getAlignmentAxis(axis);
420: }
421:
422: /**
423: * Sets the new rotation point. This is the point about which the
424: * OrientedShape3D rotates when the mode is ROTATE_ABOUT_POINT.
425: *
426: * @param point the new rotation point
427: *
428: * @exception CapabilityNotSetException if appropriate capability is
429: * not set and this object is part of live or compiled scene graph
430: */
431: public void setRotationPoint(Point3f point) {
432: if (isLiveOrCompiled())
433: if (!this .getCapability(ALLOW_POINT_WRITE))
434: throw new CapabilityNotSetException(J3dI18N
435: .getString("OrientedShape3D4"));
436: if (isLive())
437: ((OrientedShape3DRetained) retained)
438: .setRotationPoint(point);
439: else
440: ((OrientedShape3DRetained) retained)
441: .initRotationPoint(point);
442: }
443:
444: /**
445: * Sets the new rotation point. This is the point about which the
446: * OrientedShape3D rotates when the mode is ROTATE_ABOUT_POINT.
447: *
448: * @param x the x component of the rotation point
449: * @param y the y component of the rotation point
450: * @param z the z component of the rotation point
451: *
452: * @exception CapabilityNotSetException if appropriate capability is
453: * not set and this object is part of live or compiled scene graph
454: */
455: public void setRotationPoint(float x, float y, float z) {
456: if (isLiveOrCompiled())
457: if (!this .getCapability(ALLOW_POINT_WRITE))
458: throw new CapabilityNotSetException(J3dI18N
459: .getString("OrientedShape3D4"));
460: if (isLive())
461: ((OrientedShape3DRetained) retained).setRotationPoint(x, y,
462: z);
463: else
464: ((OrientedShape3DRetained) retained).initRotationPoint(x,
465: y, z);
466: }
467:
468: /**
469: * Retrieves the rotation point of this OrientedShape3D node,
470: * and copies it into the specified vector.
471: *
472: * @param point the point that will contain the rotation point
473: *
474: * @exception CapabilityNotSetException if appropriate capability is
475: * not set and this object is part of live or compiled scene graph
476: */
477: public void getRotationPoint(Point3f point) {
478: if (isLiveOrCompiled())
479: if (!this .getCapability(ALLOW_POINT_READ))
480: throw new CapabilityNotSetException(J3dI18N
481: .getString("OrientedShape3D5"));
482: ((OrientedShape3DRetained) retained).getRotationPoint(point);
483: }
484:
485: /**
486: * Sets the constant scale enable flag.
487: *
488: * @param constantScaleEnable a flag indicating whether to enable
489: * constant scale
490: *
491: * @exception CapabilityNotSetException if appropriate capability is
492: * not set and this object is part of live or compiled scene graph
493: *
494: * @since Java 3D 1.3
495: */
496: public void setConstantScaleEnable(boolean constantScaleEnable) {
497: if (isLiveOrCompiled())
498: if (!this .getCapability(ALLOW_SCALE_WRITE))
499: throw new CapabilityNotSetException(J3dI18N
500: .getString("OrientedShape3D6"));
501:
502: if (isLive())
503: ((OrientedShape3DRetained) retained)
504: .setConstantScaleEnable(constantScaleEnable);
505: else
506: ((OrientedShape3DRetained) retained)
507: .initConstantScaleEnable(constantScaleEnable);
508: }
509:
510: /**
511: * Retrieves the constant scale enable flag.
512: *
513: * @return the current constant scale enable flag
514: *
515: * @exception CapabilityNotSetException if appropriate capability is
516: * not set and this object is part of live or compiled scene graph
517: *
518: * @since Java 3D 1.3
519: */
520: public boolean getConstantScaleEnable() {
521: if (isLiveOrCompiled())
522: if (!this .getCapability(ALLOW_SCALE_READ))
523: throw new CapabilityNotSetException(J3dI18N
524: .getString("OrientedShape3D7"));
525:
526: return ((OrientedShape3DRetained) retained)
527: .getConstantScaleEnable();
528: }
529:
530: /**
531: * Sets the scale for this OrientedShape3D. This scale is used when
532: * the constant scale enable flag is set to true.
533: *
534: * @param scale the scale value
535: *
536: * @exception CapabilityNotSetException if appropriate capability is
537: * not set and this object is part of live or compiled scene graph
538: *
539: * @since Java 3D 1.3
540: */
541: public void setScale(double scale) {
542: if (isLiveOrCompiled())
543: if (!this .getCapability(ALLOW_SCALE_WRITE))
544: throw new CapabilityNotSetException(J3dI18N
545: .getString("OrientedShape3D8"));
546:
547: if (isLive())
548: ((OrientedShape3DRetained) retained).setScale(scale);
549: else
550: ((OrientedShape3DRetained) retained).initScale(scale);
551: }
552:
553: /**
554: * Retrieves the scale value for this OrientedShape3D.
555: *
556: * @return the current scale value
557: *
558: * @exception CapabilityNotSetException if appropriate capability is
559: * not set and this object is part of live or compiled scene graph
560: *
561: * @since Java 3D 1.3
562: */
563: public double getScale() {
564: if (isLiveOrCompiled())
565: if (!this .getCapability(ALLOW_SCALE_READ))
566: throw new CapabilityNotSetException(J3dI18N
567: .getString("OrientedShape3D9"));
568:
569: return ((OrientedShape3DRetained) retained).getScale();
570: }
571:
572: /**
573: * Used to create a new instance of the node. This routine is called
574: * by <code>cloneTree</code> to duplicate the current node.
575: * <code>cloneNode</code> should be overridden by any user subclassed
576: * objects. All subclasses must have their <code>cloneNode</code>
577: * method consist of the following lines:
578: * <P><blockquote><pre>
579: * public Node cloneNode(boolean forceDuplicate) {
580: * UserSubClass usc = new UserSubClass();
581: * usc.duplicateNode(this, forceDuplicate);
582: * return usc;
583: * }
584: * </pre></blockquote>
585: * @param forceDuplicate when set to <code>true</code>, causes the
586: * <code>duplicateOnCloneTree</code> flag to be ignored. When
587: * <code>false</code>, the value of each node's
588: * <code>duplicateOnCloneTree</code> variable determines whether
589: * NodeComponent data is duplicated or copied.
590: *
591: * @see Node#cloneTree
592: * @see Node#duplicateNode
593: * @see NodeComponent#setDuplicateOnCloneTree
594: */
595: public Node cloneNode(boolean forceDuplicate) {
596: OrientedShape3D s = new OrientedShape3D();
597: s.duplicateNode(this , forceDuplicate);
598: return s;
599: }
600:
601: /**
602: * Copies all node information from <code>originalNode</code> into
603: * the current node. This method is called from the
604: * <code>cloneNode</code> method which is, in turn, called by the
605: * <code>cloneTree</code> method.
606: * <P>
607: * For any <code>NodeComponent</code> objects
608: * contained by the object being duplicated, each <code>NodeComponent</code>
609: * object's <code>duplicateOnCloneTree</code> value is used to determine
610: * whether the <code>NodeComponent</code> should be duplicated in the new node
611: * or if just a reference to the current node should be placed in the
612: * new node. This flag can be overridden by setting the
613: * <code>forceDuplicate</code> parameter in the <code>cloneTree</code>
614: * method to <code>true</code>.
615: * <br>
616: * NOTE: Applications should <i>not</i> call this method directly.
617: * It should only be called by the cloneNode method.
618: *
619: * @param originalNode the original node to duplicate.
620: * @param forceDuplicate when set to <code>true</code>, causes the
621: * <code>duplicateOnCloneTree</code> flag to be ignored. When
622: * <code>false</code>, the value of each node's
623: * <code>duplicateOnCloneTree</code> variable determines whether
624: * NodeComponent data is duplicated or copied.
625: * @exception ClassCastException if originalNode is not an instance of
626: * <code>Shape3D</code>
627: *
628: * @see Node#cloneTree
629: * @see Node#cloneNode
630: * @see NodeComponent#setDuplicateOnCloneTree
631: */
632: public void duplicateNode(Node originalNode, boolean forceDuplicate) {
633: checkDuplicateNode(originalNode, forceDuplicate);
634: }
635:
636: /**
637: * Copies all Shape3D information from
638: * <code>originalNode</code> into
639: * the current node. This method is called from the
640: * <code>cloneNode</code> method which is, in turn, called by the
641: * <code>cloneTree</code> method.<P>
642: *
643: * @param originalNode the original node to duplicate.
644: * @param forceDuplicate when set to <code>true</code>, causes the
645: * <code>duplicateOnCloneTree</code> flag to be ignored. When
646: * <code>false</code>, the value of each node's
647: * <code>duplicateOnCloneTree</code> variable determines whether
648: * NodeComponent data is duplicated or copied.
649: *
650: * @exception RestrictedAccessException if this object is part of a live
651: * or compiled scenegraph.
652: *
653: * @see Node#duplicateNode
654: * @see Node#cloneTree
655: * @see NodeComponent#setDuplicateOnCloneTree
656: */
657: void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
658:
659: super .duplicateAttributes(originalNode, forceDuplicate);
660: OrientedShape3DRetained attr = (OrientedShape3DRetained) originalNode.retained;
661: OrientedShape3DRetained rt = (OrientedShape3DRetained) retained;
662:
663: rt.setAlignmentMode(attr.getAlignmentMode());
664: Vector3f axis = new Vector3f();
665: attr.getAlignmentAxis(axis);
666: rt.setAlignmentAxis(axis);
667: Point3f point = new Point3f();
668: attr.getRotationPoint(point);
669: rt.setRotationPoint(point);
670: }
671: }
|