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

📄 modelclipretained.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    void initScope(Group scope, int index) {        scopes.setElementAt((GroupRetained)(scope.retained), index);    }    /**     * Replaces the specified scope with the scope provided.     * @param scope the new scope     * @param index which scope to replace     */    void setScope(Group scope, int index) {        ArrayList addScopeList = new ArrayList();        ArrayList removeScopeList = new ArrayList();        GroupRetained group;        Object[] scopeInfo = new Object[3];        group = (GroupRetained) scopes.get(index);        tempKey.reset();	group.removeAllNodesForScopedModelClip(mirrorModelClip, removeScopeList, tempKey);        group = (GroupRetained)scope.retained;        initScope(scope, index);        tempKey.reset();	// If its a group, then add the scope to the group, if	// its a shape, then keep a list to be added during	// updateMirrorObject	group.addAllNodesForScopedModelClip(mirrorModelClip,addScopeList, tempKey);        scopeInfo[0] = addScopeList;        scopeInfo[1] = removeScopeList;        scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE:Boolean.FALSE);        sendMessage(SCOPE_CHANGED, scopeInfo, null);    }    /**     * Inserts the specified scope at specified index     * @param scope the new scope     * @param index position to insert new scope at     */    void initInsertScope(Node scope, int index) {        GroupRetained group = (GroupRetained)scope.retained;	group.setMclipScope();        scopes.insertElementAt((GroupRetained)(scope.retained), index);    }    /**     * Inserts the specified scope at specified index and sends     * a message     * @param scope the new scope     * @param index position to insert new scope at     */    void insertScope(Node scope, int index) {        Object[] scopeInfo = new Object[3];        ArrayList addScopeList = new ArrayList();        initInsertScope(scope, index);        GroupRetained group = (GroupRetained)scope.retained;        tempKey.reset();	group.addAllNodesForScopedModelClip(mirrorModelClip,addScopeList, tempKey);        scopeInfo[0] = addScopeList;        scopeInfo[1] = null;        scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);        sendMessage(SCOPE_CHANGED, scopeInfo, null);    }    void initRemoveScope(int index) {        GroupRetained group  = (GroupRetained)scopes.elementAt(index);	group.removeMclipScope();        scopes.removeElementAt(index);    }    void removeScope(int index) {        Object[] scopeInfo = new Object[3];        ArrayList removeScopeList = new ArrayList();        GroupRetained group  = (GroupRetained)scopes.elementAt(index);	initRemoveScope(index);        tempKey.reset();	group.removeAllNodesForScopedModelClip(mirrorModelClip, removeScopeList, tempKey);        scopeInfo[0] = null;        scopeInfo[1] = removeScopeList;        scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);        sendMessage(SCOPE_CHANGED, scopeInfo, null);    }    /**     * Removes the specified Group node from this ModelClip's list of     * scopes if the specified node is not found in the list of scoped     * nodes, method returns quietly.     *     * @param Group node to be removed     */    void removeScope(Group node) {      int ind = indexOfScope(node);      if(ind >= 0)	removeScope(ind);    }   void initRemoveScope(Group node) {      int ind = indexOfScope(node);      if(ind >= 0)	initRemoveScope(ind);    }    /**     * Removes all the Group nodes from the ModelClip's scope     * list. The ModelClip reverts to universal scope.     */    void removeAllScopes() {      Object[] scopeInfo = new Object[3];      ArrayList removeScopeList = new ArrayList();      int n = scopes.size();      for(int index = n-1; index >= 0; index--) {	GroupRetained group  = (GroupRetained)scopes.elementAt(index);	initRemoveScope(index);	tempKey.reset();	group.removeAllNodesForScopedModelClip(mirrorModelClip, removeScopeList, tempKey);      }      scopeInfo[0] = null;      scopeInfo[1] = removeScopeList;      scopeInfo[2] = (Boolean.FALSE);      sendMessage(SCOPE_CHANGED, scopeInfo, null);    }    void initRemoveAllScopes() {      int n = scopes.size();      for(int i = n-1; i >= 0; i--) {	initRemoveScope(i);      }    }    /**     * Returns the scope specified by the index.     * @param index which scope to return     * @return the scoperen at location index     */    Group getScope(int index) {        return (Group)(((GroupRetained)(scopes.elementAt(index))).source);    }    /**     * Returns an enumeration object of the scoperen.     * @return an enumeration object of the scoperen     */    Enumeration getAllScopes() {        Enumeration elm = scopes.elements();        Vector v = new Vector(scopes.size());        while (elm.hasMoreElements()) {            v.add( ((GroupRetained) elm.nextElement()).source);        }        return v.elements();    }    /**     * Appends the specified scope to this node's list of scopes before     * the fog is alive     * @param scope the scope to add to this node's list of scopes     */    void initAddScope(Group scope) {        GroupRetained group = (GroupRetained)scope.retained;        scopes.addElement((GroupRetained)(scope.retained));	group.setMclipScope();    }    /**     * Appends the specified scope to this node's list of scopes.     * @param scope the scope to add to this node's list of scopes     */    void addScope(Group scope) {        Object[] scopeInfo = new Object[3];        ArrayList addScopeList = new ArrayList();        GroupRetained group = (GroupRetained)scope.retained;        initAddScope(scope);        tempKey.reset();	group.addAllNodesForScopedModelClip(mirrorModelClip,addScopeList, tempKey);        scopeInfo[0] = addScopeList;        scopeInfo[1] = null;        scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);        sendMessage(SCOPE_CHANGED, scopeInfo, null);    }    /**     * Returns a count of this nodes' scopes.     * @return the number of scopes descendant from this node     */    int numScopes() {        return scopes.size();    }    /**     * Returns the index of the specified Group node within the ModelClip's list of scoped      * Group nodes     * @param Group node whose index is desired     * @return index of this node     */    int indexOfScope(Group node) {      if(node != null)	return scopes.indexOf((GroupRetained)node.retained);      else	return scopes.indexOf(null);    }    /**     * This sets the immedate mode context flag     */    void setInImmCtx(boolean inCtx) {        inImmCtx = inCtx;    }    /**     * This gets the immedate mode context flag     */    boolean getInImmCtx() {        return (inImmCtx);    }    /**      * This method and its native counterpart update the native context     * model clip planes.     */    void update(Canvas3D cv, int enableMask) {	cv.setModelViewMatrix(cv.ctx, 			      cv.vworldToEc.mat,			      getLastLocalToVworld());	update(cv.ctx, enableMask, getLastLocalToVworld());    }    void update(Context ctx, int enableMask, Transform3D trans) {	if (!VirtualUniverse.mc.isD3D()) {	    for (int i = 0; i < 6; i ++) {	         Pipeline.getPipeline().updateModelClip(ctx, i, ((enableMask & (1 << i)) != 0), 			xformPlanes[i].x, xformPlanes[i].y, 			xformPlanes[i].z, xformPlanes[i].w);	    }	    return;	}	// For D3D we need to transform the plane equations from local to	// world coordinate.	Transform3D invtrans = new Transform3D(trans);	// can't call getNormalTransform() since it will cache	// normalTransform and may return previous result next time.	invtrans.invert();	invtrans.transpose();	for (int i=0; i < 6; i++) {	    if ((enableMask & (1 << i)) != 0) {				Vector4d vec = new Vector4d(xformPlanes[i].x, xformPlanes[i].y, 					    xformPlanes[i].z, xformPlanes[i].w);		vec.normalize();		invtrans.transform(vec);		Pipeline.getPipeline().updateModelClip(ctx, i, true, vec.x, vec.y, vec.z, vec.w); 	    } else {		Pipeline.getPipeline().updateModelClip(ctx, i, false, 0, 0, 0, 0);	    }	}    }    void initMirrorObject(Object[] args) {	Shape3DRetained shape;	Object[] scopeInfo = (Object[]) args[2];	Boolean scoped = (Boolean)scopeInfo[0];	ArrayList shapeList = (ArrayList)scopeInfo[1];	BoundingLeafRetained bl=(BoundingLeafRetained)((Object[])args[4])[0];	Bounds bnds = (Bounds)((Object[])args[4])[1];	for (int i = 0; i < shapeList.size(); i++) {	    shape = ((GeometryAtom)shapeList.get(i)).source;	    shape.addModelClip(mirrorModelClip);	}	mirrorModelClip.isScoped = scoped.booleanValue();	if (bl != null) {	    mirrorModelClip.boundingLeaf = bl.mirrorBoundingLeaf;	    mirrorModelClip.region = boundingLeaf.transformedRegion;	} else {	    mirrorModelClip.boundingLeaf = null;	    mirrorModelClip.region = null;	}		if (bnds != null) {	    mirrorModelClip.regionOfInfluence = bnds;	    if (mirrorModelClip.region == null) {		mirrorModelClip.region = (Bounds)regionOfInfluence.clone();		mirrorModelClip.region.transform(regionOfInfluence, getLastLocalToVworld());	    }	}	else {	    mirrorModelClip.regionOfInfluence = null;	}	boolean[] ens = (boolean[])((Object[])args[4])[2];	for (int i = 0; i < ens.length; i++) {	    mirrorModelClip.enables[i] = ens[i];	}        mirrorModelClip.enableFlag = mirrorModelClip.enables[0] |					mirrorModelClip.enables[1] |					mirrorModelClip.enables[2] |					mirrorModelClip.enables[3] |					mirrorModelClip.enables[4] |					mirrorModelClip.enables[5] ;    }    void updateMirrorObject(Object[] objs) {	int component = ((Integer)objs[1]).intValue();	if ((component & PLANES_CHANGED) != 0) {	    Vector4d[] pl = ((Vector4d[]) objs[2]);	    for (int i = 0; i < 6; i++) {	         mirrorModelClip.xformPlanes[i].set(pl[i]);	    }	}	else if ((component & PLANE_CHANGED) != 0) {	    int planeNum = ((Integer)objs[2]).intValue();	    	    mirrorModelClip.xformPlanes[planeNum].set((Vector4d)objs[3]);	}	else if ((component & INIT_MIRROR) != 0) {	    Vector4d[] pl = (Vector4d[]) objs[3];	    for (int i = 0; i < 6; i++) {	         mirrorModelClip.xformPlanes[i].set(pl[i]);	    }	}    }    // The update Object function.    void updateImmediateMirrorObject(Object[] objs) {	int component = ((Integer)objs[1]).intValue();	Transform3D trans;	if  ((component & BOUNDINGLEAF_CHANGED) != 0) {	    mirrorModelClip.boundingLeaf = (BoundingLeafRetained)objs[2];	    if (objs[2] != null) {		mirrorModelClip.region = 		    (Bounds)mirrorModelClip.boundingLeaf.transformedRegion;	    }

⌨️ 快捷键说明

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