📄 textureattributesretained.java
字号:
int k = 0; for (int i = 0; i < textureColorTableSize; i++) { for (int j = 0; j < numTextureColorTableComponents; j++) { table[j][i] = textureColorTable[k++]; } } } final int getNumTextureColorTableComponents() { return numTextureColorTableComponents; } final int getTextureColorTableSize() { return textureColorTableSize; } final void initCombineRgbMode(int mode) { combineRgbMode = mode; } final void setCombineRgbMode(int mode) { initCombineRgbMode(mode); sendMessage(COMBINE_RGB_MODE_CHANGED, enums[mode], null); } final int getCombineRgbMode() { return combineRgbMode; } final void initCombineAlphaMode(int mode) { combineAlphaMode = mode; } final void setCombineAlphaMode(int mode) { initCombineAlphaMode(mode); sendMessage(COMBINE_ALPHA_MODE_CHANGED, enums[mode], null); } final int getCombineAlphaMode() { return combineAlphaMode; } final void initCombineRgbSource(int index, int src) { if (combineRgbSrc == null) { // it is possible to set the combineRgbSource before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } combineRgbSrc[index] = src; } final void setCombineRgbSource(int index, int src) { initCombineRgbSource(index, src); sendMessage(COMBINE_RGB_SRC_CHANGED, enums[index], enums[src]); } final int getCombineRgbSource(int index) { if (combineRgbSrc == null) { // it is possible to do a get before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } return combineRgbSrc[index]; } final void initCombineAlphaSource(int index, int src) { if (combineRgbSrc == null) { // it is possible to set the combineAlphaSource before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } combineAlphaSrc[index] = src; } final void setCombineAlphaSource(int index, int src) { initCombineAlphaSource(index, src); sendMessage(COMBINE_ALPHA_SRC_CHANGED, enums[index], enums[src]); } final int getCombineAlphaSource(int index) { if (combineRgbSrc == null) { // it is possible to do a get before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } return combineAlphaSrc[index]; } final void initCombineRgbFunction(int index, int fcn) { if (combineRgbSrc == null) { // it is possible to set the combineRgbFcn before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } combineRgbFcn[index] = fcn; } final void setCombineRgbFunction(int index, int fcn) { initCombineRgbFunction(index, fcn); sendMessage(COMBINE_RGB_FCN_CHANGED, enums[index], enums[fcn]); } final int getCombineRgbFunction(int index) { if (combineRgbSrc == null) { // it is possible to do a get before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } return combineRgbFcn[index]; } final void initCombineAlphaFunction(int index, int fcn) { if (combineRgbSrc == null) { // it is possible to set the combineAlphaFcn before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } combineAlphaFcn[index] = fcn; } final void setCombineAlphaFunction(int index, int fcn) { initCombineAlphaFunction(index, fcn); sendMessage(COMBINE_ALPHA_FCN_CHANGED, enums[index], enums[fcn]); } final int getCombineAlphaFunction(int index) { if (combineRgbSrc == null) { // it is possible to do a get before // setting the texture mode to COMBINE, so need to initialize // the combine mode related fields here initCombineMode(this); } return combineAlphaFcn[index]; } final void initCombineRgbScale(int scale) { combineRgbScale = scale; } final void setCombineRgbScale(int scale) { initCombineRgbScale(scale); sendMessage(COMBINE_RGB_SCALE_CHANGED, enums[scale], null); } final int getCombineRgbScale() { return combineRgbScale; } final void initCombineAlphaScale(int scale) { combineAlphaScale = scale; } final void setCombineAlphaScale(int scale) { initCombineAlphaScale(scale); sendMessage(COMBINE_ALPHA_SCALE_CHANGED, enums[scale], null); } final int getCombineAlphaScale() { return combineAlphaScale; } void updateNative(Canvas3D cv, boolean simulate, int textureFormat) { //System.err.println("TextureAttributes/updateNative: simulate= " + simulate + " " + this); //if ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COLOR_TABLE) // == 0) && textureColorTable != null) { // System.err.println("TextureColorTable Not supported"); //} //System.err.println("textureMode= " + textureMode); boolean isIdentity = ((transform.getType() & Transform3D.IDENTITY) != 0); if (simulate == false) { if (VirtualUniverse.mc.useCombiners && (cv.textureExtendedFeatures & Canvas3D.TEXTURE_REGISTER_COMBINERS) != 0) { Pipeline.getPipeline().updateRegisterCombiners(cv.ctx, transform.mat, isIdentity, textureMode, perspCorrectionMode, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w, textureFormat, combineRgbMode, combineAlphaMode, combineRgbSrc, combineAlphaSrc, combineRgbFcn, combineAlphaFcn, combineRgbScale, combineAlphaScale); } else { if (textureMode == TextureAttributes.COMBINE) { if ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COMBINE) != 0) { // Texture COMBINE is supported by the underlying layer int _combineRgbMode = combineRgbMode; int _combineAlphaMode = combineAlphaMode; Pipeline.getPipeline().updateTextureAttributes(cv.ctx, transform.mat, isIdentity, textureMode, perspCorrectionMode, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w, textureFormat); if (((combineRgbMode == TextureAttributes.COMBINE_DOT3) && ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COMBINE_DOT3) == 0)) || ((combineRgbMode == TextureAttributes.COMBINE_SUBTRACT) && ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COMBINE_SUBTRACT) == 0))) { // Combine DOT3/SUBTRACT is not supported by the // underlying layer, fallback to COMBINE_REPLACE _combineRgbMode = TextureAttributes.COMBINE_REPLACE; } if (((combineAlphaMode == TextureAttributes.COMBINE_DOT3) && ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COMBINE_DOT3) == 0)) || ((combineAlphaMode == TextureAttributes.COMBINE_SUBTRACT) && ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COMBINE_SUBTRACT) == 0))) { // Combine DOT3/SUBTRACT is not supported by the // underlying layer, fallback to COMBINE_REPLACE _combineAlphaMode = TextureAttributes.COMBINE_REPLACE; } Pipeline.getPipeline().updateCombiner(cv.ctx, _combineRgbMode, _combineAlphaMode, combineRgbSrc, combineAlphaSrc, combineRgbFcn, combineAlphaFcn, combineRgbScale, combineAlphaScale); } else { // Texture COMBINE is not supported by the underlying // layer, fallback to REPLACE Pipeline.getPipeline().updateTextureAttributes(cv.ctx, transform.mat, isIdentity, TextureAttributes.REPLACE, perspCorrectionMode, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w, textureFormat); } } else { Pipeline.getPipeline().updateTextureAttributes(cv.ctx, transform.mat, isIdentity, textureMode, perspCorrectionMode, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w, textureFormat); } } if (((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COLOR_TABLE) != 0) && textureColorTable != null) { Pipeline.getPipeline().updateTextureColorTable(cv.ctx, numTextureColorTableComponents, textureColorTableSize, textureColorTable); } } else { // we are in the multi-pass mode, // in this case, set the texture Mode to replace and use // blending to simulate the original textureMode Pipeline.getPipeline().updateTextureAttributes(cv.ctx, transform.mat, isIdentity, TextureAttributes.REPLACE, perspCorrectionMode, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w, textureFormat); if (((cv.textureExtendedFeatures & Canvas3D.TEXTURE_COLOR_TABLE) != 0) && textureColorTable != null) { Pipeline.getPipeline().updateTextureColorTable(cv.ctx, numTextureColorTableComponents, textureColorTableSize, textureColorTable); } switch (textureMode) { case TextureAttributes.COMBINE: case TextureAttributes.REPLACE: cv.setBlendFunc(cv.ctx, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_ZERO); break; case TextureAttributes.MODULATE: cv.setBlendFunc(cv.ctx, TransparencyAttributes.BLEND_DST_COLOR, TransparencyAttributes.BLEND_ZERO); break; case TextureAttributes.DECAL: if (textureFormat == Texture.RGBA) { cv.setBlendFunc(cv.ctx, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA); } else { cv.setBlendFunc(cv.ctx, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_ZERO); } break; case TextureAttributes.BLEND: cv.setBlendColor(cv.ctx, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w); cv.setBlendFunc(cv.ctx, TransparencyAttributes.BLEND_CONSTANT_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR); break; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -