📄 texture.java
字号:
} return ((TextureRetained)this.retained).getWidth(); } /** * Retrieves the height of this Texture object. * @return the height of this Texture object. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.2 */ public int getHeight() { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_SIZE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture17")); } return ((TextureRetained)this.retained).getHeight(); } /** * Retrieves the width of the boundary of this Texture object. * @return the width of the boundary of this Texture object. * @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 getBoundaryWidth() { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_SIZE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture17")); } return ((TextureRetained)this.retained).getBoundaryWidth(); } /** * Retrieves the number of mipmap levels needed for this Texture object. * @return (maximum Level - base Level + 1) * if <code>mipMapMode</code> is * <code>MULTI_LEVEL_MIPMAP</code>; otherwise it returns 1. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.2 */ public int numMipMapLevels() { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_SIZE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture18")); } return ((TextureRetained)this.retained).numMipMapLevels(); } /** * Sets mipmap mode for texture mapping for this texture object. * @param mipMapMode the new mipmap mode for this object. One of: * BASE_LEVEL or MULTI_LEVEL_MIPMAP. * @exception RestrictedAccessException if the method is called * when this object is part of live or compiled scene graph. * @exception IllegalArgumentException if <code>mipMapMode</code> * is a value other than <code>BASE_LEVEL</code> or * <code>MULTI_LEVEL_MIPMAP</code>. */ public void setMipMapMode(int mipMapMode) { checkForLiveOrCompiled(); ((TextureRetained)this.retained).initMipMapMode(mipMapMode); } /** * Retrieves current mipmap mode. * @return current mipmap mode of this texture object. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public int getMipMapMode() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_MIPMAP_MODE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture10")); return ((TextureRetained)this.retained).getMipMapMode(); } /** * Enables or disables texture mapping for this * appearance component object. * @param state true or false to enable or disable texture mapping * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setEnable(boolean state) { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_ENABLE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("Texture11")); } if (isLive()) ((TextureRetained)this.retained).setEnable(state); else ((TextureRetained)this.retained).initEnable(state); } /** * Retrieves the state of the texture enable flag. * @return true if texture mapping is enabled, * false if texture mapping is disabled * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public boolean getEnable() { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_ENABLE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture12")); } return ((TextureRetained)this.retained).getEnable(); } // Internal j3d usage method // Returns n if num is 2**n // Returns -1 if num is 0 or negative or if // num is NOT power of 2. // NOTE: ********** Assumes 32 bit integer****************** static int getPowerOf2(int num) { int i, tmp; // Can only handle positive numbers, return error. if (num < 1) return -1; for (i=0, tmp = num; i < 32;i++) { // Check if leftmost bit is 1 if ((tmp & 0x80000000) != 0) { //Check if any other bit is 1 if ((tmp & 0x7fffffff) == 0) return 31-i;//valid power of 2 integer else return -1;//invalid non-power-of-2 integer } tmp <<= 1; } //Can't reach here because we have already checked for 0 return -1; } // returns number of levels using NPOT rules for mipmap generation // which say that each level should be floor(size/2) of previous level static int getLevelsNPOT(int num) { int tmp, levels = 0; tmp = num; while (tmp > 1) { tmp = tmp / 2; levels++; } return levels; } /** * Sets the texture boundary color for this texture object. The * texture boundary color is used when boundaryModeS or boundaryModeT * is set to CLAMP or CLAMP_TO_BOUNDARY and if texture boundary is not * specified. * @param boundaryColor the new texture boundary color. * @exception RestrictedAccessException if the method is called * when this object is part of live or compiled scene graph. */ public void setBoundaryColor(Color4f boundaryColor) { checkForLiveOrCompiled(); ((TextureRetained)this.retained).initBoundaryColor(boundaryColor); } /** * Sets the texture boundary color for this texture object. The * texture boundary color is used when boundaryModeS or boundaryModeT * is set to CLAMP or CLAMP_TO_BOUNDARY and if texture boundary is not * specified. * @param r the red component of the color. * @param g the green component of the color. * @param b the blue component of the color. * @param a the alpha component of the color. * @exception RestrictedAccessException if the method is called * when this object is part of live or compiled scene graph. */ public void setBoundaryColor(float r, float g, float b, float a) { checkForLiveOrCompiled(); ((TextureRetained)this.retained).initBoundaryColor(r, g, b, a); } /** * Retrieves the texture boundary color for this texture object. * @param boundaryColor the vector that will receive the * current texture boundary color. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void getBoundaryColor(Color4f boundaryColor) { if (isLiveOrCompiled()) { if(!this.getCapability(ALLOW_BOUNDARY_COLOR_READ)) throw new CapabilityNotSetException(J3dI18N.getString("Texture13")); } ((TextureRetained)this.retained).getBoundaryColor(boundaryColor); } /** * Specifies the base level for this texture object. * @param baseLevel index of the lowest defined mipmap level. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if specified baseLevel < 0, or * if baseLevel > maximumLevel * * @since Java 3D 1.3 * @see Canvas3D#queryProperties */ public void setBaseLevel(int baseLevel) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_WRITE)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture32")); } } if (isLive()) { ((TextureRetained)this.retained).setBaseLevel(baseLevel); } else { ((TextureRetained)this.retained).initBaseLevel(baseLevel); } } /** * Retrieves the base level for this texture object. * @return base level for this texture object. * @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 getBaseLevel() { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_READ)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture34")); } } return ((TextureRetained)this.retained).getBaseLevel(); } /** * Specifies the maximum level for this texture object. * @param maximumLevel index of the highest defined mipmap level. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if specified * maximumLevel < baseLevel, or * if maximumLevel > <code>log<sub><font size=-2>2</font></sub>(max(width,height))</code> * @exception IllegalArgumentException if mipMipMapMode is equal to BASE_LEVEL * and maximumLevel is not equal to zero. * * @since Java 3D 1.3 * @see Canvas3D#queryProperties */ public void setMaximumLevel(int maximumLevel) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_WRITE)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture33")); } } if (isLive()) { ((TextureRetained)this.retained).setMaximumLevel(maximumLevel); } else { ((TextureRetained)this.retained).initMaximumLevel(maximumLevel); } } /** * Retrieves the maximum level for this texture object. * @return maximum level for this texture object. * @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 getMaximumLevel() { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_READ)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture35")); } } return ((TextureRetained)this.retained).getMaximumLevel(); } /** * Specifies the minimum level-of-detail for this texture object. * @param minimumLod the minimum level-of-detail. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if specified lod > maximum lod * * @since Java 3D 1.3 * @see Canvas3D#queryProperties */ public void setMinimumLOD(float minimumLod) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_WRITE)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture38")); } } if (isLive()) { ((TextureRetained)this.retained).setMinimumLOD(minimumLod); } else { ((TextureRetained)this.retained).initMinimumLOD(minimumLod); } } /** * Retrieves the minimum level-of-detail for this texture object. * @return the minimum level-of-detail * @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 float getMinimumLOD() { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_READ)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture40")); } } return ((TextureRetained)this.retained).getMinimumLOD(); } /** * Specifies the maximum level-of-detail for this texture object. * @param maximumLod the maximum level-of-detail. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if specified lod < minimum lod * * @since Java 3D 1.3 * @see Canvas3D#queryProperties */ public void setMaximumLOD(float maximumLod) { if (isLiveOrCompiled()) { if (!this.getCapability(ALLOW_LOD_RANGE_WRITE)) { throw new CapabilityNotSetException( J3dI18N.getString("Texture39")); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -