📄 modelclip.java
字号:
*/ public void addScope(Group scope) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip12")); if (isLive()) ((ModelClipRetained)this.retained).addScope(scope); else ((ModelClipRetained)this.retained).initAddScope(scope); } /** * Returns the number of nodes in this ModelClip node's list of scopes. * If this number is 0, then the list of scopes is empty and this * ModelClip node has universe scope: all nodes within the region of * influence are affected by this ModelClip node. * @return the number of nodes in this ModelClip node's list of scopes. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public int numScopes() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip11")); return ((ModelClipRetained)this.retained).numScopes(); } /** * Retrieves the index of the specified Group node in this * ModelClip node's list of scopes. * * @param scope the Group node to be looked up. * @return the index of the specified Group node; * returns -1 if the object is not in the list. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.3 */ public int indexOfScope(Group scope) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip8")); return ((ModelClipRetained)this.retained).indexOfScope(scope); } /** * Removes the specified Group node from this ModelClip * node's list of scopes. If the specified object is not in the * list, the list is not modified. If this operation causes the * list of scopes to become empty, then this ModelClip * will have universe scope: all nodes within the region of * influence will be affected by this ModelClip node. * * @param scope the Group node to be removed. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception RestrictedAccessException if the specified group node * is part of a compiled scene graph * * @since Java 3D 1.3 */ public void removeScope(Group scope) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip10")); if (isLive()) ((ModelClipRetained)this.retained).removeScope(scope); else ((ModelClipRetained)this.retained).initRemoveScope(scope); } /** * Removes all Group nodes from this ModelClip node's * list of scopes. The ModelClip node will then have * universe scope: all nodes within the region of influence will * be affected by this ModelClip node. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception RestrictedAccessException if any group node in this * node's list of scopes is part of a compiled scene graph * * @since Java 3D 1.3 */ public void removeAllScopes() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_SCOPE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip10")); if (isLive()) ((ModelClipRetained)this.retained).removeAllScopes(); else ((ModelClipRetained)this.retained).initRemoveAllScopes(); } /** * Sets the clipping planes of this ModelClip node to the * specified planes. * The individual planes are copied into this node. * @param planes an array of 6 model clipping planes */ public void setPlanes(Vector4d[] planes) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_PLANE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip2")); if (isLive()) ((ModelClipRetained)this.retained).setPlanes(planes); else ((ModelClipRetained)this.retained).initPlanes(planes); } /** * Retrieves the clipping planes from this ModelClip node. * The individual planes are copied into the specified planes, which * must be allocated by the caller. The array must be large * enough to hold all of the vectors. * @param planes an array of 6 vectors that will receive the model * clipping planes from this node */ public void getPlanes(Vector4d[] planes) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_PLANE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip3")); ((ModelClipRetained)this.retained).getPlanes(planes); } /** * Sets the specified clipping plane of this ModelClip node. * The specified plane is copied into this node. * @param planeNum specifies which model clipping plane (0-5) is replaced * @param plane new model clipping plane */ public void setPlane(int planeNum, Vector4d plane) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_PLANE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip2")); if (isLive()) ((ModelClipRetained)this.retained).setPlane(planeNum, plane); else ((ModelClipRetained)this.retained).initPlane(planeNum, plane); } /** * Retrieves the specified clipping plane from this ModelClip node. * The plane is copied into the specified plane, which * must be allocated by the caller. * @param planeNum specifies which model clipping plane (0-5) is retrieved * @param plane a vector that will receive the specified model * clipping plane from this node */ public void getPlane(int planeNum, Vector4d plane) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_PLANE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip3")); ((ModelClipRetained)this.retained).getPlane(planeNum, plane); } /** * Sets the per-plane enable flags of this ModelClip node to the * specified values. * @param enables an array of 6 enable flags */ public void setEnables(boolean[] enables) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_ENABLE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip4")); if (isLive()) ((ModelClipRetained)this.retained).setEnables(enables); else ((ModelClipRetained)this.retained).initEnables(enables); } /** * Retrieves the per-plane enable flags from this ModelClip node. * The enable flags are copied into the specified array. * The array must be large enough to hold all of the enables. * @param enables an array of 6 booleans that will receive the * enable flags from this node */ public void getEnables(boolean[] enables) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_ENABLE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip5")); ((ModelClipRetained)this.retained).getEnables(enables); } /** * Sets the specified enable flag of this ModelClip node. * @param planeNum specifies which enable flag (0-5) is set * @param enable new enable flag */ public void setEnable(int planeNum, boolean enable) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_ENABLE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip4")); if (isLive()) ((ModelClipRetained)this.retained).setEnable(planeNum, enable); else ((ModelClipRetained)this.retained).initEnable(planeNum, enable); } /** * Retrieves the specified enable flag from this ModelClip node. * @param planeNum specifies which enable flag (0-5) is retrieved * @return the specified enable flag */ public boolean getEnable(int planeNum) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_ENABLE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("ModelClip5")); return ((ModelClipRetained)this.retained).getEnable(planeNum); } /** * Creates the retained mode ModelClipRetained object that * this ModelClip node will point to. */ void createRetained() { this.retained = new ModelClipRetained(); this.retained.setSource(this); } /** * Used to create a new instance of the node. This routine is called * by <code>cloneTree</code> to duplicate the current node. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @see Node#cloneTree * @see Node#cloneNode * @see Node#duplicateNode * @see NodeComponent#setDuplicateOnCloneTree */ public Node cloneNode(boolean forceDuplicate) { ModelClip c = new ModelClip(); c.duplicateNode(this, forceDuplicate); return c; } /** * Callback used to allow a node to check if any scene graph objects * referenced * by that node have been duplicated via a call to <code>cloneTree</code>. * This method is called by <code>cloneTree</code> after all nodes in * the sub-graph have been duplicated. The cloned Leaf node's method * will be called and the Leaf node can then look up any object references * by using the <code>getNewObjectReference</code> method found in the * <code>NodeReferenceTable</code> object. If a match is found, a * reference to the corresponding object in the newly cloned sub-graph * is returned. If no corresponding reference is found, either a * DanglingReferenceException is thrown or a reference to the original * object is returned depending on the value of the * <code>allowDanglingReferences</code> parameter passed in the * <code>cloneTree</code> call. * <p> * NOTE: Applications should <i>not</i> call this method directly. * It should only be called by the cloneTree method. * * @param referenceTable a NodeReferenceTableObject that contains the * <code>getNewObjectReference</code> method needed to search for * new object instances. * @see NodeReferenceTable * @see Node#cloneTree * @see DanglingReferenceException */ public void updateNodeReferences(NodeReferenceTable referenceTable) { ModelClipRetained rt = (ModelClipRetained) retained; BoundingLeaf bl = rt.getInfluencingBoundingLeaf(); // check for influencingBoundingLeaf if (bl != null) { Object o = referenceTable.getNewObjectReference( bl); rt.initInfluencingBoundingLeaf((BoundingLeaf) o); } int num = rt.numScopes(); for (int i=0; i < num; i++) { rt.initScope((Group) referenceTable. getNewObjectReference(rt.getScope(i)), i); } } /** * Copies all Clip information from * <code>originalNode</code> into * the current node. This method is called from the * <code>cloneNode</code> method which is, in turn, called by the * <code>cloneTree</code> method.<P> * * @param originalNode the original node to duplicate. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @exception RestrictedAccessException if this object is part of a live * or compiled scenegraph. * * @see Node#duplicateNode * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(Node originalNode, boolean forceDuplicate) { super.duplicateAttributes(originalNode, forceDuplicate); ModelClipRetained attr = (ModelClipRetained) originalNode.retained; ModelClipRetained rt = (ModelClipRetained) retained; Vector4d plane = new Vector4d(); for (int i=5; i >=0; i--) { attr.getPlane(i, plane); rt.initPlane(i, plane); rt.initEnable(i, attr.getEnable(i)); } rt.initInfluencingBounds(attr.getInfluencingBounds()); Enumeration elm = attr.getAllScopes(); while (elm.hasMoreElements()) { // this reference will set correctly in updateNodeReferences() callback rt.initAddScope((Group) elm.nextElement()); } // correct value will set in updateNodeReferences rt.initInfluencingBoundingLeaf(attr.getInfluencingBoundingLeaf()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -