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

📄 graphicscontext3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            AppearanceRetained appRetained = (AppearanceRetained)appearance.retained;            if(appRetained.texture != null) {                assert (appRetained.texUnitState == null);                texRetained = appRetained.texture;                images = texRetained.getImages();                if(images != null) {                    for(int i=0; i<images.length; i++) {                        if(images[i] != null) {                            ImageComponentRetained imageRetained = (ImageComponentRetained) images[i].retained;                            // Do illegal sharing check                            if(imageRetained.getUsedByOffScreen()) {                                throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D30"));                            }                        }                    }                }            }            else if(appRetained.texUnitState != null) {                for(int j=0; j<appRetained.texUnitState.length; j++) {                    texRetained = appRetained.texUnitState[j].texture;                    images = texRetained.getImages();                    if(images != null) {                        for(int i=0; i<images.length; i++) {                            if(images[i] != null) {                                ImageComponentRetained imageRetained = (ImageComponentRetained) images[i].retained;                                // Do illegal sharing check                                if(imageRetained.getUsedByOffScreen()) {                                    throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D30"));                                }                            }                        }                    }                        }                       }        }        uAppearance = appearance;        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||	    (Thread.currentThread() == canvas3d.screen.renderer)) {            doSetAppearance(appearance);        } else if (Thread.currentThread() ==		   canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.SET_APPEARANCE, appearance, null);        } else {            sendRenderMessage(true, GraphicsContext3D.SET_APPEARANCE, appearance, null);        }    }        void doSetAppearance(Appearance appearance) {        // Appearance can't be null. See setAppearance().        assert(appearance != null);                NodeComponentRetained nc;        nc = ((AppearanceRetained)appearance.retained).material;        if (nc != null) {            nc.setInImmCtx(true);            enableLighting = ((MaterialRetained) nc).lightingEnable;            dRed = ((MaterialRetained) nc).diffuseColor.x;            dGreen = ((MaterialRetained) nc).diffuseColor.y;            dBlue = ((MaterialRetained) nc).diffuseColor.z;        } else {            enableLighting = false;        }                if(appearance instanceof ShaderAppearance){             // Handle ShaderProgramRetained.            ShaderProgramRetained spR = ((ShaderAppearanceRetained)appearance.retained).shaderProgram;            if(spR != null) {                spR.setInImmCtx(true);                Shader[] sArray = spR.getShaders();                if(sArray != null) {                    for (int i = 0 ; i < sArray.length; i++) {                        if (sArray[i] != null) {                            ((ShaderRetained)sArray[i].retained).setInImmCtx(true);                        }                    }                }            }            //Handle ShaderAttributeSetRetained.            ShaderAttributeSetRetained sasR =                         ((ShaderAppearanceRetained)appearance.retained).shaderAttributeSet;            if(sasR != null) {                sasR.setInImmCtx(true);                ShaderAttribute[] saArray = sasR.getAll();                if(saArray != null) {                    for (int i = 0 ; i < saArray.length; i++) {                        if (saArray[i] != null) {                            ((ShaderAttributeRetained)saArray[i].retained).setInImmCtx(true);                        }                    }                }            }        }                if (((AppearanceRetained)appearance.retained).texUnitState != null) {            TextureUnitStateRetained[] texUnitState =                    ((AppearanceRetained)appearance.retained).texUnitState;                        for (int i = 0 ; i < texUnitState.length; i++) {                if (texUnitState[i] != null) {                    texUnitState[i].setInImmCtx(true);                }            }        }                nc = ((AppearanceRetained)appearance.retained).texture;        if (nc != null) {            nc.setInImmCtx(true);        }                nc = ((AppearanceRetained)appearance.retained).texCoordGeneration;        if (nc != null) {            nc.setInImmCtx(true);        }                nc = ((AppearanceRetained)appearance.retained).textureAttributes;        if (nc != null) {            nc.setInImmCtx(true);        }                nc = ((AppearanceRetained)appearance.retained).coloringAttributes;        if (nc != null) {            nc.setInImmCtx(true);            red = ((ColoringAttributesRetained)nc).color.x;            green = ((ColoringAttributesRetained)nc).color.y;            blue = ((ColoringAttributesRetained)nc).color.z;        } else {            red = 1.0f;            green = 1.0f;            blue = 1.0f;        }                nc = ((AppearanceRetained)appearance.retained).transparencyAttributes;        if (nc != null) {            nc.setInImmCtx(true);            alpha = 1.0f - ((TransparencyAttributesRetained) nc).transparency;        } else {            alpha = 1.0f;        }                nc = ((AppearanceRetained)appearance.retained).renderingAttributes;        if (nc != null) {            nc.setInImmCtx(true);            visible = ((RenderingAttributesRetained)nc).visible;        } else            visible = true;                nc = ((AppearanceRetained)appearance.retained).polygonAttributes;        if (nc != null) {            nc.setInImmCtx(true);            polygonMode = ((PolygonAttributesRetained)nc).polygonMode;        } else {            polygonMode = PolygonAttributes.POLYGON_FILL;        }                nc = ((AppearanceRetained)appearance.retained).lineAttributes;        if (nc != null) {            nc.setInImmCtx(true);            lineAA = ((LineAttributesRetained)nc).lineAntialiasing;                    } else {            lineAA = false;        }                nc = ((AppearanceRetained)appearance.retained).pointAttributes;        if (nc != null) {            if (nc.source.isLive())                nc.setInImmCtx(true);            pointAA = ((PointAttributesRetained)nc).pointAntialiasing;        } else {            pointAA = false;        }                // Reset the inImmCtx flag of this.appearance.        if (this.appearance != null) {            AppearanceRetained app = (AppearanceRetained)this.appearance.retained;            app.setInImmCtx(false);            if (app.material != null) {                app.material.setInImmCtx(false);            }                        if(app instanceof ShaderAppearanceRetained){                // Handle ShaderProgramRetained.                ShaderProgramRetained spR = ((ShaderAppearanceRetained)app).shaderProgram;                if(spR != null) {                    spR.setInImmCtx(false);                    Shader[] sArray = spR.getShaders();                    if(sArray != null) {                        for (int i = 0 ; i < sArray.length; i++) {                            if (sArray[i] != null) {                                ((ShaderRetained)sArray[i].retained).setInImmCtx(false);                            }                        }                    }                }                                //Handle ShaderAttributeSetRetained.                ShaderAttributeSetRetained sasR = ((ShaderAppearanceRetained)app).shaderAttributeSet;                if(sasR != null) {                    sasR.setInImmCtx(false);                    ShaderAttribute[] saArray = sasR.getAll();                    if(saArray != null) {                        for (int i = 0 ; i < saArray.length; i++) {                            if (saArray[i] != null) {                                ((ShaderAttributeRetained)saArray[i].retained).setInImmCtx(false);                            }                        }                    }                }            }                        if (app.texUnitState != null) {                for (int i = 0; i < app.texUnitState.length; i++) {                    if (app.texUnitState[0] != null)                        app.texUnitState[0].setInImmCtx(false);                }            }            if (app.texture != null) {                app.texture.setInImmCtx(false);            }            if (app.texCoordGeneration != null) {                app.texCoordGeneration.setInImmCtx(false);            }            if (app.textureAttributes != null) {                app.textureAttributes.setInImmCtx(false);            }            if (app.coloringAttributes != null) {                app.coloringAttributes.setInImmCtx(false);            }            if (app.transparencyAttributes != null) {                app.transparencyAttributes.setInImmCtx(false);            }            if (app.renderingAttributes != null) {                app.renderingAttributes.setInImmCtx(false);            }            if (app.polygonAttributes != null) {                app.polygonAttributes.setInImmCtx(false);            }            if (app.lineAttributes != null) {                app.lineAttributes.setInImmCtx(false);            }            if (app.pointAttributes != null) {                app.pointAttributes.setInImmCtx(false);            }        }                ((AppearanceRetained)appearance.retained).setInImmCtx(true);           this.appearance = appearance;    }    /**     * Retrieves the current Appearance component object.     * @return the current Appearance object     */    public Appearance getAppearance() {	return this.uAppearance;    }    /**     * Sets the current Background to the specified Background     * leaf node object.     * The graphics context stores a reference to the specified      * Background node. This means that the application may modify      * the background color or image by using the appropriate      * methods on the Background node. The Background 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 Background object is null,      * the default background color of black (0,0,0) is used to clear     * the canvas prior to rendering a new frame. The Background      * node's application region is ignored for immediate-mode      * rendering.     *     * @param background the new Background object     *     * @exception IllegalSharingException if the Background node     * is part of or is subsequently made part of a live scene graph.     *     * @exception IllegalSharingException if the specified background node     * refers to an ImageComponent2D that is being used by a Canvas3D as     * an off-screen buffer.     */    public void setBackground(Background background) {                if (background.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D11"));        }        BackgroundRetained bgRetained = (BackgroundRetained)background.retained;        ImageComponent2D image = bgRetained.getImage();        if(image != null) {            ImageComponent2DRetained imageRetained = (ImageComponent2DRetained) image.retained;            if(imageRetained.getUsedByOffScreen()) {                throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D31"));            }        }        if (((BackgroundRetained)background.retained).geometryBranch != null) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D22"));        }                uBackground = background;        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||	    (Thread.currentThread() == canvas3d.screen.renderer)) {            doSetBackground(background);        } else if (Thread.currentThread() ==                        canvas3d.view.universe.behaviorScheduler) {            sendRenderMessage(false, GraphicsContext3D.SET_BACKGROUND, background, null);        } else {            sendRenderMessage(true, GraphicsContext3D.SET_BACKGROUND, background, null);        }    }    void doSetBackground(Background background) {	BackgroundRetained bg; 	if (this.background != null) {	    bg = (BackgroundRetained)this.background.retained;	    bg.setInImmCtx(false);	}	bg = (BackgroundRetained)background.retained;	bg.setInImmCtx(true);	this.background = background;    }    /**     * Retrieves the current Background leaf node object.     * @return the current Background object     */    public Background getBackground() {	return this.uBackground;    }    /**     * Sets the current Fog to the specified Fog     * leaf node object.     * The graphics context stores a reference to the specified      * Fog node. This means that the application may modify the      * fog attributes using the appropriate methods on the Fog      * node object. The Fog 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 Fog object is null, fog is disabled.      * Both the region of influence and the hierarchical scope      * of the Fog node are ignored for immediate-mode rendering.     * @param fog the new Fog object     * @exception IllegalSharingException if the Fog node     * is part of or is subsequently made part of a live scene graph.     */    public void setFog(Fog fog) {        if (fog != null && fog.isLive()) {           throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D12"));        }        uFog = fog;        if ((canvas3d.view == null) || 	    (canvas3d.view.universe == null) ||	    (!canvas3d.view.active) ||

⌨️ 快捷键说明

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