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

📄 graphicscontext3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            (Thread.currentThread() == canvas3d.screen.renderer)) {            doSetFog(fog);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.SET_FOG, fog, null);        } else {            sendRenderMessage(true, GraphicsContext3D.SET_FOG, fog, null);        }    }    void doSetFog(Fog fog) {	if (this.fog != null) {	   ((FogRetained)this.fog.retained).setInImmCtx(false);	}	this.fog = fog;	if (fog != null) {	    ((FogRetained)fog.retained).setInImmCtx(true);            // Issue 144: updateFogState now called unconditionally            updateFogState((FogRetained)fog.retained);	}    }    /**     * Retrieves the current Fog leaf node object.     * @return the current Fog object     */    public Fog getFog() {	return this.uFog;    }    /**     * Sets the current ModelClip leaf node to the specified object.     * The graphics context stores a reference to the specified     * ModelClip node. This means that the application may modify the     * model clipping attributes using the appropriate methods on the     * ModelClip node object. The ModelClip node must not be part of a     * live scene graph, nor may it subsequently be made part of a     * live scene graph-an IllegalSharingException is thrown in such     * cases. If the ModelClip object is null, model clipping is     * disabled.  Both the region of influence and the hierarchical     * scope of the ModelClip node are ignored for immediate-mode     * rendering.     *     * @param modelClip the new ModelClip node     *     * @exception IllegalSharingException if the ModelClip node     * is part of or is subsequently made part of a live scene graph.     *     * @since Java 3D 1.2     */    public void setModelClip(ModelClip modelClip) {        if ((modelClip != null) && modelClip.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D25"));        }        uModelClip = modelClip;        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {            doSetModelClip(modelClip);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.SET_MODELCLIP, 					modelClip, null);        } else {            sendRenderMessage(true, GraphicsContext3D.SET_MODELCLIP, 					modelClip, null);        }    }    void doSetModelClip(ModelClip modelClip) {	ModelClipRetained mc = null;	this.modelClip = modelClip;	if (this.modelClip != null) {	    mc = (ModelClipRetained)this.modelClip.retained;	    mc.setInImmCtx(true);	    if (modelClipTransform == null)		modelClipTransform = new Transform3D();	    // save the current model Transform	    modelClipTransform.set(compTransform);	}     }    /**     * Retrieves the current ModelClip leaf node object.     * @return the current ModelClip object     *     * @since Java 3D 1.2     */    public ModelClip getModelClip() {	return this.uModelClip;    }    /**     * Replaces the specified light with the light provided.     * The graphics context stores a reference to each light      * object in the list of lights. This means that the      * application may modify the light attributes for     * any of the lights using the appropriate methods on that      * Light node object. None of the Light nodes in the list      * of lights may be part of a live scene graph, nor may      * they subsequently be made part of a live scene graph -     * an IllegalSharingException is thrown in such cases.      * @param light the new light     * @param index which light to replace     * @exception IllegalSharingException if the Light node     * is part of or is subsequently made part of a live scene graph.     * @exception NullPointerException if the Light object is null.     */    public void setLight(Light light, int index) {        if (light == null) {           throw new NullPointerException(J3dI18N.getString("GraphicsContext3D13"));        }        if (light.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D14"));        }        uLights.setElementAt(light, index);        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {            doSetLight(light, index);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.SET_LIGHT, light, 			new Integer(index));        } else {            sendRenderMessage(true, GraphicsContext3D.SET_LIGHT, light,			new Integer(index));        }    }    void doSetLight(Light light, int index) {	Light oldlight;	oldlight = (Light)this.lights.elementAt(index);	if (oldlight != null) {	   ((LightRetained)oldlight.retained).setInImmCtx(false);	}	((LightRetained)light.retained).setInImmCtx(true);	updateLightState((LightRetained)light.retained);	this.lights.setElementAt(light, index);	this.lightsChanged = true;    }    /**     * Inserts the specified light at the specified index location.     * @param light the new light     * @param index at which location to insert     * @exception IllegalSharingException if the Light node     * is part of or is subsequently made part of a live scene graph.     * @exception NullPointerException if the Light object is null.     */    public void insertLight(Light light, int index) {        if (light == null) {           throw new NullPointerException(J3dI18N.getString("GraphicsContext3D13"));        }               if (light.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D14"));        }        uLights.insertElementAt(light, index);        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {            doInsertLight(light, index);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.INSERT_LIGHT, light,			new Integer(index));        } else {            sendRenderMessage(true, GraphicsContext3D.INSERT_LIGHT, light,			new Integer(index));        }    }    void doInsertLight(Light light, int index) {	((LightRetained)light.retained).setInImmCtx(true);	updateLightState((LightRetained)light.retained);	this.lights.insertElementAt(light, index);	this.lightsChanged = true;    }    /**     * Removes the light at the specified index location.     * @param index which light to remove     */    public void removeLight(int index) {        uLights.removeElementAt(index);        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {            doRemoveLight(index);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.REMOVE_LIGHT,			new Integer(index), null);        } else {            sendRenderMessage(true, GraphicsContext3D.REMOVE_LIGHT,			new Integer(index), null);        }    }    void doRemoveLight(int index) {	Light light = (Light) this.lights.elementAt(index);	((LightRetained)light.retained).setInImmCtx(false);	this.lights.removeElementAt(index);	this.lightsChanged = true;    }    /**     * Retrieves the index selected light.     * @param index which light to return     * @return the light at location index     */    public Light getLight(int index) {	return (Light) uLights.elementAt(index);    }    /**     * Retrieves the enumeration object of all the lights.     * @return the enumeration object of all the lights     */      public Enumeration getAllLights() {        return uLights.elements();    }       /**     * Appends the specified light to this graphics context's list of lights.     * Adding a null Light object to the list will result      * in a NullPointerException. Both the region of influence      * and the hierarchical scope of all lights in the list      * are ignored for immediate-mode rendering.     * @param light the light to add     * @exception IllegalSharingException if the Light node     * is part of or is subsequently made part of a live scene graph.     * @exception NullPointerException if the Light object is null.     */    public void addLight(Light light) {        if (light == null) {           throw new NullPointerException(J3dI18N.getString("GraphicsContext3D13"));        }         if (light.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D14"));        }        uLights.addElement(light);        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {            doAddLight(light);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.ADD_LIGHT, light, null);        } else {            sendRenderMessage(true, GraphicsContext3D.ADD_LIGHT, light, null);        }    }    void doAddLight(Light light) {	((LightRetained)light.retained).setInImmCtx(true);	updateLightState((LightRetained)light.retained);	this.lights.addElement(light);	this.lightsChanged = true;    }    /**     * Retrieves the current number of lights in this graphics context.     * @return the current number of lights     */    public int numLights() {	return this.uLights.size();    }    private Transform3D getNormalTransform() {	if (compTransform.isRigid()) {	    return compTransform;	}	if (normalTransform == null) {	    normalTransform = new Transform3D();	} 	if (normalTransformNeedToUpdate) {	    normalTransform.invert(compTransform);	    normalTransform.transpose();	    normalTransformNeedToUpdate = false;	}	return normalTransform;    }    void updateFogState(FogRetained fogRet) {        // Issue 144: update localToVWorldScale for all types of Fog        fogRet.setLocalToVworldScale(modelTransform.getDistanceScale());    }    void updateLightState(LightRetained light) {	if (light instanceof DirectionalLightRetained) {	   DirectionalLightRetained dl = (DirectionalLightRetained) light;	   Transform3D xform = getNormalTransform();	   xform.transform(dl.direction, dl.xformDirection);           dl.xformDirection.normalize();   	} else if (light instanceof SpotLightRetained) {	   SpotLightRetained sl = (SpotLightRetained) light;	   Transform3D xform = getNormalTransform();	   xform.transform(sl.direction, sl.xformDirection);           sl.xformDirection.normalize();           this.modelTransform.transform(sl.position, sl.xformPosition);   	} else if (light instanceof PointLightRetained) {	   PointLightRetained pl = (PointLightRetained) light;           this.modelTransform.transform(pl.position,pl.xformPosition);	   pl.localToVworldScale = modelTransform.getDistanceScale();	}    }    /**     * Sets the HiRes coordinate of this context to the location     * specified by the parameters provided.     * The parameters x, y, and z are arrays of eight 32-bit      * integers that specify the high-resolution coordinates point.     * @param x an eight element array specifying the x position     * @param y an eight element array specifying the y position     * @param z an eight element array specifying the z position     * @see HiResCoord     */    public void setHiRes(int[] x, int[] y, int[] z) {	HiResCoord hiRes = new HiResCoord(x, y, z);	setHiRes(hiRes);    }       /**     * Sets the HiRes coordinate of this context     * to the location specified by the HiRes argument.     * @param hiRes the HiRes coordinate specifying the a new location     */    public void setHiRes(HiResCoord hiRes) {        uHiRes.setHiResCoord(hiRes);        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||            (Thread.currentThread() == canvas3d.screen.renderer)) {

⌨️ 快捷键说明

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