View Javadoc

1   /* -------------------------------------------------------------------
2    * Java source file for the class TextureAttributes
3    * 
4    * Copyright (c), 2003, Masahiro Takatsuka.
5    * All Rights Researved.
6    * 
7    * Original Author: Masahiro Takatsuka (masa@jbeans.net)
8    * $Author: takatsukam $
9    * 
10   * $Date: 2004/03/03 11:53:06 $
11   * 
12   * $Id: TextureAttributes.java,v 1.3 2004/03/03 11:53:06 takatsukam Exp $
13   * 
14   * Reference:		Document no:
15   * ___				___
16   * 
17   * To Do:
18   * ___
19   * 
20  ------------------------------------------------------------------- */
21  
22  /* --------------------------- Package ---------------------------- */
23  package net.jbeans.j3d.scenegraph;
24  
25  /* ------------------ Import classes (packages) ------------------- *//package-summary/html">class="comment"> ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment"> ------------------ Import classes (packages) ------------------- */
26  import java.awt.*;
27  import java.io.*;
28  import java.lang.reflect.*;
29  import java.util.*;
30  import javax.swing.event.*;
31  import javax.media.j3d.Transform3D;
32  import javax.vecmath.*;
33  
34  import net.jbeans.lang.*;
35  import net.jbeans.util.*;
36  import net.jbeans.util.debug.*;
37  
38  /*====================================================================
39                Implementation of class TextureAttributes               
40  ====================================================================*/
41  /***
42   * generally describe TextureAttributes in here
43   * 
44   * @version $Revision: 1.3 $
45   * @author Masahiro Takatsuka (masa@jbeans.net)
46   * @see javax.media.j3d.TextureAttributes
47   * @see Serializable
48   */
49  
50  public class TextureAttributes extends javax.media.j3d.TextureAttributes implements Serializable {
51  	private static final boolean DEBUG = Debug.getDebugFlag(TextureAttributes.class);
52  
53  	/* ------------------------ not serialized ------------------------ */
54  	transient private Color4f tmpColor;
55  	
56  	public TextureAttributes() {
57  		super();
58  		initialize();
59  	}
60  
61  	public TextureAttributes(int textureMode, Transform3D transform, Color4f textureBlendColor, int perspCorrectionMode) {
62  		super(textureMode, transform, textureBlendColor, perspCorrectionMode);
63  
64  		initialize();
65  	}
66  	
67  	private final void initialize() {
68  		setCapabilities();
69  	}
70  
71  	private final void setCapabilities() {
72  		setCapability(ALLOW_BLEND_COLOR_READ);
73  		setCapability(ALLOW_BLEND_COLOR_WRITE);		
74  		setCapability(ALLOW_COLOR_TABLE_READ);
75  		setCapability(ALLOW_COLOR_TABLE_WRITE);
76  //		setCapability(ALLOW_COMBINE_READ); // from 1.3
77  // 		setCapability(ALLOW_COMBINE_WRITE);// from 1.3
78  		setCapability(ALLOW_MODE_READ);
79  		setCapability(ALLOW_MODE_WRITE);
80  		setCapability(ALLOW_TRANSFORM_READ);
81  		setCapability(ALLOW_TRANSFORM_WRITE);
82  	}
83  
84      /***
85       * Serialization methods
86       */
87      private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
88  		initialize();
89      }
90  
91  	public void setTextureBlendColor(Color color) {
92  		if (color == null) {
93  			return;
94  		}
95  		if (this.tmpColor == null) {
96  			this.tmpColor = new Color4f(color);
97  		} else {
98  			this.tmpColor.set(color);
99  		}
100 		setTextureBlendColor(this.tmpColor);
101 	}
102 
103 	public Color getTextureBlendColor() {
104 		if (this.tmpColor == null) {
105 			this.tmpColor = new Color4f();
106 		}
107 		getTextureBlendColor(this.tmpColor);
108 
109 		return new Color(this.tmpColor.x, this.tmpColor.y, this.tmpColor.z, this.tmpColor.w);
110 	}
111 
112 	public Transform3D getTextureTransform() {
113 		Transform3D t3d = new Transform3D();
114 		getTextureTransform(t3d);
115 
116 		return t3d;
117 	}
118 }
119