001: /*
002: * $RCSfile: DepthComponentNative.java,v $
003: *
004: * Copyright 1997-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.5 $
028: * $Date: 2008/02/28 20:17:21 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * A 2D array of depth (Z) values stored in the most efficient format for a
036: * particular device. Values are not accessible by the user and may only be
037: * used to read the Z values and subsequently write them back.
038: */
039:
040: public class DepthComponentNative extends DepthComponent {
041: /**
042: * Package scope defualt constructor for use by cloneNodeComponent
043: */
044: DepthComponentNative() {
045: }
046:
047: /**
048: * Constructs a new native depth (z-buffer) component object with the
049: * specified width and height.
050: * @param width the width of the array of depth values
051: * @param height the height of the array of depth values
052: */
053: public DepthComponentNative(int width, int height) {
054: ((DepthComponentNativeRetained) this .retained).initialize(
055: width, height);
056: }
057:
058: /**
059: * Copies the depth data from this object to the specified array.
060: * @param depthData array of ints that will receive a copy of
061: * the depth data
062: */
063: void getDepthData(int[] depthData) {
064: ((DepthComponentNativeRetained) this .retained)
065: .getDepthData(depthData);
066: }
067:
068: /**
069: * Creates a retained mode DepthComponentIntRetained object that this
070: * DepthComponentInt component object will point to.
071: */
072: void createRetained() {
073: this .retained = new DepthComponentNativeRetained();
074: this .retained.setSource(this );
075: }
076:
077: /**
078: * Creates a new DepthComponentNative object. Called from a Leaf node's
079: * <code>duplicateNode</code> method.
080: *
081: * @return a duplicate of the DepthComponentNative object.
082: *
083: * @see Node#duplicateNode
084: * @see Node#cloneTree
085: * @see NodeComponent#setDuplicateOnCloneTree
086: */
087: public NodeComponent cloneNodeComponent() {
088: DepthComponentNativeRetained rt = (DepthComponentNativeRetained) retained;
089: DepthComponentNative d = new DepthComponentNative(rt.width,
090: rt.height);
091: d.duplicateNodeComponent(this );
092: return d;
093: }
094:
095: /**
096: * Copies all node information from <code>originalNodeComponent</code> into
097: * the current node. This method is called from the
098: * <code>duplicateNode</code> method. This routine does
099: * the actual duplication of all "local data" (any data defined in
100: * this object).
101: *
102: * @param originalNodeComponent the original node to duplicate.
103: * @param forceDuplicate when set to <code>true</code>, causes the
104: * <code>duplicateOnCloneTree</code> flag to be ignored. When
105: * <code>false</code>, the value of each node's
106: * <code>duplicateOnCloneTree</code> variable determines whether
107: * NodeComponent data is duplicated or copied.
108: *
109: *
110: * @see Node#cloneTree
111: * @see NodeComponent#setDuplicateOnCloneTree
112: */
113: void duplicateAttributes(NodeComponent originalNodeComponent,
114: boolean forceDuplicate) {
115: super
116: .duplicateAttributes(originalNodeComponent,
117: forceDuplicate);
118:
119: int originalData[] = ((DepthComponentNativeRetained) originalNodeComponent.retained).depthData;
120:
121: int currentData[] = ((DepthComponentNativeRetained) retained).depthData;
122:
123: if (originalData != null) {
124: for (int i = 0; i < originalData.length; i++)
125: currentData[i] = originalData[i];
126: }
127: }
128: }
|