📄 textureretained.java
字号:
else { if (img.getImageData(isUseAsRaster()).get() == null) { enable = false; } } if (!enable) sendMessage(ENABLE_CHANGED, Boolean.FALSE); } } } void initImages(ImageComponent[] images) { if (images.length != maxLevels) throw new IllegalArgumentException(J3dI18N.getString("Texture20")); for (int i = 0; i < images.length; i++) { initImage(i, images[i]); } } final void setImages(ImageComponent[] images) { int i; initImages(images); ImageComponent [] imgs = new ImageComponent[images.length]; for (i = 0; i < images.length; i++) { imgs[i] = images[i]; } Object arg[] = new Object[2]; arg[0] = imgs; arg[1] = new Integer(0); sendMessage(IMAGES_CHANGED, arg); // If the user has set enable to true, then if the image is null // turn off texture enable if (userSpecifiedEnable) { enable = userSpecifiedEnable; for (i = baseLevel; i <= maximumLevel && enable; i++) { if (images[i] != null) { ImageComponentRetained img= (ImageComponentRetained)images[i].retained; if (img.isByReference()) { if (img.getRefImage(0) == null) { enable = false; } } else { if (img.getImageData(isUseAsRaster()).get() == null) { enable = false; } } } } if (!enable) { sendMessage(ENABLE_CHANGED, Boolean.FALSE); } } } /** * Gets a specified mipmap level. * @param level mipmap level to get: 0 is the base level * @return the pixel array object containing the texture image * @exception RestrictedAccessException if the method is called * when this object is part of live or compiled scene graph. */ final ImageComponent getImage(int level) { return (((images != null) && (images[0][level] != null)) ? (ImageComponent)images[0][level].source : null); } final ImageComponent[] getImages() { if (images == null) return null; ImageComponent [] rImages = new ImageComponent[images[0].length]; for (int i = 0; i < images[0].length; i++) { if (images[0][i] != null) rImages[i] = (ImageComponent)images[0][i].source; else rImages[i] = null; } return rImages; } /** * 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 */ final void initMipMapMode(int mipmapMode) { if (this.mipmapMode == mipmapMode) return; int prevMaxLevels = maxLevels; // previous maxLevels this.mipmapMode = mipmapMode; if (mipmapMode != Texture.BASE_LEVEL) { maxLevels = maxMipMapLevels; } else { baseLevel = 0; maximumLevel = 0; maxLevels = 1; } ImageComponentRetained[][] newImages = new ImageComponentRetained[numFaces][maxLevels]; if (prevMaxLevels < maxLevels) { for (int f = 0; f < numFaces; f++) { for (int i = 0; i < prevMaxLevels; i++) { newImages[f][i] = images[f][i]; } for (int j = prevMaxLevels; j < maxLevels; j++) { newImages[f][j] = null; } } } else { for (int f = 0; f < numFaces; f++) { for (int i = 0; i < maxLevels; i++) newImages[f][i] = images[f][i]; } } images = newImages; } /** * Retrieves current mipmap mode. * @return current mipmap mode of this texture object. * @exception RestrictedAccessException if the method is called */ final int getMipMapMode() { return this.mipmapMode; } /** * Enables or disables texture mapping for this * appearance component object. * @param state true or false to enable or disable texture mapping */ final void initEnable(boolean state) { userSpecifiedEnable = state; } /** * Enables or disables texture mapping for this * appearance component object and sends a * message notifying the interested structures of the change. * @param state true or false to enable or disable texture mapping */ final void setEnable(boolean state) { initEnable(state); if (state == enable) { // if enable flag is same as user specified one // this is only possible when enable is false // because one of the images is null and user specifies false return; } enable = state; for (int j = 0; j < numFaces && enable; j++) { for (int i = baseLevel; i <= maximumLevel && enable; i++) { if (images[j][i].isByReference()) { if (images[j][i].getRefImage(0) == null) { enable = false; } } else { if (images[j][i].getImageData(isUseAsRaster()).get() == null) { enable = false; } } } } sendMessage(ENABLE_CHANGED, (enable ? Boolean.TRUE: Boolean.FALSE)); } /** * Retrieves the state of the texture enable flag. * @return true if texture mapping is enabled, * false if texture mapping is disabled */ final boolean getEnable() { return userSpecifiedEnable; } final void initBaseLevel(int level) { if ((level < 0) || (level > maximumLevel)) { throw new IllegalArgumentException( J3dI18N.getString("Texture36")); } baseLevel = level; } final void setBaseLevel(int level) { if (level == baseLevel) return; initBaseLevel(level); sendMessage(BASE_LEVEL_CHANGED, new Integer(level)); } final int getBaseLevel() { return baseLevel; } final void initMaximumLevel(int level) { if ((level < baseLevel) || (level >= maxMipMapLevels)) { throw new IllegalArgumentException( J3dI18N.getString("Texture37")); } if((mipmapMode == Texture.BASE_LEVEL) && (level != 0)) { throw new IllegalArgumentException( J3dI18N.getString("Texture48")); } maximumLevel = level; } final void setMaximumLevel(int level) { if (level == maximumLevel) return; initMaximumLevel(level); sendMessage(MAX_LEVEL_CHANGED, new Integer(level)); } final int getMaximumLevel() { return maximumLevel; } final void initMinimumLOD(float lod) { if (lod > maximumLod) { throw new IllegalArgumentException( J3dI18N.getString("Texture42")); } minimumLod = lod; } final void setMinimumLOD(float lod) { initMinimumLOD(lod); sendMessage(MIN_LOD_CHANGED, new Float(lod)); } final float getMinimumLOD() { return minimumLod; } final void initMaximumLOD(float lod) { if (lod < minimumLod) { throw new IllegalArgumentException( J3dI18N.getString("Texture42")); } maximumLod = lod; } final void setMaximumLOD(float lod) { initMaximumLOD(lod); sendMessage(MAX_LOD_CHANGED, new Float(lod)); } final float getMaximumLOD() { return maximumLod; } final void initLodOffset(float s, float t, float r) { if (lodOffset == null) { lodOffset = new Point3f(s, t, r); } else { lodOffset.set(s, t, r); } } final void setLodOffset(float s, float t, float r) { initLodOffset(s, t, r); sendMessage(LOD_OFFSET_CHANGED, new Point3f(s, t, r)); } final void getLodOffset(Tuple3f offset) { if (lodOffset == null) { offset.set(0.0f, 0.0f, 0.0f); } else { offset.set(lodOffset); } } /** * Sets the texture boundary color for this texture object. The * texture boundary color is used when boundaryModeS or boundaryModeT * is set to CLAMP. * @param boundaryColor the new texture boundary color. */ final void initBoundaryColor(Color4f boundaryColor) { this.boundaryColor.set(boundaryColor); } /** * Sets the texture boundary color for this texture object. The * texture boundary color is used when boundaryModeS or boundaryModeT * is set to CLAMP. * @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. */ final void initBoundaryColor(float r, float g, float b, float a) { this.boundaryColor.set(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. */ final void getBoundaryColor(Color4f boundaryColor) { boundaryColor.set(this.boundaryColor); } /** * Set Anisotropic Filter */ final void initAnisotropicFilterMode(int mode) { anisotropicFilterMode = mode; } final int getAnisotropicFilterMode() { return anisotropicFilterMode; } final void initAnisotropicFilterDegree(float degree) { anisotropicFilterDegree = degree; } final float getAnisotropicFilterDegree() { return anisotropicFilterDegree; } /** * Set Sharpen Texture function */ final void initSharpenTextureFunc(float[] lod, float[] pts) { if (lod == null) { // pts will be null too. sharpenTextureFuncPts = null; numSharpenTextureFuncPts = 0; } else { numSharpenTextureFuncPts = lod.length; if ((sharpenTextureFuncPts == null) || (sharpenTextureFuncPts.length != lod.length * 2)) { sharpenTextureFuncPts = new float[lod.length * 2]; } for (int i = 0, j = 0; i < lod.length; i++) { sharpenTextureFuncPts[j++] = lod[i]; sharpenTextureFuncPts[j++] = pts[i]; } } } final void initSharpenTextureFunc(Point2f[] pts) { if (pts == null) { sharpenTextureFuncPts = null; numSharpenTextureFuncPts = 0; } else { numSharpenTextureFuncPts = pts.length; if ((sharpenTextureFuncPts == null) || (sharpenTextureFuncPts.length != pts.length * 2)) { sharpenTextureFuncPts = new float[pts.length * 2]; } for (int i = 0, j = 0; i < pts.length; i++) { sharpenTextureFuncPts[j++] = pts[i].x; sharpenTextureFuncPts[j++] = pts[i].y; } } } final void initSharpenTextureFunc(float[] pts) { if (pts == null) { sharpenTextureFuncPts = null; numSharpenTextureFuncPts = 0; } else { numSharpenTextureFuncPts = pts.length / 2; if ((sharpenTextureFuncPts == null) || (sharpenTextureFuncPts.length != pts.length)) { sharpenTextureFuncPts = new float[pts.length]; } for (int i = 0; i < pts.length; i++) { sharpenTextureFuncPts[i] = pts[i]; } } } /** * Get number of points in the sharpen texture LOD function */ final int getSharpenTextureFuncPointsCount() { return numSharpenTextureFuncPts; } /** * Copies the array of sharpen texture LOD function points into the * specified arrays */ final void getSharpenTextureFunc(float[] lod, float[] pts) { if (sharpenTextureFuncPts != null) { for (int i = 0, j = 0; i < numSharpenTextureFuncPts; i++) { lod[i] = sharpenTextureFuncPts[j++]; pts[i] = sharpenTextureFuncPts[j++]; } } } final void getSharpenTextureFunc(Point2f[] pts) { if (sharpenTextureFuncPts != null) { for (int i = 0, j = 0; i < numSharpenTextureFuncPts; i++) { pts[i].x = sharpenTextureFuncPts[j++]; pts[i].y = sharpenTextureFuncPts[j++]; } } } final void initFilter4Func(float[] weights) { if (weights == null) { filter4FuncPts = null; } else { if ((filter4FuncPts == null) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -