Source Code Cross Referenced for TextureCubeMapRetained.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: TextureCubeMapRetained.java,v $
003:         *
004:         * Copyright 2001-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.8 $
028:         * $Date: 2008/02/28 20:17:32 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.*;
035:        import javax.vecmath.Color4f;
036:        import java.awt.image.DataBuffer;
037:        import java.awt.image.DataBufferByte;
038:
039:        /**
040:         * TextureCubeMap is a subclass of Texture class.
041:         */
042:        class TextureCubeMapRetained extends TextureRetained {
043:
044:            static final int NUMFACES = 6;
045:
046:            void initialize(int format, int width, int widPower, int height,
047:                    int heiPower, int mipmapMode, int boundaryWidth) {
048:
049:                this .numFaces = 6;
050:
051:                super .initialize(format, width, widPower, height, heiPower,
052:                        mipmapMode, boundaryWidth);
053:            }
054:
055:            /**
056:             * Sets a specified mipmap level for a particular face of the cubemap.
057:             */
058:            void initImage(int level, int face, ImageComponent image) {
059:
060:                // Issue 172 : call checkImageSize even for non-live setImage calls
061:                checkImageSize(level, image);
062:
063:                if (this .images == null) {
064:                    throw new IllegalArgumentException(J3dI18N
065:                            .getString("TextureRetained0"));
066:                }
067:
068:                if (image instanceof  ImageComponent3D) {
069:                    throw new IllegalArgumentException(J3dI18N
070:                            .getString("TextureCubeMap3"));
071:                }
072:
073:                if (face < TextureCubeMap.POSITIVE_X
074:                        || face > TextureCubeMap.NEGATIVE_Z) {
075:                    throw new IllegalArgumentException(J3dI18N
076:                            .getString("TextureCubeMap4"));
077:                }
078:
079:                if (this .source.isLive()) {
080:                    if (this .images[face][level] != null) {
081:                        this .images[face][level].clearLive(refCount);
082:                    }
083:
084:                    if (image != null) {
085:                        ((ImageComponentRetained) image.retained).setLive(
086:                                inBackgroundGroup, refCount);
087:                    }
088:                }
089:
090:                /*  Don't think this is needed.   --- Chien.
091:                 ((ImageComponent2DRetained)image.retained).setTextureRef();
092:                 */
093:
094:                if (image != null) {
095:                    this .images[face][level] = (ImageComponentRetained) image.retained;
096:                } else {
097:                    this .images[face][level] = null;
098:                }
099:            }
100:
101:            final void setImage(int level, int face, ImageComponent image) {
102:
103:                initImage(level, face, image);
104:
105:                Object arg[] = new Object[3];
106:                arg[0] = new Integer(level);
107:                arg[1] = image;
108:                arg[2] = new Integer(face);
109:                sendMessage(IMAGE_CHANGED, arg);
110:
111:                // If the user has set enable to true, then if the image is null
112:                // turn off texture enable
113:                if (userSpecifiedEnable) {
114:                    enable = userSpecifiedEnable;
115:                    if (image != null && level < maxLevels) {
116:                        ImageComponentRetained img = (ImageComponentRetained) image.retained;
117:                        if (img.isByReference()) {
118:                            if (img.getRefImage(0) == null) {
119:                                enable = false;
120:                            }
121:                        } else {
122:                            if (img.getImageData(isUseAsRaster()).get() == null) {
123:                                enable = false;
124:                            }
125:                        }
126:                        if (!enable)
127:                            sendMessage(ENABLE_CHANGED, Boolean.FALSE);
128:                    }
129:                }
130:            }
131:
132:            void initImages(int face, ImageComponent[] images) {
133:
134:                if (images.length != maxLevels)
135:                    throw new IllegalArgumentException(J3dI18N
136:                            .getString("Texture20"));
137:
138:                for (int i = 0; i < images.length; i++) {
139:                    initImage(i, face, images[i]);
140:                }
141:            }
142:
143:            final void setImages(int face, ImageComponent[] images) {
144:
145:                int i;
146:
147:                initImages(face, images);
148:
149:                ImageComponent[] imgs = new ImageComponent[images.length];
150:                for (i = 0; i < images.length; i++) {
151:                    imgs[i] = images[i];
152:                }
153:
154:                Object args[] = new Object[2];
155:                args[0] = imgs;
156:                args[1] = new Integer(face);
157:
158:                sendMessage(IMAGES_CHANGED, args);
159:                // If the user has set enable to true, then if the image is null
160:                // turn off texture enable
161:                if (userSpecifiedEnable) {
162:                    enable = userSpecifiedEnable;
163:                    i = 0;
164:                    while (enable && i < maxLevels) {
165:                        if (images[i] != null) {
166:                            ImageComponentRetained img = (ImageComponentRetained) images[i].retained;
167:                            if (img.isByReference()) {
168:                                if (img.getRefImage(0) == null) {
169:                                    enable = false;
170:                                }
171:                            } else {
172:                                if (img.getImageData(isUseAsRaster()).get() == null) {
173:                                    enable = false;
174:                                }
175:                            }
176:                        }
177:                        i++;
178:                    }
179:                    if (!enable) {
180:                        sendMessage(ENABLE_CHANGED, Boolean.FALSE);
181:                    }
182:                }
183:            }
184:
185:            /**
186:             * Gets a specified mipmap level of a particular face of the cube map.
187:             * @param level mipmap level to get
188:             * @param face face of the cube map
189:             * @return the pixel array object containing the texture image
190:             */
191:            final ImageComponent getImage(int level, int face) {
192:
193:                if (face < TextureCubeMap.POSITIVE_X
194:                        || face > TextureCubeMap.NEGATIVE_Z) {
195:                    throw new IllegalArgumentException(J3dI18N
196:                            .getString("TextureCubeMap4"));
197:                }
198:
199:                return (((images != null) && (images[face][level] != null)) ? (ImageComponent) images[face][level].source
200:                        : null);
201:            }
202:
203:            /**
204:             * Gets an array of image for a particular face of the cube map.
205:             * @param face face of the cube map
206:             * @return the pixel array object containing the texture image
207:             */
208:            final ImageComponent[] getImages(int face) {
209:
210:                if (images == null)
211:                    return null;
212:
213:                if (face < TextureCubeMap.POSITIVE_X
214:                        || face > TextureCubeMap.NEGATIVE_Z) {
215:                    throw new IllegalArgumentException(J3dI18N
216:                            .getString("TextureCubeMap4"));
217:                }
218:
219:                ImageComponent[] rImages = new ImageComponent[images[face].length];
220:                for (int i = 0; i < images[face].length; i++) {
221:                    if (images[face][i] != null)
222:                        rImages[i] = (ImageComponent) images[face][i].source;
223:                    else
224:                        rImages[i] = null;
225:                }
226:                return rImages;
227:            }
228:
229:            void bindTexture(Context ctx, int objectId, boolean enable) {
230:                Pipeline.getPipeline()
231:                        .bindTextureCubeMap(ctx, objectId, enable);
232:            }
233:
234:            void updateTextureBoundary(Context ctx, int boundaryModeS,
235:                    int boundaryModeT, float boundaryRed, float boundaryGreen,
236:                    float boundaryBlue, float boundaryAlpha) {
237:
238:                Pipeline.getPipeline().updateTextureCubeMapBoundary(ctx,
239:                        boundaryModeS, boundaryModeT, boundaryRed,
240:                        boundaryGreen, boundaryBlue, boundaryAlpha);
241:            }
242:
243:            void updateTextureFilterModes(Context ctx, int minFilter,
244:                    int magFilter) {
245:
246:                Pipeline.getPipeline().updateTextureCubeMapFilterModes(ctx,
247:                        minFilter, magFilter);
248:            }
249:
250:            void updateTextureSharpenFunc(Context ctx,
251:                    int numSharpenTextureFuncPts, float[] sharpenTextureFuncPts) {
252:
253:                Pipeline.getPipeline().updateTextureCubeMapSharpenFunc(ctx,
254:                        numSharpenTextureFuncPts, sharpenTextureFuncPts);
255:            }
256:
257:            void updateTextureFilter4Func(Context ctx, int numFilter4FuncPts,
258:                    float[] filter4FuncPts) {
259:
260:                Pipeline.getPipeline().updateTextureCubeMapFilter4Func(ctx,
261:                        numFilter4FuncPts, filter4FuncPts);
262:            }
263:
264:            void updateTextureAnisotropicFilter(Context ctx, float degree) {
265:                Pipeline.getPipeline().updateTextureCubeMapAnisotropicFilter(
266:                        ctx, degree);
267:            }
268:
269:            void updateTextureLodRange(Context ctx, int baseLevel,
270:                    int maximumLevel, float minimumLod, float maximumLod) {
271:
272:                Pipeline.getPipeline().updateTextureCubeMapLodRange(ctx,
273:                        baseLevel, maximumLevel, minimumLod, maximumLod);
274:            }
275:
276:            void updateTextureLodOffset(Context ctx, float lodOffsetX,
277:                    float lodOffsetY, float lodOffsetZ) {
278:
279:                Pipeline.getPipeline().updateTextureCubeMapLodOffset(ctx,
280:                        lodOffsetX, lodOffsetY, lodOffsetZ);
281:            }
282:
283:            /**
284:             * Load level 0 explicitly with null data pointer to allow
285:             * mipmapping when level 0 is not the base level
286:             */
287:            void updateTextureDimensions(Canvas3D cv) {
288:                if (images[0][0] != null) {
289:                    // All faces should have the same image format and type.
290:                    int imageFormat = images[0][0]
291:                            .getImageFormatTypeIntValue(false);
292:                    int imageType = images[0][0].getImageDataTypeIntValue();
293:
294:                    for (int i = 0; i < 6; i++) {
295:                        updateTextureImage(cv, i, maxLevels, 0, format,
296:                                imageFormat, width, height, boundaryWidth,
297:                                imageType, null);
298:                    }
299:                }
300:            }
301:
302:            // This is just a wrapper of the native method.
303:            void updateTextureImage(Canvas3D cv, int face, int numLevels,
304:                    int level, int textureFormat, int imageFormat, int width,
305:                    int height, int boundaryWidth, int imageDataType,
306:                    Object imageData) {
307:
308:                Pipeline.getPipeline().updateTextureCubeMapImage(cv.ctx, face,
309:                        numLevels, level, textureFormat, imageFormat, width,
310:                        height, boundaryWidth, imageDataType, imageData,
311:                        useAutoMipMapGeneration(cv));
312:            }
313:
314:            // This is just a wrapper of the native method.
315:            void updateTextureSubImage(Canvas3D cv, int face, int level,
316:                    int xoffset, int yoffset, int textureFormat,
317:                    int imageFormat, int imgXOffset, int imgYOffset, int tilew,
318:                    int width, int height, int imageDataType, Object imageData) {
319:
320:                Pipeline.getPipeline().updateTextureCubeMapSubImage(cv.ctx,
321:                        face, level, xoffset, yoffset, textureFormat,
322:                        imageFormat, imgXOffset, imgYOffset, tilew, width,
323:                        height, imageDataType, imageData,
324:                        useAutoMipMapGeneration(cv));
325:
326:            }
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.