Source Code Cross Referenced for TexCoordGeneration.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: TexCoordGeneration.java,v $
003:         *
004:         * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.6 $
028:         * $Date: 2008/02/28 20:17:31 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Vector4f;
035:
036:        /**
037:         * The TexCoordGeneration object contains all parameters needed for 
038:         * automatic texture coordinate generation.  It is included as part 
039:         * of an Appearance component object.
040:         * <p>
041:         * Texture coordinates determine which texel in the texture map is
042:         * assigned to a given vertex. Texture coordinates are interpolated
043:         * between vertices, similarly to how colors are interpolated between
044:         * two vertices of lines and polygons.
045:         * <p>
046:         * Texture coordinates consist of two, three or four coordinates.
047:         * These coordinates
048:         * are referred to as the <i>S</i>, <i>T</i>, <i>R</i>, and <i>Q</i>
049:         * coordinates.
050:         * 2D textures use the <i>S</i> and <i>T</i> coordinates. 3D textures
051:         * use the <i>S</i>, <i>T</i> and <i>R</i> coordinates. The <i>Q</i>
052:         * coordinate, similar to the <i>w</i> coordinate of the <i>(x, y, z, w)</i>
053:         * object coordinates, is used to create homogeneous coordinates.
054:         * <p>
055:         * Rather than the programmer having to explicitly assign texture 
056:         * coordinates, Java 3D can automatically generate the texture
057:         * coordinates to achieve texture mapping onto contours.
058:         * The TexCoordGeneration attributes specify the functions for automatically
059:         * generating texture coordinates. The texture attributes that can be 
060:         * defined are:
061:         * <p><ul>
062:         * <li>Texture format - defines whether the generated texture 
063:         * coordinates are 2D, 3D, or 4D:<p>
064:         * <ul>
065:         * <li>TEXTURE_COORDINATE_2 - generates 2D texture coordinates 
066:         * (S and T).<p>
067:         * <li>TEXTURE_COORDINATE_3 - generates 3D texture coordinates
068:         * (S, T, and R).<p>
069:         * <li>TEXTURE_COORDINATE_4 - generates 4D texture coordinates
070:         * (S, T, R, and Q).<p>
071:         * </ul>
072:         * <li>Texture generation mode - defines how the texture coordinates
073:         * are generated:<p>
074:         * <ul>
075:         * <li>OBJECT_LINEAR - texture coordinates are generated as a linear
076:         * function in object coordinates. The function used is:<p>
077:         * <ul>
078:         * <code>g = p<sub>1</sub>x<sub>o</sub> + p<sub>2</sub>y<sub>o</sub> + p<sub>3</sub>z<sub>o</sub> + p<sub>4</sub>w<sub>o</sub></code>
079:         * <p>
080:         * where<br>
081:         * <ul><code>g</code> is the value computed for the coordinate.<br>
082:         * <code>p<sub>1</sub></code>, <code>p<sub>2</sub></code>,
083:         * <code>p<sub>3</sub></code>, and <code>p<sub>4</sub></code>
084:         * are the plane equation coefficients (described below).<br>
085:         * x<sub>o</sub>, y<sub>o</sub>, z<sub>o</sub>, and w<sub>o</sub> are
086:         * the object coordinates of the vertex.<p>
087:         * </ul></ul>
088:         * <li>EYE_LINEAR - texture coordinates are generated as a linear
089:         * function in eye coordinates. The function used is:<p>
090:         * <ul>
091:         * <code>g = p<sub>1</sub>'x<sub>e</sub> + p<sub>2</sub>'y<sub>e</sub> + p<sub>3</sub>'z<sub>e</sub> + p<sub>4</sub>'w<sub>e</sub></code>
092:         * <p>
093:         * where<br>
094:         * <ul><code>x<sub>e</sub></code>, <code>y<sub>e</sub></code>,
095:         * <code>z<sub>e</sub></code>, and w<sub>e</sub></code> are the eye
096:         * coordinates of the vertex.<br>
097:         * <code>p<sub>1</sub>'</code>, <code>p<sub>2</sub>'</code>,
098:         * <code>p<sub>3</sub>'</code>, and <code>p<sub>4</sub>'</code>
099:         * are the plane equation coefficients transformed into eye
100:         * coordinates.<p>
101:         * </ul></ul>
102:         * 
103:         * <li>SPHERE_MAP - texture coordinates are generated using 
104:         * spherical reflection mapping in eye coordinates. Used to simulate
105:         * the reflected image of a spherical environment onto a polygon.<p>
106:         *
107:         * <li>NORMAL_MAP - texture coordinates are generated to match 
108:         * vertices' normals in eye coordinates. This is only available if
109:         * TextureCubeMap is available.
110:         * </li><p>
111:         *
112:         * <li>REFLECTION_MAP - texture coordinates are generated to match
113:         * vertices' reflection vectors in eye coordinates. This is only available
114:         * if TextureCubeMap is available.
115:         * </li><p>
116:         * </ul>
117:         * <li>Plane equation coefficients - defines the coefficients for the 
118:         * plane equations used to generate the coordinates in the 
119:         * OBJECT_LINEAR and EYE_LINEAR texture generation modes.
120:         * The coefficients define a reference plane in either object coordinates
121:         * or in eye coordinates, depending on the texture generation mode.
122:         * <p>
123:         * The equation coefficients are set by the <code>setPlaneS</code>,
124:         * <code>setPlaneT</code>, <code>setPlaneR</code>, and <code>setPlaneQ</code>
125:         * methods for each of the S, T, R, and Q coordinate functions, respectively.
126:         * By default the equation coefficients are set as follows:<p>
127:         * <ul>
128:         * plane S = (1.0, 0.0, 0.0, 0.0)<br>
129:         * plane T = (0.0, 1.0, 0.0, 0.0)<br>
130:         * plane R = (0.0, 0.0, 0.0, 0.0)<br>
131:         * plane Q = (0.0, 0.0, 0.0, 0.0)<p>
132:         * </ul></ul>
133:         * Texture coordinate generation is enabled or disabled by the
134:         * <code>setEnable</code> method. When enabled, the specified
135:         * texture coordinate is computed according to the generating function
136:         * associated with the coordinate. When disabled, subsequent vertices
137:         * take the specified texture coordinate from the current set of
138:         * texture coordinates.<p>
139:         *
140:         * @see Canvas3D#queryProperties
141:         */
142:        public class TexCoordGeneration extends NodeComponent {
143:
144:            /**
145:             * Specifies that this TexCoordGeneration object allows reading its
146:             * enable flag.
147:             */
148:            public static final int ALLOW_ENABLE_READ = CapabilityBits.TEX_COORD_GENERATION_ALLOW_ENABLE_READ;
149:
150:            /**
151:             * Specifies that this TexCoordGeneration object allows writing its
152:             * enable flag.
153:             */
154:            public static final int ALLOW_ENABLE_WRITE = CapabilityBits.TEX_COORD_GENERATION_ALLOW_ENABLE_WRITE;
155:
156:            /**
157:             * Specifies that this TexCoordGeneration object allows reading its
158:             * format information.
159:             */
160:            public static final int ALLOW_FORMAT_READ = CapabilityBits.TEX_COORD_GENERATION_ALLOW_FORMAT_READ;
161:
162:            /**
163:             * Specifies that this TexCoordGeneration object allows reading its
164:             * mode information.
165:             */
166:            public static final int ALLOW_MODE_READ = CapabilityBits.TEX_COORD_GENERATION_ALLOW_MODE_READ;
167:
168:            /**
169:             * Specifies that this TexCoordGeneration object allows reading its
170:             * planeS, planeR, and planeT component information.
171:             */
172:            public static final int ALLOW_PLANE_READ = CapabilityBits.TEX_COORD_GENERATION_ALLOW_PLANE_READ;
173:
174:            /**
175:             * Specifies that this TexCoordGeneration object allows writing its
176:             * planeS, planeR, and planeT component information.
177:             *
178:             * @since Java 3D 1.3
179:             */
180:            public static final int ALLOW_PLANE_WRITE = CapabilityBits.TEX_COORD_GENERATION_ALLOW_PLANE_WRITE;
181:
182:            /**
183:             * Generates texture coordinates as a linear function in
184:             * object coordinates.
185:             *
186:             * @see #setGenMode
187:             */
188:            public static final int OBJECT_LINEAR = 0;
189:            /**
190:             * Generates texture coordinates as a linear function in
191:             * eye coordinates.
192:             *
193:             * @see #setGenMode
194:             */
195:            public static final int EYE_LINEAR = 1;
196:            /**
197:             * Generates texture coordinates using a spherical reflection
198:             * mapping in eye coordinates.
199:             *
200:             * @see #setGenMode
201:             */
202:            public static final int SPHERE_MAP = 2;
203:            /**
204:             * Generates texture coordinates that match vertices' normals in
205:             * eye coordinates.
206:             *
207:             * @see #setGenMode
208:             * @see Canvas3D#queryProperties
209:             *
210:             * @since Java 3D 1.3
211:             */
212:            public static final int NORMAL_MAP = 3;
213:            /**
214:             * Generates texture coordinates that match vertices' reflection
215:             * vectors in eye coordinates.
216:             *
217:             * @see #setGenMode
218:             * @see Canvas3D#queryProperties
219:             *
220:             * @since Java 3D 1.3
221:             */
222:            public static final int REFLECTION_MAP = 4;
223:
224:            // Definitions for format
225:            /**
226:             * Generates 2D texture coordinates (S and T).
227:             *
228:             * @see #setFormat
229:             */
230:            public static final int TEXTURE_COORDINATE_2 = 0;
231:            /**
232:             * Generates 3D texture coordinates (S, T, and R).
233:             *
234:             * @see #setFormat
235:             */
236:            public static final int TEXTURE_COORDINATE_3 = 1;
237:            /**
238:             * Generates 4D texture coordinates (S, T, R, and Q).
239:             *
240:             * @see #setFormat
241:             *
242:             * @since Java 3D 1.3
243:             */
244:            public static final int TEXTURE_COORDINATE_4 = 2;
245:
246:            // Array for setting default read capabilities
247:            private static final int[] readCapabilities = { ALLOW_ENABLE_READ,
248:                    ALLOW_FORMAT_READ, ALLOW_MODE_READ, ALLOW_PLANE_READ };
249:
250:            /**
251:             * Constructs a TexCoordGeneration object with default parameters.
252:             * The default values are as follows:
253:             * <ul>
254:             * enable flag : true<br>
255:             * texture generation mode : OBJECT_LINEAR<br>
256:             * format : TEXTURE_COORDINATE_2<br>
257:             * plane S : (1,0,0,0)<br>
258:             * plane T : (0,1,0,0)<br>
259:             * plane R : (0,0,0,0)<br>
260:             * plane Q : (0,0,0,0)<br>
261:             * </ul>
262:             */
263:            public TexCoordGeneration() {
264:                // Just use the defaults
265:                // set default read capabilities
266:                setDefaultReadCapabilities(readCapabilities);
267:            }
268:
269:            /**
270:             * Constructs a TexCoordGeneration object with the specified genMode and
271:             * format.
272:             * Defaults will be used for the rest of the state variables.
273:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
274:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP
275:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
276:             * TEXTURE_COORDINATE_3, or TEXTURE_COORDINATE_4
277:             *
278:             * @see Canvas3D#queryProperties
279:             */
280:            public TexCoordGeneration(int genMode, int format) {
281:                // set default read capabilities
282:                setDefaultReadCapabilities(readCapabilities);
283:
284:                ((TexCoordGenerationRetained) this .retained)
285:                        .initGenMode(genMode);
286:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
287:            }
288:
289:            /**
290:             * Constructs a TexCoordGeneration object with the specified genMode,
291:             * format, and the S coordinate plane equation.
292:             * Defaults will be used for the rest of the state variables.
293:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
294:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP
295:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
296:             * TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4
297:             * @param planeS plane equation for the S coordinate
298:             *
299:             * @see Canvas3D#queryProperties
300:             */
301:            public TexCoordGeneration(int genMode, int format, Vector4f planeS) {
302:                // set default read capabilities
303:                setDefaultReadCapabilities(readCapabilities);
304:
305:                ((TexCoordGenerationRetained) this .retained)
306:                        .initGenMode(genMode);
307:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
308:                ((TexCoordGenerationRetained) this .retained).initPlaneS(planeS);
309:            }
310:
311:            /**
312:             * Constructs a TexCoordGeneration object with the specified genMode,
313:             * format, and the S and T coordinate plane equations.
314:             * Defaults will be used for the rest of the state variables.
315:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
316:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP
317:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
318:             * TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4
319:             * @param planeS plane equation for the S coordinate
320:             * @param planeT plane equation for the T coordinate
321:             *
322:             * @see Canvas3D#queryProperties
323:             */
324:            public TexCoordGeneration(int genMode, int format, Vector4f planeS,
325:                    Vector4f planeT) {
326:                // set default read capabilities
327:                setDefaultReadCapabilities(readCapabilities);
328:
329:                ((TexCoordGenerationRetained) this .retained)
330:                        .initGenMode(genMode);
331:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
332:                ((TexCoordGenerationRetained) this .retained).initPlaneS(planeS);
333:                ((TexCoordGenerationRetained) this .retained).initPlaneT(planeT);
334:            }
335:
336:            /**
337:             * Constructs a TexCoordGeneration object with the specified genMode,
338:             * format, and the S, T, and R coordinate plane equations.
339:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
340:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP
341:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
342:             * TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4
343:             * @param planeS plane equation for the S coordinate
344:             * @param planeT plane equation for the T coordinate
345:             * @param planeR plane equation for the R coordinate
346:             *
347:             * @see Canvas3D#queryProperties
348:             */
349:            public TexCoordGeneration(int genMode, int format, Vector4f planeS,
350:                    Vector4f planeT, Vector4f planeR) {
351:                // set default read capabilities
352:                setDefaultReadCapabilities(readCapabilities);
353:
354:                ((TexCoordGenerationRetained) this .retained)
355:                        .initGenMode(genMode);
356:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
357:                ((TexCoordGenerationRetained) this .retained).initPlaneS(planeS);
358:                ((TexCoordGenerationRetained) this .retained).initPlaneT(planeT);
359:                ((TexCoordGenerationRetained) this .retained).initPlaneR(planeR);
360:            }
361:
362:            /**
363:             * Constructs a TexCoordGeneration object with the specified genMode,
364:             * format, and the S, T, R, and Q coordinate plane equations.
365:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
366:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP
367:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
368:             * TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4
369:             * @param planeS plane equation for the S coordinate
370:             * @param planeT plane equation for the T coordinate
371:             * @param planeR plane equation for the R coordinate
372:             * @param planeQ plane equation for the Q coordinate
373:             *
374:             * @see Canvas3D#queryProperties
375:             *
376:             * @since Java 3D 1.3
377:             */
378:            public TexCoordGeneration(int genMode, int format, Vector4f planeS,
379:                    Vector4f planeT, Vector4f planeR, Vector4f planeQ) {
380:                // set default read capabilities
381:                setDefaultReadCapabilities(readCapabilities);
382:
383:                ((TexCoordGenerationRetained) this .retained)
384:                        .initGenMode(genMode);
385:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
386:                ((TexCoordGenerationRetained) this .retained).initPlaneS(planeS);
387:                ((TexCoordGenerationRetained) this .retained).initPlaneT(planeT);
388:                ((TexCoordGenerationRetained) this .retained).initPlaneR(planeR);
389:                ((TexCoordGenerationRetained) this .retained).initPlaneQ(planeQ);
390:            }
391:
392:            /**
393:             * Enables or disables texture coordinate generation for this
394:             * appearance component object.
395:             * @param state true or false to enable or disable texture coordinate
396:             * generation
397:             * @exception CapabilityNotSetException if appropriate capability is
398:             * not set and this object is part of live or compiled scene graph
399:             */
400:            public void setEnable(boolean state) {
401:                if (isLiveOrCompiled())
402:                    if (!this .getCapability(ALLOW_ENABLE_WRITE))
403:                        throw new CapabilityNotSetException(J3dI18N
404:                                .getString("TexCoordGeneration0"));
405:                if (isLive())
406:                    ((TexCoordGenerationRetained) this .retained)
407:                            .setEnable(state);
408:                else
409:                    ((TexCoordGenerationRetained) this .retained)
410:                            .initEnable(state);
411:            }
412:
413:            /**
414:             * Retrieves the state of the texCoordGeneration enable flag.
415:             * @return true if texture coordinate generation is enabled,
416:             * false if texture coordinate generation is disabled
417:             * @exception CapabilityNotSetException if appropriate capability is
418:             * not set and this object is part of live or compiled scene graph
419:             */
420:            public boolean getEnable() {
421:                if (isLiveOrCompiled())
422:                    if (!this .getCapability(ALLOW_ENABLE_READ))
423:                        throw new CapabilityNotSetException(J3dI18N
424:                                .getString("TexCoordGeneration1"));
425:                return ((TexCoordGenerationRetained) this .retained).getEnable();
426:            }
427:
428:            /**
429:             * Sets the TexCoordGeneration format to the specified value.
430:             * @param format texture format, one of: TEXTURE_COORDINATE_2,
431:             * TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4
432:             * @exception RestrictedAccessException if the method is called
433:             * when this object is part of live or compiled scene graph.
434:             */
435:            public void setFormat(int format) {
436:                checkForLiveOrCompiled();
437:                ((TexCoordGenerationRetained) this .retained).initFormat(format);
438:
439:            }
440:
441:            /**
442:             * Retrieves the current TexCoordGeneration format.
443:             * @return the texture format
444:             * @exception CapabilityNotSetException if appropriate capability is
445:             * not set and this object is part of live or compiled scene graph
446:             */
447:            public int getFormat() {
448:                if (isLiveOrCompiled())
449:                    if (!this .getCapability(ALLOW_FORMAT_READ))
450:                        throw new CapabilityNotSetException(J3dI18N
451:                                .getString("TexCoordGeneration2"));
452:                return ((TexCoordGenerationRetained) this .retained).getFormat();
453:            }
454:
455:            /**
456:             * Sets the TexCoordGeneration generation mode to the specified value.
457:             * @param genMode texture generation mode, one of: OBJECT_LINEAR,
458:             * EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP.
459:             * @exception RestrictedAccessException if the method is called
460:             * when this object is part of live or compiled scene graph.
461:             *
462:             * @exception IllegalArgumentException if <code>genMode</code> is
463:             * a value other than <code>OBJECT_LINEAR</code>, <code>EYE_LINEAR</code>,
464:             * <code>SPHERE_MAP</code>, <code>NORMAL_MAP</code>, or 
465:             * <code>REFLECTION_MAP</code>.
466:             *
467:             * @see Canvas3D#queryProperties
468:             */
469:            public void setGenMode(int genMode) {
470:                checkForLiveOrCompiled();
471:
472:                if ((genMode < OBJECT_LINEAR) || (genMode > REFLECTION_MAP)) {
473:                    throw new IllegalArgumentException(J3dI18N
474:                            .getString("TexCoordGeneration5"));
475:                }
476:                ((TexCoordGenerationRetained) this .retained)
477:                        .initGenMode(genMode);
478:            }
479:
480:            /**
481:             * Retrieves the current TexCoordGeneration generation mode.
482:             * @return the texture generation mode
483:             * @exception CapabilityNotSetException if appropriate capability is
484:             * not set and this object is part of live or compiled scene graph
485:             */
486:            public int getGenMode() {
487:                if (isLiveOrCompiled())
488:                    if (!this .getCapability(ALLOW_MODE_READ))
489:                        throw new CapabilityNotSetException(J3dI18N
490:                                .getString("TexCoordGeneration3"));
491:                return ((TexCoordGenerationRetained) this .retained)
492:                        .getGenMode();
493:            }
494:
495:            /**
496:             * Sets the S coordinate plane equation.  This plane equation
497:             * is used to generate the S coordinate in OBJECT_LINEAR and EYE_LINEAR
498:             * texture generation modes.
499:             * @param planeS plane equation for the S coordinate
500:             * @exception CapabilityNotSetException if appropriate capability is 
501:             * not set and this object is part of live or compiled scene graph
502:             */
503:            public void setPlaneS(Vector4f planeS) {
504:                if (isLiveOrCompiled())
505:                    if (!this .getCapability(ALLOW_PLANE_WRITE))
506:                        throw new CapabilityNotSetException(J3dI18N
507:                                .getString("TexCoordGeneration6"));
508:
509:                if (isLive())
510:                    ((TexCoordGenerationRetained) this .retained)
511:                            .setPlaneS(planeS);
512:                else
513:                    ((TexCoordGenerationRetained) this .retained)
514:                            .initPlaneS(planeS);
515:            }
516:
517:            /**
518:             * Retrieves a copy of the plane equation used to
519:             * generate the S coordinate.
520:             * @param planeS the S coordinate plane equation
521:             * @exception CapabilityNotSetException if appropriate capability is
522:             * not set and this object is part of live or compiled scene graph
523:             */
524:            public void getPlaneS(Vector4f planeS) {
525:                if (isLiveOrCompiled())
526:                    if (!this .getCapability(ALLOW_PLANE_READ))
527:                        throw new CapabilityNotSetException(J3dI18N
528:                                .getString("TexCoordGeneration4"));
529:                ((TexCoordGenerationRetained) this .retained).getPlaneS(planeS);
530:            }
531:
532:            /**
533:             * Sets the T coordinate plane equation.  This plane equation
534:             * is used to generate the T coordinate in OBJECT_LINEAR and EYE_LINEAR
535:             * texture generation modes.
536:             * @param planeT plane equation for the T coordinate
537:             * @exception CapabilityNotSetException if appropriate capability is 
538:             * not set and this object is part of live or compiled scene graph
539:             */
540:            public void setPlaneT(Vector4f planeT) {
541:                if (isLiveOrCompiled())
542:                    if (!this .getCapability(ALLOW_PLANE_WRITE))
543:                        throw new CapabilityNotSetException(J3dI18N
544:                                .getString("TexCoordGeneration6"));
545:
546:                if (isLive())
547:                    ((TexCoordGenerationRetained) this .retained)
548:                            .setPlaneT(planeT);
549:                else
550:                    ((TexCoordGenerationRetained) this .retained)
551:                            .initPlaneT(planeT);
552:            }
553:
554:            /**
555:             * Retrieves a copy of the plane equation used to
556:             * generate the T coordinate.
557:             * @param planeT the T coordinate plane equation
558:             * @exception CapabilityNotSetException if appropriate capability is
559:             * not set and this object is part of live or compiled scene graph
560:             */
561:            public void getPlaneT(Vector4f planeT) {
562:                if (isLiveOrCompiled())
563:                    if (!this .getCapability(ALLOW_PLANE_READ))
564:                        throw new CapabilityNotSetException(J3dI18N
565:                                .getString("TexCoordGeneration4"));
566:                ((TexCoordGenerationRetained) this .retained).getPlaneT(planeT);
567:            }
568:
569:            /**
570:             * Sets the R coordinate plane equation.  This plane equation
571:             * is used to generate the R coordinate in OBJECT_LINEAR and EYE_LINEAR
572:             * texture generation modes.
573:             * @param planeR plane equation for the R coordinate
574:             * @exception CapabilityNotSetException if appropriate capability is 
575:             * not set and this object is part of live or compiled scene graph
576:             */
577:            public void setPlaneR(Vector4f planeR) {
578:                if (isLiveOrCompiled())
579:                    if (!this .getCapability(ALLOW_PLANE_WRITE))
580:                        throw new CapabilityNotSetException(J3dI18N
581:                                .getString("TexCoordGeneration6"));
582:
583:                if (isLive())
584:                    ((TexCoordGenerationRetained) this .retained)
585:                            .setPlaneR(planeR);
586:                else
587:                    ((TexCoordGenerationRetained) this .retained)
588:                            .initPlaneR(planeR);
589:            }
590:
591:            /**
592:             * Retrieves a copy of the plane equation used to
593:             * generate the R coordinate.
594:             * @param planeR the R coordinate plane equation
595:             * @exception CapabilityNotSetException if appropriate capability is
596:             * not set and this object is part of live or compiled scene graph
597:             */
598:            public void getPlaneR(Vector4f planeR) {
599:                if (isLiveOrCompiled())
600:                    if (!this .getCapability(ALLOW_PLANE_READ))
601:                        throw new CapabilityNotSetException(J3dI18N
602:                                .getString("TexCoordGeneration4"));
603:                ((TexCoordGenerationRetained) this .retained).getPlaneR(planeR);
604:            }
605:
606:            /**
607:             * Sets the Q coordinate plane equation.  This plane equation
608:             * is used to generate the Q coordinate in OBJECT_LINEAR and EYE_LINEAR
609:             * texture generation modes.
610:             * @param planeQ plane equation for the Q coordinate
611:             * @exception CapabilityNotSetException if appropriate capability is 
612:             * not set and this object is part of live or compiled scene graph
613:             *
614:             * @since Java 3D 1.3
615:             */
616:            public void setPlaneQ(Vector4f planeQ) {
617:                if (isLiveOrCompiled())
618:                    if (!this .getCapability(ALLOW_PLANE_WRITE))
619:                        throw new CapabilityNotSetException(J3dI18N
620:                                .getString("TexCoordGeneration6"));
621:
622:                if (isLive())
623:                    ((TexCoordGenerationRetained) this .retained)
624:                            .setPlaneQ(planeQ);
625:                else
626:                    ((TexCoordGenerationRetained) this .retained)
627:                            .initPlaneQ(planeQ);
628:            }
629:
630:            /**
631:             * Retrieves a copy of the plane equation used to
632:             * generate the Q coordinate.
633:             * @param planeQ the Q coordinate plane equation
634:             * @exception CapabilityNotSetException if appropriate capability is
635:             * not set and this object is part of live or compiled scene graph
636:             *
637:             * @since Java 3D 1.3
638:             */
639:            public void getPlaneQ(Vector4f planeQ) {
640:                if (isLiveOrCompiled())
641:                    if (!this .getCapability(ALLOW_PLANE_READ))
642:                        throw new CapabilityNotSetException(J3dI18N
643:                                .getString("TexCoordGeneration4"));
644:                ((TexCoordGenerationRetained) this .retained).getPlaneQ(planeQ);
645:            }
646:
647:            /**
648:             * Creates a retained mode TexCoordGenerationRetained object that this
649:             * TexCoordGeneration component object will point to.
650:             */
651:            void createRetained() {
652:                this .retained = new TexCoordGenerationRetained();
653:                this .retained.setSource(this );
654:            }
655:
656:            /**
657:             * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)  
658:             */
659:            public NodeComponent cloneNodeComponent() {
660:                TexCoordGeneration tga = new TexCoordGeneration();
661:                tga.duplicateNodeComponent(this );
662:                return tga;
663:            }
664:
665:            /**
666:             * Copies all node information from <code>originalNodeComponent</code> into
667:             * the current node.  This method is called from the
668:             * <code>duplicateNode</code> method. This routine does
669:             * the actual duplication of all "local data" (any data defined in
670:             * this object). 
671:             *
672:             * @param originalNodeComponent the original node to duplicate.
673:             * @param forceDuplicate when set to <code>true</code>, causes the
674:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
675:             *  <code>false</code>, the value of each node's
676:             *  <code>duplicateOnCloneTree</code> variable determines whether
677:             *  NodeComponent data is duplicated or copied.
678:             *
679:             * @see Node#cloneTree
680:             * @see NodeComponent#setDuplicateOnCloneTree
681:             */
682:
683:            void duplicateAttributes(NodeComponent originalNodeComponent,
684:                    boolean forceDuplicate) {
685:
686:                super 
687:                        .duplicateAttributes(originalNodeComponent,
688:                                forceDuplicate);
689:
690:                TexCoordGenerationRetained tex = (TexCoordGenerationRetained) originalNodeComponent.retained;
691:                TexCoordGenerationRetained rt = (TexCoordGenerationRetained) retained;
692:
693:                Vector4f v = new Vector4f();
694:
695:                rt.initGenMode(tex.getGenMode());
696:                tex.getPlaneS(v);
697:                rt.initPlaneS(v);
698:                tex.getPlaneT(v);
699:                rt.initPlaneT(v);
700:                tex.getPlaneR(v);
701:                rt.initPlaneR(v);
702:                tex.getPlaneQ(v);
703:                rt.initPlaneQ(v);
704:                rt.initFormat(tex.getFormat());
705:                rt.initEnable(tex.getEnable());
706:            }
707:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.