0001: /*
0002: * $RCSfile: TextureAttributes.java,v $
0003: *
0004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
0005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0006: *
0007: * This code is free software; you can redistribute it and/or modify it
0008: * under the terms of the GNU General Public License version 2 only, as
0009: * published by the Free Software Foundation. Sun designates this
0010: * particular file as subject to the "Classpath" exception as provided
0011: * by Sun in the LICENSE file that accompanied this code.
0012: *
0013: * This code is distributed in the hope that it will be useful, but WITHOUT
0014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0016: * version 2 for more details (a copy is included in the LICENSE file that
0017: * accompanied this code).
0018: *
0019: * You should have received a copy of the GNU General Public License version
0020: * 2 along with this work; if not, write to the Free Software Foundation,
0021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0022: *
0023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0024: * CA 95054 USA or visit www.sun.com if you need additional information or
0025: * have any questions.
0026: *
0027: * $Revision: 1.6 $
0028: * $Date: 2008/02/28 20:17:31 $
0029: * $State: Exp $
0030: */
0031:
0032: package javax.media.j3d;
0033:
0034: import javax.vecmath.Color4f;
0035:
0036: /**
0037: * The TextureAttributes object defines attributes that apply to
0038: * texture mapping.
0039: * The texture attributes include the following:<P>
0040: * <UL>
0041: * <LI>Texture mode - defines how the object and texture colors
0042: * are blended. The mode may be one of the following:</LI><P>
0043: * <UL>
0044: * <LI>MODULATE - modulates the incoming color with the texture
0045: * color.<P>
0046: * <UL>
0047: * C' = C Ct
0048: * </UL></LI><P>
0049: * <LI>DECAL - applies the texture color to the incoming color as a decal.<P>
0050: * <UL>
0051: * C'<sub>rgb</sub> = C<sub>rgb</sub> (1 - Ct<sub>a</sub>) + Ct<sub>rgb</sub> Ct<sub>a</sub><P>
0052: * C'<sub>a</sub> = C<sub>a</sub>
0053: * </UL></LI><P>
0054: * <LI>BLEND - blends the texture blend color with the incoming color.<P>
0055: * <UL>
0056: * C'<sub>rgb</sub> = C<sub>rgb</sub> (1 - Ct<sub>rgb</sub>) + Cb<sub>rgb</sub> Ct<sub>rgb</sub><P>
0057: * C'<sub>a</sub> = C<sub>a</sub> Ct<sub>a</sub><P>
0058: * </UL>
0059: * Note that if the texture format is INTENSITY, alpha is computed identically
0060: * to red, green, and blue: <P>
0061: * <UL>
0062: * C'<sub>a</sub> = C<sub>a</sub> (1 - Ct<sub>a</sub>) + Cb<sub>a</sub> Ct<sub>a</sub>
0063: * </UL></LI><P>
0064: * <LI>REPLACE - replaces the incoming color with the texture color.<P>
0065: * <UL>
0066: * C' = Ct <P>
0067: * </UL></LI><P>
0068: * <LI>COMBINE - combines the object color with the texture color or texture
0069: * blend color according to the combine operation as specified in the
0070: * texture combine mode. </LI><P>
0071: * <p>
0072: * </UL>
0073: * C = Incoming color to the texture unit state. For texture unit state 0, C is the object color
0074: * Ct = Texture color<br>
0075: * Cb = Texture blend color<br>
0076: * <p>
0077: * <LI>Combine Mode - defines the combine operation when texture mode
0078: * specifies COMBINE. The combine mode includes the following:<p>
0079: * <UL>
0080: * <LI>COMBINE_REPLACE<P>
0081: * <UL>
0082: * C' = C<sub>0</sub> <P>
0083: * </UL></LI><P>
0084: * <LI>COMBINE_MODULATE<P>
0085: * <UL>
0086: * C' = C<sub>0</sub> C<sub>1</sub>
0087: * </UL></LI><P>
0088: * <LI>COMBINE_ADD<P>
0089: * <UL>
0090: * C' = C<sub>0</sub> + C<sub>1</sub> <P>
0091: * </UL></LI><P>
0092: * <LI>COMBINE_ADD_SIGNED <P>
0093: * <UL>
0094: * C' = C<sub>0</sub> + C<sub>1</sub> - 0.5 <P>
0095: * </UL></LI><P>
0096: * <LI>COMBINE_SUBTRACT <P>
0097: * <UL>
0098: * C' = C<sub>0</sub> - C<sub>1</sub> <P>
0099: * </UL></LI><P>
0100: * <LI>COMBINE_INTERPOLATE<P>
0101: * <UL>
0102: * C' = C<sub>0</sub> C<sub>2</sub> + C<sub>1</sub> (1 - C<sub>2</sub>) <P>
0103: * </UL></LI><P>
0104: * <LI>COMBINE_DOT3<P>
0105: * <UL>
0106: * C' = 4 * (
0107: * (C<sub>0<sub>r</sub></sub> - 0.5) * (C<sub>1<sub>r</sub></sub> - 0.5) +
0108: * (C<sub>0<sub>g</sub></sub> - 0.5) * (C<sub>1<sub>g</sub></sub> - 0.5) +
0109: * (C<sub>0<sub>b</sub></sub> - 0.5) * (C<sub>1<sub>b</sub></sub> - 0.5))<P>
0110: * where C<sub>N<sub>x</sub></sub> is the x component of the Nth color operand
0111: * in the combine operation.<P>
0112: * The value C' will be placed to the all three r,g,b components or the
0113: * a component of the output.
0114: * </UL></LI><P>
0115: * </UL></LI><P>
0116: * where C<sub>0</sub>, C<sub>1</sub> and C<sub>2</sub> are determined by
0117: * the color source, and the color operand.
0118: * </UL></LI><P>
0119: * <UL>
0120: * <LI>Combine Color Source - defines the source for a color operand in the
0121: * combine operation. The color source includes the following:<p>
0122: * <UL>
0123: * <LI> COMBINE_OBJECT_COLOR - object color<P>
0124: * <LI> COMBINE_TEXTURE_COLOR - texture color<P>
0125: * <LI> COMBINE_CONSTANT_COLOR - texture blend color<P>
0126: * <LI> COMBINE_PREVIOUS_TEXTURE_UNIT_STATE - color from the previous texture
0127: * unit state. For texture unit state 0, this is equivalent to
0128: * COMBINE_OBJECT_COLOR.<P>
0129: * </UL></LI><P>
0130: * <LI>Combine Color Function - specifies the function for a color operand
0131: * in the combine operation. The valid values are:<P>
0132: * <UL>
0133: * <LI>COMBINE_SRC_COLOR - the color function is f = C<sub>rgb</sub><P>
0134: * <LI>COMBINE_ONE_MINUS_SRC_COLOR - the color function is f = (1 - C<sub>rgb</sub>)<P>
0135: * <LI>COMBINE_SRC_ALPHA - the color function is f = C<sub>a</sub><P>
0136: * <LI>COMBINE_ONE_MINUS_SRC_ALPHA - the color function is f = (1 - C<sub>a</sub>)<P>
0137: * </UL></LI><P>
0138: * <LI>Combine scale factor - specifies the scale factor to be applied to
0139: * the output color of the combine operation. The valid values include:
0140: * 1, 2, or 4.</LI><P>
0141: * <LI>Transform - the texture transform object used to transform
0142: * texture coordinates. The texture transform can translate, scale,
0143: * or rotate the texture coordinates before the texture is applied
0144: * to the object.</LI><P>
0145: * <LI>Blend color - the constant texture blend color</LI><P>
0146: * <LI>Perspective correction - the perspective correction mode
0147: * used for color and texture coordinate interpolation. One of
0148: * the following:</LI><P>
0149: * <UL>
0150: * <LI>NICEST - uses the nicest (highest quality) available
0151: * method for texture mapping perspective correction.</LI><P>
0152: * <LI>FASTEST - uses the fastest available method for texture
0153: * mapping perspective correction.</LI><P>
0154: * </UL>
0155: * <LI>Texture color table - defines a table that is used to look up
0156: * texture colors before applying the texture mode.</LI>
0157: * </UL>
0158: *
0159: * @see Appearance
0160: * @see Canvas3D#queryProperties
0161: */
0162: public class TextureAttributes extends NodeComponent {
0163: /**
0164: * Specifies that this TextureAttributes object allows
0165: * reading its texture mode component
0166: * information and perspective correction mode.
0167: */
0168: public static final int ALLOW_MODE_READ = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_MODE_READ;
0169:
0170: /**
0171: * Specifies that this TextureAttributes object allows
0172: * writing its texture mode component
0173: * information and perspective correction mode.
0174: */
0175: public static final int ALLOW_MODE_WRITE = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_MODE_WRITE;
0176:
0177: /**
0178: * Specifies that this TextureAttributes object allows
0179: * reading its texture blend color component
0180: * information.
0181: */
0182: public static final int ALLOW_BLEND_COLOR_READ = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_BLEND_COLOR_READ;
0183:
0184: /**
0185: * Specifies that this TextureAttributes object allows
0186: * writing its texture blend color component
0187: * information.
0188: */
0189: public static final int ALLOW_BLEND_COLOR_WRITE = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_BLEND_COLOR_WRITE;
0190:
0191: /**
0192: * Specifies that this TextureAttributes object allows
0193: * reading its texture transform component
0194: * information.
0195: */
0196: public static final int ALLOW_TRANSFORM_READ = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_TRANSFORM_READ;
0197:
0198: /**
0199: * Specifies that this TextureAttributes object allows
0200: * writing its texture transform component
0201: * information.
0202: */
0203: public static final int ALLOW_TRANSFORM_WRITE = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_TRANSFORM_WRITE;
0204:
0205: /**
0206: * Specifies that this TextureAttributes object allows
0207: * reading its texture color table component
0208: * information.
0209: *
0210: * @since Java 3D 1.2
0211: */
0212: public static final int ALLOW_COLOR_TABLE_READ = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_COLOR_TABLE_READ;
0213:
0214: /**
0215: * Specifies that this TextureAttributes object allows
0216: * writing its texture color table component
0217: * information.
0218: *
0219: * @since Java 3D 1.2
0220: */
0221: public static final int ALLOW_COLOR_TABLE_WRITE = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_COLOR_TABLE_WRITE;
0222:
0223: /**
0224: * Specifies that this TextureAttributes object allows
0225: * reading its texture combine mode information. (e.g. combine mode,
0226: * combine color source, combine color function, combine scale factor)
0227: *
0228: * @since Java 3D 1.3
0229: */
0230: public static final int ALLOW_COMBINE_READ = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_COMBINE_READ;
0231:
0232: /**
0233: * Specifies that this TextureAttributes object allows
0234: * writing its texture combine mode information. (e.g. combine mode,
0235: * combine color source, combine color function, combine scale factor)
0236: *
0237: * @since Java 3D 1.3
0238: */
0239: public static final int ALLOW_COMBINE_WRITE = CapabilityBits.TEXTURE_ATTRIBUTES_ALLOW_COMBINE_WRITE;
0240:
0241: /**
0242: * Use the fastest available method for perspective correction.
0243: * @see #setPerspectiveCorrectionMode
0244: */
0245: public static final int FASTEST = 0;
0246:
0247: /**
0248: * Use the nicest (highest quality) available method for texture
0249: * mapping perspective correction.
0250: * @see #setPerspectiveCorrectionMode
0251: */
0252: public static final int NICEST = 1;
0253:
0254: /**
0255: * Modulate the object color with the texture color.
0256: * @see #setTextureMode
0257: */
0258: public static final int MODULATE = 2;
0259:
0260: /**
0261: * Apply the texture color to the object as a decal.
0262: * @see #setTextureMode
0263: */
0264: public static final int DECAL = 3;
0265:
0266: /**
0267: * Blend the texture blend color with the object color.
0268: * @see #setTextureMode
0269: */
0270: public static final int BLEND = 4;
0271:
0272: /**
0273: * Replace the object color with the texture color.
0274: * @see #setTextureMode
0275: */
0276: public static final int REPLACE = 5;
0277:
0278: /**
0279: * Combine the object color with texture color as specified in
0280: * the combine mode.
0281: *
0282: * @see #setTextureMode
0283: * @since Java 3D 1.3
0284: */
0285: public static final int COMBINE = 6;
0286:
0287: /**
0288: * Replace the input color with the specified color.
0289: *
0290: * @since Java 3D 1.3
0291: * @see #setCombineRgbMode
0292: * @see #setCombineAlphaMode
0293: */
0294: public static final int COMBINE_REPLACE = 0;
0295:
0296: /**
0297: * Modulates one color with another color.
0298: *
0299: * @since Java 3D 1.3
0300: * @see #setCombineRgbMode
0301: * @see #setCombineAlphaMode
0302: */
0303: public static final int COMBINE_MODULATE = 1;
0304:
0305: /**
0306: * Add two colors.
0307: *
0308: * @since Java 3D 1.3
0309: * @see #setCombineRgbMode
0310: * @see #setCombineAlphaMode
0311: */
0312: public static final int COMBINE_ADD = 2;
0313:
0314: /**
0315: * Add two colors plus an implicit offset.
0316: *
0317: * @since Java 3D 1.3
0318: * @see #setCombineRgbMode
0319: * @see #setCombineAlphaMode
0320: */
0321: public static final int COMBINE_ADD_SIGNED = 3;
0322:
0323: /**
0324: * Subtract one color from another color.
0325: *
0326: * @since Java 3D 1.3
0327: * @see #setCombineRgbMode
0328: * @see #setCombineAlphaMode
0329: */
0330: public static final int COMBINE_SUBTRACT = 4;
0331:
0332: /**
0333: * Interpolate two colors with a factor.
0334: *
0335: * @since Java 3D 1.3
0336: * @see #setCombineRgbMode
0337: * @see #setCombineAlphaMode
0338: */
0339: public static final int COMBINE_INTERPOLATE = 5;
0340:
0341: /**
0342: * Dot product of two colors.
0343: *
0344: * @since Java 3D 1.3
0345: * @see #setCombineRgbMode
0346: * @see #setCombineAlphaMode
0347: */
0348: public static final int COMBINE_DOT3 = 6;
0349:
0350: /**
0351: * Object color coming into the texturing state.
0352: *
0353: * @since Java 3D 1.3
0354: * @see #setCombineRgbSource
0355: * @see #setCombineAlphaSource
0356: */
0357: public static final int COMBINE_OBJECT_COLOR = 0;
0358:
0359: /**
0360: * Texture color of the corresponding texture unit state.
0361: *
0362: * @since Java 3D 1.3
0363: * @see #setCombineRgbSource
0364: * @see #setCombineAlphaSource
0365: */
0366: public static final int COMBINE_TEXTURE_COLOR = 1;
0367:
0368: /**
0369: * Texture blend color.
0370: *
0371: * @since Java 3D 1.3
0372: * @see #setCombineRgbSource
0373: * @see #setCombineAlphaSource
0374: */
0375: public static final int COMBINE_CONSTANT_COLOR = 2;
0376:
0377: /**
0378: * Color from the previous texture unit state.
0379: *
0380: * @since Java 3D 1.3
0381: * @see #setCombineRgbSource
0382: * @see #setCombineAlphaSource
0383: */
0384: public static final int COMBINE_PREVIOUS_TEXTURE_UNIT_STATE = 3;
0385:
0386: /**
0387: * Color function is f = C<sub>rgb</sub>
0388: *
0389: * @since Java 3D 1.3
0390: * @see #setCombineRgbFunction
0391: */
0392: public static final int COMBINE_SRC_COLOR = 0;
0393:
0394: /**
0395: * Color function is f = (1 - C<sub>rgb</sub>)
0396: *
0397: * @since Java 3D 1.3
0398: * @see #setCombineRgbFunction
0399: */
0400: public static final int COMBINE_ONE_MINUS_SRC_COLOR = 1;
0401:
0402: /**
0403: * Color function is f = C<sub>a</sub>
0404: *
0405: * @since Java 3D 1.3
0406: * @see #setCombineRgbFunction
0407: * @see #setCombineAlphaFunction
0408: */
0409: public static final int COMBINE_SRC_ALPHA = 2;
0410:
0411: /**
0412: * Color function is f = (1 - C<sub>a</sub>)
0413: *
0414: * @since Java 3D 1.3
0415: * @see #setCombineRgbFunction
0416: * @see #setCombineAlphaFunction
0417: */
0418: public static final int COMBINE_ONE_MINUS_SRC_ALPHA = 3;
0419:
0420: // Array for setting default read capabilities
0421: private static final int[] readCapabilities = {
0422: ALLOW_BLEND_COLOR_READ, ALLOW_COLOR_TABLE_READ,
0423: ALLOW_COMBINE_READ, ALLOW_MODE_READ, ALLOW_TRANSFORM_READ };
0424:
0425: /**
0426: * Constructs a TextureAttributes object with default parameters.
0427: * The default values are as follows:
0428: * <ul>
0429: * texture mode : REPLACE<br>
0430: * blend color : black (0,0,0,0)<br>
0431: * transform : identity<br>
0432: * perspective correction mode : NICEST<br>
0433: * texture color table : null<br>
0434: * combine rgb mode : COMBINE_MODULATE<br>
0435: * combine alpha mode : COMBINE_MODULATE<br>
0436: * combine rgb source :
0437: * <ul>
0438: * C<sub>0</sub>=COMBINE_TEXTURE_COLOR<br>
0439: * C<sub>1</sub>=COMBINE_PREVIOUS_TEXTURE_UNIT_STATE<br>
0440: * C<sub>2</sub>=COMBINE_CONSTANT_COLOR<br>
0441: * </ul>
0442: * combine alpha source :
0443: * <ul>
0444: * C<sub>0</sub>=COMBINE_TEXTURE_COLOR<br>
0445: * C<sub>1</sub>=COMBINE_PREVIOUS_TEXTURE_UNIT_STATE<br>
0446: * C<sub>2</sub>=COMBINE_CONSTANT_COLOR<br>
0447: * </ul>
0448: * combine rgb function : COMBINE_SRC_COLOR<br>
0449: * combine alpha function : COMBINE_SRC_ALPHA<br>
0450: * combine rgb scale : 1<br>
0451: * combine alpha scale : 1<br>
0452: * </ul>
0453: */
0454: public TextureAttributes() {
0455: // set default read capabilities
0456: setDefaultReadCapabilities(readCapabilities);
0457: }
0458:
0459: /**
0460: * Constructs a TextureAttributes object with the specified values.
0461: * @param textureMode the texture mode; one of <code>MODULATE</code>,
0462: * <code>DECAL</code>, <code>BLEND</code>, <code>REPLACE</code>, or
0463: * <code>COMBINE</code>
0464: * @param transform the transform object, used to transform texture
0465: * coordinates
0466: * @param textureBlendColor the texture constant color
0467: * @param perspCorrectionMode the perspective correction mode to
0468: * be used for color and/or texture coordinate interpolation;
0469: * one of <code>NICEST</code> or <code>FASTEST</code>
0470: * @exception IllegalArgumentException if <code>textureMode</code>
0471: * is a value other than <code>MODULATE</code>,
0472: * <code>DECAL</code>, <code>BLEND</code>, <code>REPLACE</code>, or
0473: * <code>COMBINE</code>
0474: * @exception IllegalArgumentException if mode value is other
0475: * than <code>FASTEST</code> or <code>NICEST</code>.
0476: */
0477: public TextureAttributes(int textureMode, Transform3D transform,
0478: Color4f textureBlendColor, int perspCorrectionMode) {
0479:
0480: if ((textureMode < MODULATE) || (textureMode > COMBINE)) {
0481: throw new IllegalArgumentException(J3dI18N
0482: .getString("TextureAttributes10"));
0483: }
0484:
0485: if ((perspCorrectionMode != FASTEST)
0486: && (perspCorrectionMode != NICEST)) {
0487: throw new IllegalArgumentException(J3dI18N
0488: .getString("TextureAttributes9"));
0489: }
0490:
0491: // set default read capabilities
0492: setDefaultReadCapabilities(readCapabilities);
0493:
0494: ((TextureAttributesRetained) this .retained)
0495: .initTextureMode(textureMode);
0496: ((TextureAttributesRetained) this .retained)
0497: .initTextureBlendColor(textureBlendColor);
0498: ((TextureAttributesRetained) this .retained)
0499: .initTextureTransform(transform);
0500: ((TextureAttributesRetained) this .retained)
0501: .initPerspectiveCorrectionMode(perspCorrectionMode);
0502: }
0503:
0504: /**
0505: * Sets the texture mode parameter for this
0506: * appearance component object.
0507: * @param textureMode the texture mode, one of: <code>MODULATE</code>,
0508: * <code>DECAL</code>, <code>BLEND</code>, <code>REPLACE</code>, or
0509: * <code>COMBINE</code>
0510: * @exception IllegalArgumentException if <code>textureMode</code>
0511: * is a value other than <code>MODULATE</code>,
0512: * <code>DECAL</code>, <code>BLEND</code>, <code>REPLACE</code>, or
0513: * <code>COMBINE</code>
0514: *
0515: * @see Canvas3D#queryProperties
0516: */
0517: public void setTextureMode(int textureMode) {
0518: if (isLiveOrCompiled())
0519: if (!this .getCapability(ALLOW_MODE_WRITE))
0520: throw new CapabilityNotSetException(J3dI18N
0521: .getString("TextureAttributes0"));
0522:
0523: if ((textureMode < MODULATE) || (textureMode > COMBINE)) {
0524: throw new IllegalArgumentException(J3dI18N
0525: .getString("TextureAttributes10"));
0526: }
0527:
0528: if (isLive())
0529: ((TextureAttributesRetained) this .retained)
0530: .setTextureMode(textureMode);
0531: else
0532: ((TextureAttributesRetained) this .retained)
0533: .initTextureMode(textureMode);
0534: }
0535:
0536: /**
0537: * Gets the texture mode parameter for this
0538: * texture attributes object.
0539: * @return textureMode the texture mode
0540: * @exception CapabilityNotSetException if appropriate capability is
0541: * not set and this object is part of live or compiled scene graph
0542: */
0543: public int getTextureMode() {
0544: if (isLiveOrCompiled())
0545: if (!this .getCapability(ALLOW_MODE_READ))
0546: throw new CapabilityNotSetException(J3dI18N
0547: .getString("TextureAttributes1"));
0548:
0549: return ((TextureAttributesRetained) this .retained)
0550: .getTextureMode();
0551: }
0552:
0553: /**
0554: * Sets the texture constant color for this
0555: * texture attributes object.
0556: * @param textureBlendColor the texture constant color
0557: * @exception CapabilityNotSetException if appropriate capability is
0558: * not set and this object is part of live or compiled scene graph
0559: */
0560: public void setTextureBlendColor(Color4f textureBlendColor) {
0561: if (isLiveOrCompiled())
0562: if (!this .getCapability(ALLOW_BLEND_COLOR_WRITE))
0563: throw new CapabilityNotSetException(J3dI18N
0564: .getString("TextureAttributes2"));
0565:
0566: if (isLive())
0567: ((TextureAttributesRetained) this .retained)
0568: .setTextureBlendColor(textureBlendColor);
0569: else
0570: ((TextureAttributesRetained) this .retained)
0571: .initTextureBlendColor(textureBlendColor);
0572: }
0573:
0574: /**
0575: * Sets the texture blend color for this
0576: * appearance component object.
0577: * @param r the red component of the color
0578: * @param g the green component of the color
0579: * @param b the blue component of the color
0580: * @param a the alpha component of the color
0581: * @exception CapabilityNotSetException if appropriate capability is
0582: * not set and this object is part of live or compiled scene graph
0583: */
0584: public void setTextureBlendColor(float r, float g, float b, float a) {
0585: if (isLiveOrCompiled())
0586: if (!this .getCapability(ALLOW_BLEND_COLOR_WRITE))
0587: throw new CapabilityNotSetException(J3dI18N
0588: .getString("TextureAttributes3"));
0589:
0590: if (isLive())
0591: ((TextureAttributesRetained) this .retained)
0592: .setTextureBlendColor(r, g, b, a);
0593: else
0594: ((TextureAttributesRetained) this .retained)
0595: .initTextureBlendColor(r, g, b, a);
0596: }
0597:
0598: /**
0599: * Gets the texture blend color for this
0600: * appearance component object.
0601: * @param textureBlendColor the vector that will receive the texture
0602: * constant color
0603: * @exception CapabilityNotSetException if appropriate capability is
0604: * not set and this object is part of live or compiled scene graph
0605: */
0606: public void getTextureBlendColor(Color4f textureBlendColor) {
0607: if (isLiveOrCompiled())
0608: if (!this .getCapability(ALLOW_BLEND_COLOR_READ))
0609: throw new CapabilityNotSetException(J3dI18N
0610: .getString("TextureAttributes4"));
0611:
0612: ((TextureAttributesRetained) this .retained)
0613: .getTextureBlendColor(textureBlendColor);
0614: }
0615:
0616: /**
0617: * Sets the texture transform object used to transform texture
0618: * coordinates. A copy of the specified Transform3D object is
0619: * stored in this TextureAttributes object.
0620: * @param transform the new transform object
0621: * @exception CapabilityNotSetException if the method is called
0622: * when this object is part of live or compiled scene graph.
0623: */
0624: public void setTextureTransform(Transform3D transform) {
0625: if (isLiveOrCompiled())
0626: if (!this .getCapability(ALLOW_TRANSFORM_WRITE))
0627: throw new CapabilityNotSetException(J3dI18N
0628: .getString("TextureAttributes5"));
0629:
0630: if (isLive())
0631: ((TextureAttributesRetained) this .retained)
0632: .setTextureTransform(transform);
0633: else
0634: ((TextureAttributesRetained) this .retained)
0635: .initTextureTransform(transform);
0636: }
0637:
0638: /**
0639: * Retrieves a copy of the texture transform object.
0640: * @param transform the transform object that will receive the
0641: * current texture transform
0642: * @exception CapabilityNotSetException if the method is called
0643: * when this object is part of live or compiled scene graph.
0644: */
0645: public void getTextureTransform(Transform3D transform) {
0646: if (isLiveOrCompiled())
0647: if (!this .getCapability(ALLOW_TRANSFORM_READ))
0648: throw new CapabilityNotSetException(J3dI18N
0649: .getString("TextureAttributes6"));
0650:
0651: ((TextureAttributesRetained) this .retained)
0652: .getTextureTransform(transform);
0653: }
0654:
0655: /**
0656: * Sets perspective correction mode to be used for color
0657: * and/or texture coordinate interpolation.
0658: * A value of <code>NICEST</code> indicates that perspective correction should be
0659: * performed and that the highest quality method should be used.
0660: * A value of <code>FASTEST</code> indicates that the most efficient perspective
0661: * correction method should be used.
0662: * @param mode one of <code>NICEST</code> or <code>FASTEST</code>
0663: * The default value is <code>NICEST</code>.
0664: * @exception CapabilityNotSetException if appropriate capability is
0665: * not set and this object is part of live or compiled scene graph
0666: * @exception IllegalArgumentException if mode value is other
0667: * than <code>FASTEST</code> or <code>NICEST</code>.
0668: */
0669: public void setPerspectiveCorrectionMode(int mode) {
0670: if (isLiveOrCompiled())
0671: if (!this .getCapability(ALLOW_MODE_WRITE))
0672: throw new CapabilityNotSetException(J3dI18N
0673: .getString("TextureAttributes7"));
0674:
0675: if ((mode != FASTEST) && (mode != NICEST))
0676: throw new IllegalArgumentException(J3dI18N
0677: .getString("TextureAttributes9"));
0678:
0679: if (isLive())
0680: ((TextureAttributesRetained) this .retained)
0681: .setPerspectiveCorrectionMode(mode);
0682: else
0683: ((TextureAttributesRetained) this .retained)
0684: .initPerspectiveCorrectionMode(mode);
0685: }
0686:
0687: /**
0688: * Gets perspective correction mode value.
0689: * @return mode the value of perspective correction mode
0690: * @exception CapabilityNotSetException if appropriate capability is
0691: * not set and this object is part of live or compiled scene graph
0692: */
0693: public int getPerspectiveCorrectionMode() {
0694: if (isLiveOrCompiled())
0695: if (!this .getCapability(ALLOW_MODE_READ))
0696: throw new CapabilityNotSetException(J3dI18N
0697: .getString("TextureAttributes8"));
0698: return ((TextureAttributesRetained) this .retained)
0699: .getPerspectiveCorrectionMode();
0700: }
0701:
0702: /**
0703: * Sets the texture color table from the specified table. The
0704: * individual integer array elements are copied. The array is
0705: * indexed first by color component (<i>r</i>, <i>g</i>, <i>b</i>,
0706: * and <i>a</i>, respectively) and then by color value;
0707: * <code>table.length</code> defines the number of color
0708: * components and <code>table[0].length</code> defines the texture
0709: * color table size. If the table is non-null, the number of
0710: * color components must either be 3, for <i>rgb</i> data, or 4,
0711: * for <i>rgba</i> data. The size of each array for each color
0712: * component must be the same and must be a power of 2. If table
0713: * is null or if the texture color table size is 0, the texture
0714: * color table is disabled. If the texture color table size is
0715: * greater than the device-dependent maximum texture color table
0716: * size for a particular Canvas3D, the texture color table is
0717: * ignored for that canvas.
0718: *
0719: * <p>
0720: * When enabled, the texture color table is applied after the
0721: * texture filtering operation and before texture application.
0722: * Each of the <i>r</i>, <i>g</i>, <i>b</i>, and <i>a</i>
0723: * components are clamped to the range [0,1], multiplied by
0724: * <code>textureColorTableSize-1</code>, and rounded to the
0725: * nearest integer. The resulting value for each component is
0726: * then used as an index into the respective table for that
0727: * component. If the texture color table contains 3 components,
0728: * alpha is passed through unmodified.
0729: *
0730: * @param table the new texture color table
0731: *
0732: * @exception IllegalArgumentException if <code>table.length</code>
0733: * is not 3 or 4, or if the arrays for each component are not all
0734: * the same length, or if the texture color table size
0735: * is not a power of 2
0736: * @exception CapabilityNotSetException if appropriate capability is
0737: * not set and this object is part of live or compiled scene graph
0738: *
0739: * @see Canvas3D#queryProperties
0740: *
0741: * @since Java 3D 1.2
0742: */
0743: public void setTextureColorTable(int[][] table) {
0744: if (isLiveOrCompiled())
0745: if (!this .getCapability(ALLOW_COLOR_TABLE_WRITE))
0746: throw new CapabilityNotSetException(J3dI18N
0747: .getString("TextureAttributes11"));
0748:
0749: if (isLive())
0750: ((TextureAttributesRetained) this .retained)
0751: .setTextureColorTable(table);
0752: else
0753: ((TextureAttributesRetained) this .retained)
0754: .initTextureColorTable(table);
0755: }
0756:
0757: /**
0758: * Retrieves the texture color table and copies it into the
0759: * specified array. If the current texture color table is null,
0760: * no values are copied.
0761: *
0762: * @param table the array that will receive a copy of the
0763: * texture color table from this TextureAttributes object.
0764: * The array must be allocated by the caller and must be large
0765: * enough to hold the entire table (that is,
0766: * <code>int[numTextureColorTableComponents][textureColorTableSize]</code>).
0767: *
0768: * @exception CapabilityNotSetException if appropriate capability is
0769: * not set and this object is part of live or compiled scene graph
0770: *
0771: * @since Java 3D 1.2
0772: */
0773: public void getTextureColorTable(int[][] table) {
0774: if (isLiveOrCompiled())
0775: if (!this .getCapability(ALLOW_COLOR_TABLE_READ))
0776: throw new CapabilityNotSetException(J3dI18N
0777: .getString("TextureAttributes12"));
0778: ((TextureAttributesRetained) this .retained)
0779: .getTextureColorTable(table);
0780: return;
0781: }
0782:
0783: /**
0784: * Retrieves the number of color components in the current texture
0785: * color table. A value of 0 is returned if the texture color
0786: * table is null.
0787: *
0788: * @return the number of color components in the texture color
0789: * table, or 0 if the table is null
0790: *
0791: * @since Java 3D 1.2
0792: */
0793: public int getNumTextureColorTableComponents() {
0794: return (((TextureAttributesRetained) this .retained)
0795: .getNumTextureColorTableComponents());
0796: }
0797:
0798: /**
0799: * Retrieves the size of the current texture color table. A value
0800: * of 0 is returned if the texture color table is null.
0801: *
0802: * @return the size of the texture color table, or 0 if the table
0803: * is null
0804: *
0805: * @since Java 3D 1.2
0806: */
0807: public int getTextureColorTableSize() {
0808: return (((TextureAttributesRetained) this .retained)
0809: .getTextureColorTableSize());
0810: }
0811:
0812: /**
0813: * Sets the combine mode for the rgb components of the output color
0814: * for this object.
0815: *
0816: * @param combineMode the combine mode, one of:
0817: * <code>COMBINE_REPLACE</code>,
0818: * <code>COMBINE_MODULATE</code>, <code>COMBINE_ADD</code>,
0819: * <code>COMBINE_ADD_SIGNED</code>, <code>COMBINE_SUBTRACT</code>,
0820: * <code>COMBINE_INTERPOLATE</code>, or <code>COMBINE_DOT3</code>
0821: *
0822: * @exception IllegalArgumentException if <code>combineMode</code>
0823: * is a value other than <code>COMBINE_REPLACE</code>,
0824: * <code>COMBINE_MODULATE</code>, <code>COMBINE_ADD</code>,
0825: * <code>COMBINE_ADD_SIGNED</code>, <code>COMBINE_SUBTRACT</code>,
0826: * <code>COMBINE_INTERPOLATE</code>, or <code>COMBINE_DOT3</code>
0827: * @exception CapabilityNotSetException if appropriate capability is
0828: * not set and this object is part of live or compiled scene graph
0829: *
0830: * @see Canvas3D#queryProperties
0831: *
0832: * @since Java 3D 1.3
0833: */
0834: public void setCombineRgbMode(int combineMode) {
0835: if (isLiveOrCompiled()) {
0836: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
0837: throw new CapabilityNotSetException(J3dI18N
0838: .getString("TextureAttributes16"));
0839: }
0840: }
0841:
0842: if ((combineMode < COMBINE_REPLACE)
0843: || (combineMode > COMBINE_DOT3)) {
0844: throw new IllegalArgumentException(J3dI18N
0845: .getString("TextureAttributes20"));
0846: }
0847:
0848: if (isLive()) {
0849: ((TextureAttributesRetained) this .retained)
0850: .setCombineRgbMode(combineMode);
0851: } else {
0852: ((TextureAttributesRetained) this .retained)
0853: .initCombineRgbMode(combineMode);
0854: }
0855: }
0856:
0857: /**
0858: * Sets the combine mode for the alpha component of the output color
0859: * for this object.
0860: *
0861: * @param combineMode the combine mode, one of:
0862: * <code>COMBINE_REPLACE</code>,
0863: * <code>COMBINE_MODULATE</code>, <code>COMBINE_ADD</code>,
0864: * <code>COMBINE_ADD_SIGNED</code>, <code>COMBINE_SUBTRACT</code>,
0865: * <code>COMBINE_INTERPOLATE</code>, or <code>COMBINE_DOT3</code>
0866: *
0867: * @exception IllegalArgumentException if <code>combineMode</code>
0868: * is a value other than <code>COMBINE_REPLACE</code>,
0869: * <code>COMBINE_MODULATE</code>, <code>COMBINE_ADD</code>,
0870: * <code>COMBINE_ADD_SIGNED</code>, <code>COMBINE_SUBTRACT</code>,
0871: * <code>COMBINE_INTERPOLATE</code>, or <code>COMBINE_DOT3</code>
0872: * @exception CapabilityNotSetException if appropriate capability is
0873: * not set and this object is part of live or compiled scene graph
0874: *
0875: * @see Canvas3D#queryProperties
0876: *
0877: * @since Java 3D 1.3
0878: */
0879: public void setCombineAlphaMode(int combineMode) {
0880: if (isLiveOrCompiled()) {
0881: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
0882: throw new CapabilityNotSetException(J3dI18N
0883: .getString("TextureAttributes18"));
0884: }
0885: }
0886:
0887: if ((combineMode < COMBINE_REPLACE)
0888: || (combineMode > COMBINE_DOT3)) {
0889: throw new IllegalArgumentException(J3dI18N
0890: .getString("TextureAttributes20"));
0891: }
0892:
0893: if (isLive()) {
0894: ((TextureAttributesRetained) this .retained)
0895: .setCombineAlphaMode(combineMode);
0896: } else {
0897: ((TextureAttributesRetained) this .retained)
0898: .initCombineAlphaMode(combineMode);
0899: }
0900: }
0901:
0902: /**
0903: * Retrieves the combine mode for the rgb components of the output color
0904: * for this object.
0905: * @return the combine mode for the rgb components.
0906: *
0907: * @exception CapabilityNotSetException if appropriate capability is
0908: * not set and this object is part of live or compiled scene graph
0909: *
0910: * @since Java 3D 1.3
0911: */
0912: public int getCombineRgbMode() {
0913: if (isLiveOrCompiled()) {
0914: if (!this .getCapability(ALLOW_COMBINE_READ)) {
0915: throw new CapabilityNotSetException(J3dI18N
0916: .getString("TextureAttributes17"));
0917: }
0918: }
0919:
0920: return ((TextureAttributesRetained) this .retained)
0921: .getCombineRgbMode();
0922: }
0923:
0924: /**
0925: * Retrieves the combine mode for the alpha component of the output color
0926: * for this object.
0927: * @return the combine mode for the alpha component.
0928: *
0929: * @exception CapabilityNotSetException if appropriate capability is
0930: * not set and this object is part of live or compiled scene graph
0931: *
0932: * @since Java 3D 1.3
0933: */
0934: public int getCombineAlphaMode() {
0935: if (isLiveOrCompiled()) {
0936: if (!this .getCapability(ALLOW_COMBINE_READ)) {
0937: throw new CapabilityNotSetException(J3dI18N
0938: .getString("TextureAttributes19"));
0939: }
0940: }
0941:
0942: return ((TextureAttributesRetained) this .retained)
0943: .getCombineAlphaMode();
0944: }
0945:
0946: /**
0947: * Sets the source for the rgb components of the specified color operand
0948: * for this object.
0949: *
0950: * @param index color operand in the combine operation
0951: * @param src the color source, one of: <code>COMBINE_OBJECT_COLOR</code>,
0952: * <code>COMBINE_TEXTURE_COLOR</code>,
0953: * <code>COMBINE_CONSTANT_COLOR</code>, or
0954: * <code>COMBINE_PREVIOUS_TEXTURE_UNIT_STATE</code>
0955: *
0956: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
0957: * <code>index</code> > 2
0958: * @exception IllegalArgumentException if <code>src</code>
0959: * is a value other than <code>COMBINE_OBJECT_COLOR</code>,
0960: * <code>COMBINE_TEXTURE_COLOR</code>,
0961: * <code>COMBINE_CONSTANT_COLOR</code>, or
0962: * <code>COMBINE_PREVIOUS_TEXTURE_UNIT_STATE</code>
0963: * @exception CapabilityNotSetException if appropriate capability is
0964: * not set and this object is part of live or compiled scene graph
0965: *
0966: * @see Canvas3D#queryProperties
0967: *
0968: * @since Java 3D 1.3
0969: */
0970: public void setCombineRgbSource(int index, int src) {
0971: if (isLiveOrCompiled()) {
0972: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
0973: throw new CapabilityNotSetException(J3dI18N
0974: .getString("TextureAttributes21"));
0975: }
0976: }
0977:
0978: if ((index < 0) || (index > 2)) {
0979: throw new IndexOutOfBoundsException(J3dI18N
0980: .getString("TextureAttributes25"));
0981: }
0982:
0983: if ((src < COMBINE_OBJECT_COLOR)
0984: || (src > COMBINE_PREVIOUS_TEXTURE_UNIT_STATE)) {
0985: throw new IllegalArgumentException(J3dI18N
0986: .getString("TextureAttributes26"));
0987: }
0988:
0989: if (isLive()) {
0990: ((TextureAttributesRetained) this .retained)
0991: .setCombineRgbSource(index, src);
0992: } else {
0993: ((TextureAttributesRetained) this .retained)
0994: .initCombineRgbSource(index, src);
0995: }
0996: }
0997:
0998: /**
0999: * Sets the source for the alpha component of the specified color operand
1000: * for this object.
1001: *
1002: * @param index color operand in the combine operation
1003: * @param src the color source, one of: <code>COMBINE_OBJECT_COLOR</code>,
1004: * <code>COMBINE_TEXTURE_COLOR</code>,
1005: * <code>COMBINE_CONSTANT_COLOR</code>, or
1006: * <code>COMBINE_PREVIOUS_TEXTURE_UNIT_STATE</code>
1007: *
1008: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1009: * <code>index</code> > 2
1010: * @exception IllegalArgumentException if <code>src</code>
1011: * is a value other than <code>COMBINE_OBJECT_COLOR</code>,
1012: * <code>COMBINE_TEXTURE_COLOR</code>,
1013: * <code>COMBINE_CONSTANT_COLOR</code>, or
1014: * <code>COMBINE_PREVIOUS_TEXTURE_UNIT_STATE</code>
1015: * @exception CapabilityNotSetException if appropriate capability is
1016: * not set and this object is part of live or compiled scene graph
1017: *
1018: * @see Canvas3D#queryProperties
1019: *
1020: * @since Java 3D 1.3
1021: */
1022: public void setCombineAlphaSource(int index, int src) {
1023: if (isLiveOrCompiled()) {
1024: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
1025: throw new CapabilityNotSetException(J3dI18N
1026: .getString("TextureAttributes23"));
1027: }
1028: }
1029:
1030: if ((index < 0) || (index > 2)) {
1031: throw new IndexOutOfBoundsException(J3dI18N
1032: .getString("TextureAttributes25"));
1033: }
1034:
1035: if ((src < COMBINE_OBJECT_COLOR)
1036: || (src > COMBINE_PREVIOUS_TEXTURE_UNIT_STATE)) {
1037: throw new IllegalArgumentException(J3dI18N
1038: .getString("TextureAttributes26"));
1039: }
1040:
1041: if (isLive()) {
1042: ((TextureAttributesRetained) this .retained)
1043: .setCombineAlphaSource(index, src);
1044: } else {
1045: ((TextureAttributesRetained) this .retained)
1046: .initCombineAlphaSource(index, src);
1047: }
1048: }
1049:
1050: /**
1051: * Retrieves the source for the rgb components of the specified
1052: * color operand for this object.
1053: *
1054: * @param index color operand in the combine operation
1055: *
1056: * @return the source for the rgb components of the specified color
1057: * operand for this object
1058: *
1059: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1060: * <code>index</code> > 2
1061: * @exception CapabilityNotSetException if appropriate capability is
1062: * not set and this object is part of live or compiled scene graph
1063: *
1064: * @since Java 3D 1.3
1065: */
1066: public int getCombineRgbSource(int index) {
1067: if (isLiveOrCompiled()) {
1068: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1069: throw new CapabilityNotSetException(J3dI18N
1070: .getString("TextureAttributes22"));
1071: }
1072: }
1073:
1074: if ((index < 0) || (index > 2)) {
1075: throw new IndexOutOfBoundsException(J3dI18N
1076: .getString("TextureAttributes25"));
1077: }
1078:
1079: return ((TextureAttributesRetained) this .retained)
1080: .getCombineRgbSource(index);
1081: }
1082:
1083: /**
1084: * Retrieves the source for the alpha component of the specified
1085: * color operand for this object.
1086: *
1087: * @param index color operand in the combine operation
1088: *
1089: * @return the source for the alpha component of the specified color
1090: * operand for this object
1091: *
1092: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1093: * <code>index</code> > 2
1094: * @exception CapabilityNotSetException if appropriate capability is
1095: * not set and this object is part of live or compiled scene graph
1096: *
1097: * @since Java 3D 1.3
1098: */
1099: public int getCombineAlphaSource(int index) {
1100: if (isLiveOrCompiled()) {
1101: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1102: throw new CapabilityNotSetException(J3dI18N
1103: .getString("TextureAttributes24"));
1104: }
1105: }
1106:
1107: if ((index < 0) || (index > 2)) {
1108: throw new IndexOutOfBoundsException(J3dI18N
1109: .getString("TextureAttributes25"));
1110: }
1111:
1112: return ((TextureAttributesRetained) this .retained)
1113: .getCombineAlphaSource(index);
1114: }
1115:
1116: /**
1117: * Sets the function for the rgb components of the specified color operand
1118: * for this object.
1119: *
1120: * @param index color operand in the combine operation
1121: * @param function the color function, one of:
1122: * <code>COMBINE_SRC_COLOR</code>,
1123: * <code>COMBINE_ONE_MINUS_SRC_COLOR</code>,
1124: * <code>COMBINE_SRC_ALPHA</code>, or
1125: * <code>COMBINE_ONE_MINUS_SRC_ALPHA</code>
1126: *
1127: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1128: * <code>index</code> > 2
1129: * @exception IllegalArgumentException if <code>function</code>
1130: * is a value other than <code>COMBINE_SRC_COLOR</code>,
1131: * <code>COMBINE_ONE_MINUS_SRC_COLOR</code>,
1132: * <code>COMBINE_SRC_ALPHA</code>, or
1133: * <code>COMBINE_ONE_MINUS_SRC_ALPHA</code>
1134: * @exception CapabilityNotSetException if appropriate capability is
1135: * not set and this object is part of live or compiled scene graph
1136: *
1137: * @see Canvas3D#queryProperties
1138: *
1139: * @since Java 3D 1.3
1140: */
1141: public void setCombineRgbFunction(int index, int function) {
1142: if (isLiveOrCompiled()) {
1143: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
1144: throw new CapabilityNotSetException(J3dI18N
1145: .getString("TextureAttributes27"));
1146: }
1147: }
1148:
1149: if ((index < 0) || (index > 2)) {
1150: throw new IndexOutOfBoundsException(J3dI18N
1151: .getString("TextureAttributes25"));
1152: }
1153:
1154: if ((function < COMBINE_SRC_COLOR)
1155: || (function > COMBINE_ONE_MINUS_SRC_ALPHA)) {
1156: throw new IllegalArgumentException(J3dI18N
1157: .getString("TextureAttributes31"));
1158: }
1159:
1160: if (isLive()) {
1161: ((TextureAttributesRetained) this .retained)
1162: .setCombineRgbFunction(index, function);
1163: } else {
1164: ((TextureAttributesRetained) this .retained)
1165: .initCombineRgbFunction(index, function);
1166: }
1167: }
1168:
1169: /**
1170: * Sets the function for the alpha component of the specified color operand
1171: * for this object.
1172: *
1173: * @param index color operand in the combine operation
1174: * @param function the color function, one of:
1175: * <code>COMBINE_SRC_ALPHA</code>, or
1176: * <code>COMBINE_ONE_MINUS_SRC_ALPHA</code>
1177: *
1178: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1179: * <code>index</code> > 2
1180: * @exception IllegalArgumentException if <code>function</code>
1181: * is a value other than
1182: * <code>COMBINE_SRC_ALPHA</code> or
1183: * <code>COMBINE_ONE_MINUS_SRC_ALPHA</code>
1184: * @exception CapabilityNotSetException if appropriate capability is
1185: * not set and this object is part of live or compiled scene graph
1186: *
1187: * @see Canvas3D#queryProperties
1188: *
1189: * @since Java 3D 1.3
1190: */
1191: public void setCombineAlphaFunction(int index, int function) {
1192: if (isLiveOrCompiled()) {
1193: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
1194: throw new CapabilityNotSetException(J3dI18N
1195: .getString("TextureAttributes29"));
1196: }
1197: }
1198:
1199: if ((index < 0) || (index > 2)) {
1200: throw new IndexOutOfBoundsException(J3dI18N
1201: .getString("TextureAttributes25"));
1202: }
1203:
1204: if ((function < COMBINE_SRC_ALPHA)
1205: || (function > COMBINE_ONE_MINUS_SRC_ALPHA)) {
1206: throw new IllegalArgumentException(J3dI18N
1207: .getString("TextureAttributes31"));
1208: }
1209:
1210: if (isLive()) {
1211: ((TextureAttributesRetained) this .retained)
1212: .setCombineAlphaFunction(index, function);
1213: } else {
1214: ((TextureAttributesRetained) this .retained)
1215: .initCombineAlphaFunction(index, function);
1216: }
1217: }
1218:
1219: /**
1220: * Retrieves the function for the rgb components of the specified color
1221: * operand for this object.
1222: *
1223: * @param index color operand in the combine operation
1224: *
1225: * @return the function for the rgb components of the specified color
1226: * operand for this object.
1227: *
1228: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1229: * <code>index</code> > 2
1230: * @exception CapabilityNotSetException if appropriate capability is
1231: * not set and this object is part of live or compiled scene graph
1232: *
1233: * @since Java 3D 1.3
1234: */
1235: public int getCombineRgbFunction(int index) {
1236: if (isLiveOrCompiled()) {
1237: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1238: throw new CapabilityNotSetException(J3dI18N
1239: .getString("TextureAttributes28"));
1240: }
1241: }
1242:
1243: if ((index < 0) || (index > 2)) {
1244: throw new IndexOutOfBoundsException(J3dI18N
1245: .getString("TextureAttributes25"));
1246: }
1247:
1248: return ((TextureAttributesRetained) this .retained)
1249: .getCombineRgbFunction(index);
1250: }
1251:
1252: /**
1253: * Retrieves the function for the alpha component of the specified color
1254: * operand for this object.
1255: *
1256: * @param index color operand in the combine operation
1257: *
1258: * @return the function for the alpha component of the specified color
1259: * operand for this object.
1260: *
1261: * @exception IndexOutOfBoundsException if <code>index</code> < 0 or
1262: * <code>index</code> > 2
1263: * @exception CapabilityNotSetException if appropriate capability is
1264: * not set and this object is part of live or compiled scene graph
1265: *
1266: * @since Java 3D 1.3
1267: */
1268: public int getCombineAlphaFunction(int index) {
1269: if (isLiveOrCompiled()) {
1270: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1271: throw new CapabilityNotSetException(J3dI18N
1272: .getString("TextureAttributes30"));
1273: }
1274: }
1275:
1276: if ((index < 0) || (index > 2)) {
1277: throw new IndexOutOfBoundsException(J3dI18N
1278: .getString("TextureAttributes25"));
1279: }
1280:
1281: return ((TextureAttributesRetained) this .retained)
1282: .getCombineAlphaFunction(index);
1283: }
1284:
1285: /**
1286: * Sets the scale factor for the rgb components of the output color
1287: * for this object.
1288: *
1289: * @param scale the scale factor for the rgb components of the output
1290: * color. It must be one of the following: 1, 2, or 4.
1291: *
1292: * @exception IllegalArgumentException if <code>scale</code> is a
1293: * value other than 1, 2, or 4.
1294: * @exception CapabilityNotSetException if appropriate capability is
1295: * not set and this object is part of live or compiled scene graph
1296: *
1297: * @see Canvas3D#queryProperties
1298: *
1299: * @since Java 3D 1.3
1300: */
1301: public void setCombineRgbScale(int scale) {
1302: if (isLiveOrCompiled()) {
1303: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
1304: throw new CapabilityNotSetException(J3dI18N
1305: .getString("TextureAttributes32"));
1306: }
1307: }
1308:
1309: if ((scale != 1) && (scale != 2) && (scale != 4)) {
1310: throw new IllegalArgumentException(J3dI18N
1311: .getString("TextureAttributes36"));
1312: }
1313:
1314: if (isLive()) {
1315: ((TextureAttributesRetained) this .retained)
1316: .setCombineRgbScale(scale);
1317: } else {
1318: ((TextureAttributesRetained) this .retained)
1319: .initCombineRgbScale(scale);
1320: }
1321: }
1322:
1323: /**
1324: * Sets the scale factor for the alpha component of the output color
1325: * for this object.
1326: *
1327: * @param scale the scale factor for the alpha component of the output
1328: * color. It must be one of the following: 1, 2, or 4.
1329: *
1330: * @exception IllegalArgumentException if <code>scale</code> is a
1331: * value other than 1, 2, or 4.
1332: * @exception CapabilityNotSetException if appropriate capability is
1333: * not set and this object is part of live or compiled scene graph
1334: *
1335: * @see Canvas3D#queryProperties
1336: *
1337: * @since Java 3D 1.3
1338: */
1339: public void setCombineAlphaScale(int scale) {
1340: if (isLiveOrCompiled()) {
1341: if (!this .getCapability(ALLOW_COMBINE_WRITE)) {
1342: throw new CapabilityNotSetException(J3dI18N
1343: .getString("TextureAttributes34"));
1344: }
1345: }
1346:
1347: if ((scale != 1) && (scale != 2) && (scale != 4)) {
1348: throw new IllegalArgumentException(J3dI18N
1349: .getString("TextureAttributes36"));
1350: }
1351:
1352: if (isLive()) {
1353: ((TextureAttributesRetained) this .retained)
1354: .setCombineAlphaScale(scale);
1355: } else {
1356: ((TextureAttributesRetained) this .retained)
1357: .initCombineAlphaScale(scale);
1358: }
1359: }
1360:
1361: /**
1362: * Retrieves the scale factor for the rgb components of the output color
1363: * for this object.
1364: *
1365: * @return the scale factor for the rgb components of the output color
1366: *
1367: * @exception CapabilityNotSetException if appropriate capability is
1368: * not set and this object is part of live or compiled scene graph
1369: *
1370: * @since Java 3D 1.3
1371: */
1372: public int getCombineRgbScale() {
1373: if (isLiveOrCompiled()) {
1374: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1375: throw new CapabilityNotSetException(J3dI18N
1376: .getString("TextureAttributes33"));
1377: }
1378: }
1379:
1380: return ((TextureAttributesRetained) this .retained)
1381: .getCombineRgbScale();
1382: }
1383:
1384: /**
1385: * Retrieves the scale factor for the alpha component of the output color
1386: * for this object.
1387: *
1388: * @return the scale factor for the alpha component of the output color
1389: *
1390: * @exception CapabilityNotSetException if appropriate capability is
1391: * not set and this object is part of live or compiled scene graph
1392: *
1393: * @since Java 3D 1.3
1394: */
1395: public int getCombineAlphaScale() {
1396: if (isLiveOrCompiled()) {
1397: if (!this .getCapability(ALLOW_COMBINE_READ)) {
1398: throw new CapabilityNotSetException(J3dI18N
1399: .getString("TextureAttributes35"));
1400: }
1401: }
1402:
1403: return ((TextureAttributesRetained) this .retained)
1404: .getCombineAlphaScale();
1405: }
1406:
1407: /**
1408: * Creates a retained mode TextureAttributesRetained object that this
1409: * TextureAttributes component object will point to.
1410: */
1411: void createRetained() {
1412: this .retained = new TextureAttributesRetained();
1413: this .retained.setSource(this );
1414: }
1415:
1416: /**
1417: * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
1418: */
1419: public NodeComponent cloneNodeComponent() {
1420: TextureAttributes ta = new TextureAttributes();
1421: ta.duplicateNodeComponent(this );
1422: return ta;
1423: }
1424:
1425: /**
1426: * Copies all node information from <code>originalNodeComponent</code> into
1427: * the current node. This method is called from the
1428: * <code>duplicateNode</code> method. This routine does
1429: * the actual duplication of all "local data" (any data defined in
1430: * this object).
1431: *
1432: * @param originalNodeComponent the original node to duplicate.
1433: * @param forceDuplicate when set to <code>true</code>, causes the
1434: * <code>duplicateOnCloneTree</code> flag to be ignored. When
1435: * <code>false</code>, the value of each node's
1436: * <code>duplicateOnCloneTree</code> variable determines whether
1437: * NodeComponent data is duplicated or copied.
1438: *
1439: * @see Node#cloneTree
1440: * @see NodeComponent#setDuplicateOnCloneTree
1441: */
1442: void duplicateAttributes(NodeComponent originalNodeComponent,
1443: boolean forceDuplicate) {
1444:
1445: super
1446: .duplicateAttributes(originalNodeComponent,
1447: forceDuplicate);
1448:
1449: TextureAttributesRetained attr = (TextureAttributesRetained) originalNodeComponent.retained;
1450: TextureAttributesRetained rt = (TextureAttributesRetained) retained;
1451:
1452: Color4f c = new Color4f();
1453: attr.getTextureBlendColor(c);
1454: Transform3D t = new Transform3D();
1455: attr.getTextureTransform(t);
1456:
1457: rt.initTextureMode(attr.getTextureMode());
1458: rt.initPerspectiveCorrectionMode(attr
1459: .getPerspectiveCorrectionMode());
1460: rt.initTextureBlendColor(c);
1461: rt.initTextureTransform(t);
1462:
1463: if ((attr.getNumTextureColorTableComponents() != 0)
1464: && (attr.getTextureColorTableSize() != 0)) {
1465: int table[][] = new int[attr
1466: .getNumTextureColorTableComponents()][attr
1467: .getTextureColorTableSize()];
1468: attr.getTextureColorTable(table);
1469: rt.initTextureColorTable(table);
1470: }
1471: }
1472: }
|