⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelclipretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $RCSfile: ModelClipRetained.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.5 $ * $Date: 2007/02/09 17:18:10 $ * $State: Exp $ */package javax.media.j3d;import java.util.Enumeration;import java.util.Vector;import java.util.ArrayList;import javax.vecmath.*;/** * The ModelClip retained object. */class ModelClipRetained extends LeafRetained {    // Statics used when something in the fog changes    static final int PLANE_CHANGED           = 0x0001;    static final int PLANES_CHANGED          = 0x0002;    static final int ENABLE_CHANGED          = 0x0004;    static final int ENABLES_CHANGED         = 0x0008;    static final int BOUNDS_CHANGED          = 0x0010;    static final int BOUNDINGLEAF_CHANGED    = 0x0020;    static final int SCOPE_CHANGED	     = 0x0040;    static final int INIT_MIRROR	     = 0x0080;    static final int CLEAR_MIRROR	     = 0x0100;    static final int LAST_DEFINED_BIT        = 0x0100;    /**     * The clip planes and the enable bits     */    Vector4d[] planes = new Vector4d[6];    boolean[]  enables = new boolean[6];    Vector4d[] xformPlanes = new Vector4d[6];    // enableFlag is true if one of the enables is true    // only used by mirror object    boolean    enableFlag = false;    /**     * The Boundary object defining the model clip's region of influencing     */    Bounds regionOfInfluence = null;    /**     * The bounding leaf reference     */    BoundingLeafRetained boundingLeaf = null;    /**     * The transformed value of the influencingRegion.     */    Bounds region = null;    /**     * Vector of GroupRetained  nodes that scopes this model clip.     */    Vector scopes = new Vector();    //Boolean to indicate if this object is scoped (only used for mirror objects    boolean isScoped = false;    // The object that contains the dynamic HashKey - a string type object    // Used in scoping    HashKey tempKey = new HashKey(250);    // This is true when this model clip is referenced in an immediate mode context    boolean inImmCtx = false;    // The mirror copy of this modelClip    ModelClipRetained mirrorModelClip = null;     // A reference to the scene graph model clip    ModelClipRetained sgModelClip = null;    // Target threads to be notified when model clip changes    final static int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |                                     J3dThread.UPDATE_RENDER;    /**     * The EnvironmentSets which reference this model clip.     * Note that multiple RenderBin update thread may access     * this shared environmentSets simultaneously.     * So we use UnorderList which sync. all the operations.     */    UnorderList environmentSets = new UnorderList(1, EnvironmentSet.class);    // Is true, if the mirror clip is viewScoped    boolean isViewScoped = false;    /**     * Constructs and initializes model clip planes     */      ModelClipRetained() {	// planes contains the negate default values	planes[0] = new Vector4d( 1.0, 0.0,  0.0,-1.0);	planes[1] = new Vector4d(-1.0, 0.0,  0.0,-1.0);	planes[2] = new Vector4d( 0.0, 1.0,  0.0,-1.0);	planes[3] = new Vector4d( 0.0,-1.0,  0.0,-1.0);	planes[4] = new Vector4d( 0.0, 0.0,  1.0,-1.0);	planes[5] = new Vector4d( 0.0, 0.0, -1.0,-1.0);	for (int i = 0; i < 6; i++)	    xformPlanes[i] = new Vector4d(planes[i]);        enables[0] = enables[1] = enables[2] = enables[3] =	    enables[4] = enables[5] = true;    }    /**     * Initializes planes before the object is live     */    void initPlanes(Vector4d[] planes) {        if (staticTransform != null) {	    Transform3D xform = staticTransform.getNormalTransform();	    for (int i = 0; i < 6; i++) {		 this.planes[i].set(planes[i]);	         xform.transform(this.planes[i], this.xformPlanes[i]);	    }	} else {	    for (int i = 0; i < 6; i++) {		 this.planes[i].set(planes[i]);		 this.xformPlanes[i].set(this.planes[i]);	    }	}    }    /**     * Sets the clip planes and send a message     */    void setPlanes(Vector4d[] planes) {        Vector4d[] pl = new Vector4d[6];	initPlanes(planes);	for (int i = 0; i < 6; i++) {             pl[i] = new Vector4d(this.xformPlanes[i]);	}	sendMessage(PLANES_CHANGED, pl, null);    }    /**     * Initializes planes before the object is live     */    void initPlane(int planeNum, Vector4d plane) {        if (planeNum < 0 || planeNum > 5)	    throw new IllegalArgumentException(J3dI18N.getString("ModelClip6"));	if (staticTransform != null) {	    Transform3D xform = staticTransform.getNormalTransform();            this.planes[planeNum].set(plane);	    xform.transform(this.planes[planeNum], this.xformPlanes[planeNum]);	} else {            this.planes[planeNum].set(plane);	    this.xformPlanes[planeNum].set(plane);	}    }    /**     * Sets the clip planes and send a message     */    void setPlane(int planeNum, Vector4d plane) {	initPlane(planeNum, plane);	sendMessage(PLANE_CHANGED, 		    new Integer(planeNum), 		    new Vector4d(this.xformPlanes[planeNum]));    }    /**     * Gets planes     */    void getPlanes(Vector4d[] planes){	for (int i = 0; i < 6; i++) {	     planes[i].set(this.planes[i]);  	}    }    /**     * Gets the specified clipping plane     */    void getPlane(int planeNum, Vector4d plane) {        if (planeNum < 0 || planeNum > 5)	    throw new IllegalArgumentException(J3dI18N.getString("ModelClip6"));	plane.set(this.planes[planeNum]);    }    /**     * Initializes planes before the object is live     */    void initEnables(boolean[] enables) {        this.enables[0] = enables[0];        this.enables[1] = enables[1];        this.enables[2] = enables[2];        this.enables[3] = enables[3];        this.enables[4] = enables[4];        this.enables[5] = enables[5];    }    /**     * Sets the clip planes and send a message     */    void setEnables(boolean[] enables) {        Boolean[] en = new Boolean[6];	initEnables(enables);                en[0] = (enables[0] ? Boolean.TRUE: Boolean.FALSE);        en[1] = (enables[1] ? Boolean.TRUE: Boolean.FALSE);        en[2] = (enables[2] ? Boolean.TRUE: Boolean.FALSE);        en[3] = (enables[3] ? Boolean.TRUE: Boolean.FALSE);        en[4] = (enables[4] ? Boolean.TRUE: Boolean.FALSE);        en[5] = (enables[5] ? Boolean.TRUE: Boolean.FALSE);	sendMessage(ENABLES_CHANGED, en, null);    }    /**     * Initializes planes before the object is live     */    void initEnable(int planeNum, boolean enable) {        if (planeNum < 0 || planeNum > 5)	    throw new IllegalArgumentException(J3dI18N.getString("ModelClip6"));        this.enables[planeNum] = enable;    }    /**     * Sets the clip planes and send a message     */    void setEnable(int planeNum, boolean enable) {	initEnable(planeNum, enable);	sendMessage(ENABLE_CHANGED, 		    new Integer(planeNum),		     (enable ? Boolean.TRUE: Boolean.FALSE));    }    /**     * Gets enables     */    void getEnables(boolean[] enables) {	enables[0] = this.enables[0];	enables[1] = this.enables[1];	enables[2] = this.enables[2];	enables[3] = this.enables[3];	enables[4] = this.enables[4];	enables[5] = this.enables[5];    }    /**     * Gets the specified enable     */    boolean getEnable(int planeNum) {        if (planeNum < 0 || planeNum > 5)	    throw new IllegalArgumentException(J3dI18N.getString("ModelClip6"));	return (this.enables[planeNum]);    }    /**     * Set the Model Clip's region of influencing     */    void initInfluencingBounds(Bounds region) {        if (region != null) {            this.regionOfInfluence = (Bounds) region.clone();            if (staticTransform != null) {                regionOfInfluence.transform(staticTransform.transform);            }        } else {            this.regionOfInfluence = null;        }    }    /**     * Set the Model Clip's region of influencing and send message     */     void setInfluencingBounds(Bounds region) {        initInfluencingBounds(region);	sendMessage(BOUNDS_CHANGED,		    (region != null ? (Bounds) region.clone(): null),		    null);    }    /**      * Get the Model Clip's region of influencing.     */     Bounds getInfluencingBounds() {        Bounds b = null;        if (regionOfInfluence != null) {            b = (Bounds) regionOfInfluence.clone();            if (staticTransform != null) {                Transform3D invTransform = staticTransform.getInvTransform();                b.transform(invTransform);            }        }        return b;    }    /**     * Set the Model Clip's region of influencing to the specified Leaf node.     */     void initInfluencingBoundingLeaf(BoundingLeaf region) {        if (region != null) {            boundingLeaf = (BoundingLeafRetained)region.retained;        } else {            boundingLeaf = null;        }    }    /**     * Set the Model Clip's region of influencing to the specified Leaf node.     */     void setInfluencingBoundingLeaf(BoundingLeaf region) {        if (boundingLeaf != null)            boundingLeaf.mirrorBoundingLeaf.removeUser(mirrorModelClip);        if (region != null) {            boundingLeaf = (BoundingLeafRetained)region.retained;            boundingLeaf.mirrorBoundingLeaf.addUser(mirrorModelClip);        } else {            boundingLeaf = null;        }	sendMessage(BOUNDINGLEAF_CHANGED, 		    (boundingLeaf != null ?		     boundingLeaf.mirrorBoundingLeaf : null), 		    null);    }    /**      * Get the Model Clip's region of influencing.     */     BoundingLeaf getInfluencingBoundingLeaf() {        return (boundingLeaf != null ?		(BoundingLeaf)boundingLeaf.source : null);    }    /**     * Replaces the specified scope with the scope provided.     * @param scope the new scope     * @param index which scope to replace     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -