Source Code Cross Referenced for RenderingAttributesRetained.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: RenderingAttributesRetained.java,v $
003:         *
004:         * Copyright 1998-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.9 $
028:         * $Date: 2008/02/28 20:17:29 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.ArrayList;
035:
036:        /**
037:         * The RenderingAttributes object defines all rendering state that can be set
038:         * as a component object of a Shape3D node.
039:         */
040:        class RenderingAttributesRetained extends NodeComponentRetained {
041:            // A list of pre-defined bits to indicate which component
042:            // in this RenderingAttributes object changed.
043:            static final int DEPTH_ENABLE = 0x01;
044:
045:            static final int DEPTH_WRITE_ENABLE = 0x02;
046:
047:            static final int ALPHA_TEST_VALUE = 0x04;
048:
049:            static final int ALPHA_TEST_FUNC = 0x08;
050:
051:            static final int VISIBLE = 0x10;
052:
053:            static final int IGNORE_VCOLOR = 0x20;
054:
055:            static final int RASTER_OP_ENABLE = 0x40;
056:
057:            static final int RASTER_OP_VALUE = 0x80;
058:
059:            static final int DEPTH_TEST_FUNC = 0x100;
060:
061:            static final int STENCIL_ENABLE = 0x200;
062:
063:            static final int STENCIL_OP_VALUES = 0x400;
064:
065:            static final int STENCIL_FUNC = 0x800;
066:
067:            static final int STENCIL_WRITE_MASK = 0x1000;
068:
069:            // depth buffer Enable for hidden surface removal
070:            boolean depthBufferEnable = true;
071:
072:            boolean depthBufferWriteEnable = true;
073:
074:            float alphaTestValue = 0.0f;
075:
076:            int alphaTestFunction = RenderingAttributes.ALWAYS;
077:
078:            int depthTestFunction = RenderingAttributes.LESS_OR_EQUAL;
079:
080:            boolean visible = true;
081:
082:            boolean ignoreVertexColors = false;
083:
084:            // raster operation
085:            boolean rasterOpEnable = false;
086:            int rasterOp = RenderingAttributes.ROP_COPY;
087:
088:            // stencil operation
089:            boolean stencilEnable = false;
090:            int stencilFailOp = RenderingAttributes.STENCIL_KEEP;
091:            int stencilZFailOp = RenderingAttributes.STENCIL_KEEP;
092:            int stencilZPassOp = RenderingAttributes.STENCIL_KEEP;
093:            int stencilFunction = RenderingAttributes.ALWAYS;
094:            int stencilReferenceValue = 0;
095:            int stencilCompareMask = ~0;
096:            int stencilWriteMask = ~0;
097:
098:            // depth buffer comparison function. Used by multi-texturing only
099:            //[PEPE] NOTE: they are both unused. Candidates for removal.
100:            static final int LESS = 0;
101:            static final int LEQUAL = 1;
102:
103:            /**
104:             * Sets the visibility flag for this RenderingAttributes component object. 
105:             * @param visible true or false to enable or disable visibility
106:             * @exception CapabilityNotSetException if appropriate capability is 
107:             * not set and this object is part of live or compiled scene graph
108:             *
109:             * @see View#setVisibilityPolicy
110:             */
111:            final void initVisible(boolean state) {
112:                visible = state;
113:            }
114:
115:            /**
116:             * Sets the visibility flag for this RenderingAttributes
117:             * component object.  Invisible objects are not rendered (subject to
118:             * the visibility policy for the current view), but they can be picked
119:             * or collided with.
120:             * @param visible true or false to enable or disable visibility
121:             * @exception CapabilityNotSetException if appropriate capability is 
122:             * not set and this object is part of live or compiled scene graph
123:             *
124:             * @see View#setVisibilityPolicy
125:             */
126:            final void setVisible(boolean state) {
127:                // Optimize : If new state equal to current state, should I simply return ?
128:                // Is it safe ?
129:                initVisible(state);
130:
131:                // Need to call sendMessage twice. Not an efficient approach, but
132:                // it simplified code logic and speed up the common case; where
133:                // perUniv is false.
134:
135:                sendMessage(VISIBLE, (state ? Boolean.TRUE : Boolean.FALSE));
136:
137:            }
138:
139:            /**
140:             * Retrieves the visibility flag for this RenderingAttributes object.
141:             * @return true if the object is visible; false
142:             * if the object is invisible.
143:             * @exception CapabilityNotSetException if appropriate capability is 
144:             * not set and this object is part of live or compiled scene graph
145:             */
146:            final boolean getVisible() {
147:                return visible;
148:            }
149:
150:            /**
151:             * Enables or disables vertex colors for this RenderAttributes
152:             * component object.
153:             * @param state true or false to enable or disable vertex colors
154:             */
155:            final void initIgnoreVertexColors(boolean state) {
156:                ignoreVertexColors = state;
157:            }
158:
159:            /**
160:             * Enables or disables vertex colors for this RenderAttributes
161:             * component object and sends a 
162:             * message notifying the interested structures of the change.
163:             * @param state true or false to enable or disable depth vertex colors
164:             */
165:            final void setIgnoreVertexColors(boolean state) {
166:                initIgnoreVertexColors(state);
167:                sendMessage(IGNORE_VCOLOR, (state ? Boolean.TRUE
168:                        : Boolean.FALSE));
169:            }
170:
171:            /**
172:             * Retrieves the state of vertex color Enable flag
173:             * @return true if vertex colors are enabled, false
174:             * if vertex colors are disabled
175:             */
176:            final boolean getIgnoreVertexColors() {
177:                return ignoreVertexColors;
178:            }
179:
180:            /**
181:             * Enables or disables depth buffer mode for this RenderAttributes
182:             * component object.
183:             * @param state true or false to enable or disable depth buffer mode
184:             */
185:            final void initDepthBufferEnable(boolean state) {
186:                depthBufferEnable = state;
187:            }
188:
189:            /**
190:             * Enables or disables depth buffer mode for this RenderAttributes
191:             * component object and sends a 
192:             * message notifying the interested structures of the change.
193:             * @param state true or false to enable or disable depth buffer mode
194:             */
195:            final void setDepthBufferEnable(boolean state) {
196:                initDepthBufferEnable(state);
197:                sendMessage(DEPTH_ENABLE,
198:                        (state ? Boolean.TRUE : Boolean.FALSE));
199:            }
200:
201:            /**
202:             * Retrieves the state of zBuffer Enable flag
203:             * @return true if depth buffer mode is enabled, false
204:             * if depth buffer mode is disabled
205:             */
206:            final boolean getDepthBufferEnable() {
207:                return depthBufferEnable;
208:            }
209:
210:            /**
211:             * Enables or disables writing the depth buffer for this object.
212:             * During the transparent rendering pass,
213:             * this attribute can be overridden by
214:             * the depthBufferFreezeTransparent attribute in the View object.
215:             * @param state true or false to enable or disable depth buffer Write mode
216:             * @see View#setDepthBufferFreezeTransparent
217:             */
218:            final void initDepthBufferWriteEnable(boolean state) {
219:                depthBufferWriteEnable = state;
220:            }
221:
222:            /**
223:             * Enables or disables writing the depth buffer for this object and sends
224:             * a message notifying the interested structures of the change.
225:             * During the transparent rendering pass,
226:             * this attribute can be overridden by
227:             * the depthBufferFreezeTransparent attribute in the View object.
228:             * @param state true or false to enable or disable depth buffer Write mode
229:             * @see View#setDepthBufferFreezeTransparent
230:             */
231:            final void setDepthBufferWriteEnable(boolean state) {
232:
233:                initDepthBufferWriteEnable(state);
234:                sendMessage(DEPTH_WRITE_ENABLE, (state ? Boolean.TRUE
235:                        : Boolean.FALSE));
236:            }
237:
238:            /**
239:             * Retrieves the state of Depth Buffer Write Enable flag
240:             * @return true if depth buffer is writable, false
241:             * if depth buffer is read-only
242:             */
243:            final boolean getDepthBufferWriteEnable() {
244:                return depthBufferWriteEnable;
245:            }
246:
247:            /**
248:             * Set alpha test value used by alpha test function.  This value is
249:             * compared to the alpha value of each rendered pixel.
250:             * @param value the alpha value
251:             */
252:            final void initAlphaTestValue(float value) {
253:                alphaTestValue = value;
254:            }
255:
256:            /**
257:             * Set alpha test value used by alpha test function and sends a 
258:             * message notifying the interested structures of the change.
259:             * This value is compared to the alpha value of each rendered pixel.
260:             * @param value the alpha value
261:             */
262:            final void setAlphaTestValue(float value) {
263:
264:                initAlphaTestValue(value);
265:                sendMessage(ALPHA_TEST_VALUE, new Float(value));
266:            }
267:
268:            /**
269:             * Retrieves the alpha test value.
270:             * @return the alpha test value.
271:             */
272:            final float getAlphaTestValue() {
273:                return alphaTestValue;
274:            }
275:
276:            /**
277:             * Set alpha test function.  This function is used to compare the
278:             * alpha test value with each per-pixel alpha value.  If the test
279:             * passes, then the pixel is written otherwise the pixel is not
280:             * written.
281:             * @param function the new alpha test function.  One of:
282:             * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
283:             * GREATER_OR_EQUAL.
284:             */
285:            final void initAlphaTestFunction(int function) {
286:                alphaTestFunction = function;
287:            }
288:
289:            /**
290:             * Set alpha test function and sends a 
291:             * message notifying the interested structures of the change.
292:             * This function is used to compare the
293:             * alpha test value with each per-pixel alpha value.  If the test
294:             * passes, then the pixel is written otherwise the pixel is not
295:             * written.
296:             * @param function the new alpha test function.  One of:
297:             * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
298:             * GREATER_OR_EQUAL.
299:             */
300:            final void setAlphaTestFunction(int function) {
301:
302:                initAlphaTestFunction(function);
303:                sendMessage(ALPHA_TEST_FUNC, new Integer(function));
304:            }
305:
306:            /**
307:             * Retrieves current alpha test function.
308:             * @return the current alpha test function
309:             */
310:            final int getAlphaTestFunction() {
311:                return alphaTestFunction;
312:            }
313:
314:            /**
315:             * Set depth test function.  This function is used to compare the
316:             * depth test value with each per-pixel alpha value.  If the test
317:             * passes, then the pixel is written otherwise the pixel is not
318:             * written.
319:             * @param function the new depth test function.  One of:
320:             * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
321:             * GREATER_OR_EQUAL.
322:             * Default value is LESS_OR_EQUAL
323:             */
324:            final void initDepthTestFunction(int function) {
325:                depthTestFunction = function;
326:            }
327:
328:            /**
329:             * Set depth test function.  This function is used to compare the
330:             * depth test value with each per-pixel depth value.  If the test
331:             * passes, the pixel is written otherwise the pixel is not
332:             * written.
333:             * @param function the new depth test function.  One of
334:             * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
335:             * GREATER_OR_EQUAL
336:             * Default value is LESS_OR_EQUAL
337:             */
338:            final void setDepthTestFunction(int function) {
339:                initDepthTestFunction(function);
340:                sendMessage(DEPTH_TEST_FUNC, new Integer(function));
341:            }
342:
343:            /**
344:             * Retrieves current depth test function.
345:             * @return the current depth test function
346:             * @exception CapabilityNotSetException if appropriate capability is 
347:             * not set and this object is part of live or compiled scene graph
348:             */
349:            final int getDepthTestFunction() {
350:                return depthTestFunction;
351:            }
352:
353:            /**
354:             * Initialize the raster op enable flag
355:             */
356:            final void initRasterOpEnable(boolean flag) {
357:                rasterOpEnable = flag;
358:            }
359:
360:            /**
361:             * Set the raster op enable flag
362:             */
363:            final void setRasterOpEnable(boolean flag) {
364:                initRasterOpEnable(flag);
365:                sendMessage(RASTER_OP_ENABLE, new Boolean(flag));
366:            }
367:
368:            /**
369:             * Retrieves the current raster op enable flag.
370:             */
371:            final boolean getRasterOpEnable() {
372:                return rasterOpEnable;
373:            }
374:
375:            /**
376:             * Initialize the raster op value
377:             */
378:            final void initRasterOp(int op) {
379:                rasterOp = op;
380:            }
381:
382:            /**
383:             * Set the raster op value
384:             */
385:            final void setRasterOp(int op) {
386:                initRasterOp(op);
387:                sendMessage(RASTER_OP_VALUE, new Integer(op));
388:            }
389:
390:            /**
391:             * Retrieves the current raster op value.
392:             */
393:            final int getRasterOp() {
394:                return rasterOp;
395:            }
396:
397:            // Stencil operations 
398:            /**
399:             * Initialize the stencil enable state
400:             */
401:            final void initStencilEnable(boolean state) {
402:                stencilEnable = state;
403:            }
404:
405:            /**
406:             * Set the stencil enable state
407:             */
408:            final void setStencilEnable(boolean state) {
409:                initStencilEnable(state);
410:                sendMessage(STENCIL_ENABLE, new Boolean(state));
411:            }
412:
413:            /**
414:             * Retrieves the current stencil enable state.
415:             */
416:            final boolean getStencilEnable() {
417:                return stencilEnable;
418:            }
419:
420:            /**
421:             * Initialize the stencil op. value
422:             */
423:            final void initStencilOp(int failOp, int zFailOp, int zPassOp) {
424:                stencilFailOp = failOp;
425:                stencilZFailOp = zFailOp;
426:                stencilZPassOp = zPassOp;
427:            }
428:
429:            /**
430:             * Set the stencil op. value
431:             */
432:            final void setStencilOp(int failOp, int zFailOp, int zPassOp) {
433:                initStencilOp(failOp, zFailOp, zPassOp);
434:
435:                ArrayList arrList = new ArrayList(3);
436:                arrList.add(new Integer(failOp));
437:                arrList.add(new Integer(zFailOp));
438:                arrList.add(new Integer(zPassOp));
439:                sendMessage(STENCIL_OP_VALUES, arrList);
440:            }
441:
442:            /**
443:             * Retrieves the current stencil op. value
444:             */
445:            final void getStencilOp(int[] stencilOps) {
446:                stencilOps[0] = stencilFailOp;
447:                stencilOps[1] = stencilZFailOp;
448:                stencilOps[2] = stencilZPassOp;
449:            }
450:
451:            /**
452:             * Initialize the stencil function value
453:             */
454:            final void initStencilFunction(int function, int refValue,
455:                    int compareMask) {
456:                stencilFunction = function;
457:                stencilReferenceValue = refValue;
458:                stencilCompareMask = compareMask;
459:            }
460:
461:            /**
462:             * Set the stencil function value
463:             */
464:            final void setStencilFunction(int function, int refValue,
465:                    int compareMask) {
466:                initStencilOp(function, refValue, compareMask);
467:
468:                ArrayList arrList = new ArrayList(3);
469:                arrList.add(new Integer(function));
470:                arrList.add(new Integer(refValue));
471:                arrList.add(new Integer(compareMask));
472:                sendMessage(STENCIL_FUNC, arrList);
473:            }
474:
475:            /**
476:             * Retrieves the current stencil op. value
477:             */
478:            final void getStencilFunction(int[] params) {
479:                params[0] = stencilFunction;
480:                params[1] = stencilReferenceValue;
481:                params[2] = stencilCompareMask;
482:            }
483:
484:            /**
485:             * Initialize the stencil write mask
486:             */
487:            final void initStencilWriteMask(int mask) {
488:                stencilWriteMask = mask;
489:            }
490:
491:            /**
492:             * Set the stencil write mask
493:             */
494:            final void setStencilWriteMask(int mask) {
495:                initStencilWriteMask(mask);
496:                sendMessage(STENCIL_WRITE_MASK, new Integer(mask));
497:            }
498:
499:            /**
500:             * Retrieves the current stencil write mask
501:             */
502:            final int getStencilWriteMask() {
503:                return stencilWriteMask;
504:            }
505:
506:            /**
507:             * Updates the native context.
508:             */
509:
510:            /**
511:             * Updates the native context.
512:             */
513:            void updateNative(Canvas3D c3d,
514:                    boolean depthBufferWriteEnableOverride,
515:                    boolean depthBufferEnableOverride) {
516:                Pipeline.getPipeline().updateRenderingAttributes(c3d.ctx,
517:                        depthBufferWriteEnableOverride,
518:                        depthBufferEnableOverride, depthBufferEnable,
519:                        depthBufferWriteEnable, depthTestFunction,
520:                        alphaTestValue, alphaTestFunction, ignoreVertexColors,
521:                        rasterOpEnable, rasterOp, c3d.userStencilAvailable,
522:                        stencilEnable, stencilFailOp, stencilZFailOp,
523:                        stencilZPassOp, stencilFunction, stencilReferenceValue,
524:                        stencilCompareMask, stencilWriteMask);
525:            }
526:
527:            /**
528:             * Creates and initializes a mirror object, point the mirror object
529:             * to the retained object if the object is not editable
530:             */
531:            synchronized void createMirrorObject() {
532:                if (mirror == null) {
533:                    // Check the capability bits and let the mirror object
534:                    // point to itself if is not editable
535:                    if (isStatic()) {
536:                        mirror = this ;
537:                    } else {
538:                        RenderingAttributesRetained mirrorRa = new RenderingAttributesRetained();
539:                        mirrorRa.set(this );
540:                        mirrorRa.source = source;
541:                        mirror = mirrorRa;
542:                    }
543:                } else {
544:                    ((RenderingAttributesRetained) mirror).set(this );
545:                }
546:            }
547:
548:            /**
549:             * Initializes a mirror object, point the mirror object to the retained
550:             * object if the object is not editable
551:             */
552:            synchronized void initMirrorObject() {
553:                ((RenderingAttributesRetained) mirror).set(this );
554:            }
555:
556:            /**
557:             * Update the "component" field of the mirror object with the 
558:             *  given "value"
559:             */
560:            synchronized void updateMirrorObject(int component, Object value) {
561:                RenderingAttributesRetained mirrorRa = (RenderingAttributesRetained) mirror;
562:
563:                if ((component & DEPTH_ENABLE) != 0) {
564:                    mirrorRa.depthBufferEnable = ((Boolean) value)
565:                            .booleanValue();
566:                } else if ((component & DEPTH_WRITE_ENABLE) != 0) {
567:                    mirrorRa.depthBufferWriteEnable = ((Boolean) value)
568:                            .booleanValue();
569:                } else if ((component & DEPTH_TEST_FUNC) != 0) {
570:                    mirrorRa.depthTestFunction = ((Integer) value).intValue();
571:                } else if ((component & ALPHA_TEST_VALUE) != 0) {
572:                    mirrorRa.alphaTestValue = ((Float) value).floatValue();
573:                } else if ((component & ALPHA_TEST_FUNC) != 0) {
574:                    mirrorRa.alphaTestFunction = ((Integer) value).intValue();
575:                } else if ((component & VISIBLE) != 0) {
576:                    mirrorRa.visible = (((Boolean) value).booleanValue());
577:                } else if ((component & IGNORE_VCOLOR) != 0) {
578:                    mirrorRa.ignoreVertexColors = (((Boolean) value)
579:                            .booleanValue());
580:                } else if ((component & RASTER_OP_ENABLE) != 0) {
581:                    mirrorRa.rasterOpEnable = (((Boolean) value).booleanValue());
582:                } else if ((component & RASTER_OP_VALUE) != 0) {
583:                    mirrorRa.rasterOp = (((Integer) value).intValue());
584:                } else if ((component & STENCIL_ENABLE) != 0) {
585:                    mirrorRa.stencilEnable = (((Boolean) value).booleanValue());
586:                } else if ((component & STENCIL_OP_VALUES) != 0) {
587:                    ArrayList arrlist = (ArrayList) value;
588:                    mirrorRa.stencilFailOp = (((Integer) arrlist.get(0))
589:                            .intValue());
590:                    mirrorRa.stencilZFailOp = (((Integer) arrlist.get(1))
591:                            .intValue());
592:                    mirrorRa.stencilZPassOp = (((Integer) arrlist.get(2))
593:                            .intValue());
594:                } else if ((component & STENCIL_FUNC) != 0) {
595:                    ArrayList arrlist = (ArrayList) value;
596:                    mirrorRa.stencilFunction = (((Integer) arrlist.get(0))
597:                            .intValue());
598:                    mirrorRa.stencilReferenceValue = (((Integer) arrlist.get(1))
599:                            .intValue());
600:                    mirrorRa.stencilCompareMask = (((Integer) arrlist.get(2))
601:                            .intValue());
602:                } else if ((component & STENCIL_WRITE_MASK) != 0) {
603:                    mirrorRa.stencilWriteMask = (((Integer) value).intValue());
604:                }
605:            }
606:
607:            boolean equivalent(RenderingAttributesRetained rr) {
608:                return (this  == rr)
609:                        || ((rr != null)
610:                                && (rr.depthBufferEnable == depthBufferEnable)
611:                                && (rr.depthBufferWriteEnable == depthBufferWriteEnable)
612:                                && (rr.alphaTestValue == alphaTestValue)
613:                                && (rr.alphaTestFunction == alphaTestFunction)
614:                                && (rr.visible == visible)
615:                                && (rr.ignoreVertexColors == ignoreVertexColors)
616:                                && (rr.rasterOpEnable == rasterOpEnable)
617:                                && (rr.rasterOp == rasterOp)
618:                                && (rr.depthTestFunction == depthTestFunction)
619:                                && (rr.stencilEnable == stencilEnable)
620:                                && (rr.stencilFailOp == stencilFailOp)
621:                                && (rr.stencilZFailOp == stencilZFailOp)
622:                                && (rr.stencilZPassOp == stencilZPassOp)
623:                                && (rr.stencilFunction == stencilFunction)
624:                                && (rr.stencilReferenceValue == stencilReferenceValue)
625:                                && (rr.stencilCompareMask == stencilCompareMask) && (rr.stencilWriteMask == stencilWriteMask));
626:            }
627:
628:            protected void set(RenderingAttributesRetained ra) {
629:                super .set(ra);
630:                depthBufferEnable = ra.depthBufferEnable;
631:                depthBufferWriteEnable = ra.depthBufferWriteEnable;
632:                alphaTestValue = ra.alphaTestValue;
633:                alphaTestFunction = ra.alphaTestFunction;
634:                depthTestFunction = ra.depthTestFunction;
635:                visible = ra.visible;
636:                ignoreVertexColors = ra.ignoreVertexColors;
637:                rasterOpEnable = ra.rasterOpEnable;
638:                rasterOp = ra.rasterOp;
639:                stencilEnable = ra.stencilEnable;
640:                stencilFailOp = ra.stencilFailOp;
641:                stencilZFailOp = ra.stencilZFailOp;
642:                stencilZPassOp = ra.stencilZPassOp;
643:                stencilFunction = ra.stencilFunction;
644:                stencilReferenceValue = ra.stencilReferenceValue;
645:                stencilCompareMask = ra.stencilCompareMask;
646:                stencilWriteMask = ra.stencilWriteMask;
647:
648:            }
649:
650:            final void sendMessage(int attrMask, Object attr) {
651:
652:                ArrayList univList = new ArrayList();
653:                ArrayList gaList = Shape3DRetained.getGeomAtomsList(
654:                        mirror.users, univList);
655:
656:                // Send to rendering attribute structure, regardless of
657:                // whether there are users or not (alternate appearance case ..)
658:                J3dMessage createMessage = new J3dMessage();
659:                createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES;
660:                createMessage.type = J3dMessage.RENDERINGATTRIBUTES_CHANGED;
661:                createMessage.universe = null;
662:                createMessage.args[0] = this ;
663:                createMessage.args[1] = new Integer(attrMask);
664:                createMessage.args[2] = attr;
665:                //	System.err.println("changedFreqent1 = "+changedFrequent);
666:                createMessage.args[3] = new Integer(changedFrequent);
667:                VirtualUniverse.mc.processMessage(createMessage);
668:
669:                // System.err.println("univList.size is " + univList.size());
670:                for (int i = 0; i < univList.size(); i++) {
671:                    createMessage = new J3dMessage();
672:                    createMessage.threads = J3dThread.UPDATE_RENDER;
673:                    if (attrMask == VISIBLE)
674:                        createMessage.threads |= J3dThread.UPDATE_GEOMETRY;
675:                    createMessage.type = J3dMessage.RENDERINGATTRIBUTES_CHANGED;
676:
677:                    createMessage.universe = (VirtualUniverse) univList.get(i);
678:                    createMessage.args[0] = this ;
679:                    createMessage.args[1] = new Integer(attrMask);
680:                    createMessage.args[2] = attr;
681:
682:                    ArrayList gL = (ArrayList) gaList.get(i);
683:                    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
684:                    gL.toArray(gaArr);
685:                    createMessage.args[3] = gaArr;
686:
687:                    VirtualUniverse.mc.processMessage(createMessage);
688:                }
689:
690:            }
691:
692:            // TODO : Need to handle stencil operation -- Chien
693:            void handleFrequencyChange(int bit) {
694:                int mask = 0;
695:
696:                if (bit == RenderingAttributes.ALLOW_ALPHA_TEST_VALUE_WRITE)
697:                    mask = ALPHA_TEST_VALUE;
698:                if (bit == RenderingAttributes.ALLOW_ALPHA_TEST_FUNCTION_WRITE)
699:                    mask = ALPHA_TEST_FUNC;
700:                if (bit == RenderingAttributes.ALLOW_VISIBLE_WRITE)
701:                    mask = VISIBLE;
702:                if (bit == RenderingAttributes.ALLOW_IGNORE_VERTEX_COLORS_WRITE)
703:                    mask = IGNORE_VCOLOR;
704:                if (bit == RenderingAttributes.ALLOW_RASTER_OP_WRITE)
705:                    mask = RASTER_OP_ENABLE;
706:                if (bit == RenderingAttributes.ALLOW_DEPTH_ENABLE_WRITE)
707:                    mask = DEPTH_WRITE_ENABLE;
708:                if (bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE)
709:                    mask = DEPTH_TEST_FUNC;
710:
711:                if (bit == RenderingAttributes.ALLOW_STENCIL_ATTRIBUTES_WRITE)
712:                    mask = DEPTH_TEST_FUNC;
713:
714:                if (bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE)
715:                    mask = STENCIL_ENABLE | STENCIL_OP_VALUES | STENCIL_FUNC
716:                            | STENCIL_WRITE_MASK;
717:
718:                if (mask != 0)
719:                    setFrequencyChangeMask(bit, mask);
720:                //	System.err.println("changedFreqent2 = "+changedFrequent);
721:            }
722:
723:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.