Source Code Cross Referenced for AppearanceRetained.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) 


0001:        /*
0002:         * $RCSfile: AppearanceRetained.java,v $
0003:         *
0004:         * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
0005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0006:         *
0007:         * This code is free software; you can redistribute it and/or modify it
0008:         * under the terms of the GNU General Public License version 2 only, as
0009:         * published by the Free Software Foundation.  Sun designates this
0010:         * particular file as subject to the "Classpath" exception as provided
0011:         * by Sun in the LICENSE file that accompanied this code.
0012:         *
0013:         * This code is distributed in the hope that it will be useful, but WITHOUT
0014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0016:         * version 2 for more details (a copy is included in the LICENSE file that
0017:         * accompanied this code).
0018:         *
0019:         * You should have received a copy of the GNU General Public License version
0020:         * 2 along with this work; if not, write to the Free Software Foundation,
0021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0022:         *
0023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0024:         * CA 95054 USA or visit www.sun.com if you need additional information or
0025:         * have any questions.
0026:         *
0027:         * $Revision: 1.11 $
0028:         * $Date: 2008/02/28 20:17:19 $
0029:         * $State: Exp $
0030:         */
0031:
0032:        package javax.media.j3d;
0033:
0034:        import java.util.Vector;
0035:        import java.util.BitSet;
0036:        import java.util.ArrayList;
0037:
0038:        /**
0039:         * The Appearance object defines all rendering state that can be set
0040:         * as a component object of a Shape3D node.
0041:         */
0042:        class AppearanceRetained extends NodeComponentRetained {
0043:
0044:            //
0045:            // State variables: these should all be initialized to approproate
0046:            // Java 3D defaults.
0047:            //
0048:
0049:            // Material object used when lighting is enabled
0050:            MaterialRetained material = null;
0051:
0052:            // Texture object used to apply a texture map to an object
0053:            TextureRetained texture = null;
0054:
0055:            // Texture coordinate generation object
0056:            TexCoordGenerationRetained texCoordGeneration = null;
0057:
0058:            // Texture Attributes bundle object
0059:            TextureAttributesRetained textureAttributes = null;
0060:
0061:            TextureUnitStateRetained texUnitState[] = null;
0062:
0063:            // Coloring Attributes bundle object
0064:            ColoringAttributesRetained coloringAttributes = null;
0065:
0066:            // Transparency Attributes bundle object
0067:            TransparencyAttributesRetained transparencyAttributes = null;
0068:
0069:            // Rendering Attributes bundle object
0070:            RenderingAttributesRetained renderingAttributes = null;
0071:
0072:            // Polygon Attributes bundle object
0073:            PolygonAttributesRetained polygonAttributes = null;
0074:
0075:            // Line Attributes bundle object
0076:            LineAttributesRetained lineAttributes = null;
0077:
0078:            // Point Attributes bundle object
0079:            PointAttributesRetained pointAttributes = null;
0080:
0081:            // Lock used for synchronization of live state
0082:            Object liveStateLock = new Object();
0083:
0084:            // NOTE: Consider grouping random state into common objects
0085:
0086:            // Cache used during compilation.  If map == compState, then 
0087:            // mapAppearance can be used for this appearance
0088:            CompileState map = null;
0089:            AppearanceRetained mapAppearance = null;
0090:
0091:            static final int MATERIAL = 0x0001;
0092:            static final int TEXTURE = 0x0002;
0093:            static final int TEXCOORD_GEN = 0x0004;
0094:            static final int TEXTURE_ATTR = 0x0008;
0095:            static final int COLOR = 0x0010;
0096:            static final int TRANSPARENCY = 0x0020;
0097:            static final int RENDERING = 0x0040;
0098:            static final int POLYGON = 0x0080;
0099:            static final int LINE = 0x0100;
0100:            static final int POINT = 0x0200;
0101:            static final int TEXTURE_UNIT_STATE = 0x0400;
0102:
0103:            static final int ALL_SOLE_USERS = 0;
0104:
0105:            // A pointer to the scene graph appearance object
0106:            AppearanceRetained sgApp = null;
0107:
0108:            // The object level hashcode for this appearance
0109:            //    int objHashCode = super.hashCode();
0110:
0111:            /**
0112:             * Set the material object to the specified object.
0113:             * @param material object that specifies the desired material
0114:             * @exception IllegalSharingException
0115:             * properties
0116:             */
0117:            void setMaterial(Material material) {
0118:
0119:                synchronized (liveStateLock) {
0120:                    if (source.isLive()) {
0121:
0122:                        if (this .material != null) {
0123:                            this .material.clearLive(refCount);
0124:                            this .material.removeMirrorUsers(this );
0125:                        }
0126:                        if (material != null) {
0127:                            ((MaterialRetained) material.retained).setLive(
0128:                                    inBackgroundGroup, refCount);
0129:                            // If appearance is live, then copy all the users of this
0130:                            // appaearance as users of this material
0131:                            ((MaterialRetained) material.retained)
0132:                                    .copyMirrorUsers(this );
0133:                        }
0134:                        sendMessage(
0135:                                MATERIAL,
0136:                                (material != null ? ((MaterialRetained) material.retained).mirror
0137:                                        : null), true);
0138:                    }
0139:                    if (material == null) {
0140:                        this .material = null;
0141:                    } else {
0142:                        this .material = (MaterialRetained) material.retained;
0143:                    }
0144:                }
0145:            }
0146:
0147:            /**
0148:             * Retrieve the current material object.
0149:             * @return the material object
0150:             */
0151:            Material getMaterial() {
0152:                return (material == null ? null : (Material) material.source);
0153:            }
0154:
0155:            /**
0156:             * Sets the texture object to the specified object.
0157:             * @param texture object that specifies the desired texture
0158:             * map and texture parameters
0159:             */
0160:            void setTexture(Texture texture) {
0161:                synchronized (liveStateLock) {
0162:                    if (source.isLive()) {
0163:
0164:                        if (this .texture != null) {
0165:                            this .texture.clearLive(refCount);
0166:                            this .texture.removeMirrorUsers(this );
0167:                        }
0168:
0169:                        if (texture != null) {
0170:                            ((TextureRetained) texture.retained).setLive(
0171:                                    inBackgroundGroup, refCount);
0172:                            ((TextureRetained) texture.retained)
0173:                                    .copyMirrorUsers(this );
0174:                        }
0175:                        sendMessage(
0176:                                TEXTURE,
0177:                                (texture != null ? ((TextureRetained) texture.retained).mirror
0178:                                        : null), true);
0179:
0180:                    }
0181:
0182:                    if (texture == null) {
0183:                        this .texture = null;
0184:                    } else {
0185:                        this .texture = (TextureRetained) texture.retained;
0186:                    }
0187:                }
0188:            }
0189:
0190:            /**
0191:             * Retrieves the current texture object. 
0192:             * @return the texture object
0193:             */
0194:            Texture getTexture() {
0195:                return (texture == null ? null : (Texture) texture.source);
0196:            }
0197:
0198:            /**
0199:             * Sets the textureAttrbutes object to the specified object.
0200:             * @param textureAttributes object that specifies the desired texture
0201:             * attributes
0202:             */
0203:            void setTextureAttributes(TextureAttributes textureAttributes) {
0204:
0205:                synchronized (liveStateLock) {
0206:                    if (source.isLive()) {
0207:
0208:                        if (this .textureAttributes != null) {
0209:                            this .textureAttributes.clearLive(refCount);
0210:                            this .textureAttributes.removeMirrorUsers(this );
0211:                        }
0212:
0213:                        if (textureAttributes != null) {
0214:                            ((TextureAttributesRetained) textureAttributes.retained)
0215:                                    .setLive(inBackgroundGroup, refCount);
0216:                            ((TextureAttributesRetained) textureAttributes.retained)
0217:                                    .copyMirrorUsers(this );
0218:                        }
0219:                        sendMessage(
0220:                                TEXTURE_ATTR,
0221:                                (textureAttributes != null ? ((TextureAttributesRetained) textureAttributes.retained).mirror
0222:                                        : null), true);
0223:
0224:                    }
0225:
0226:                    if (textureAttributes == null) {
0227:                        this .textureAttributes = null;
0228:                    } else {
0229:                        this .textureAttributes = (TextureAttributesRetained) textureAttributes.retained;
0230:                    }
0231:                }
0232:            }
0233:
0234:            /**
0235:             * Retrieves the current textureAttributes object.
0236:             * @return the textureAttributes object
0237:             */
0238:            TextureAttributes getTextureAttributes() {
0239:                return (textureAttributes == null ? null
0240:                        : (TextureAttributes) textureAttributes.source);
0241:            }
0242:
0243:            /**
0244:             * Sets the coloringAttrbutes object to the specified object.
0245:             * @param coloringAttributes object that specifies the desired texture
0246:             * attributes
0247:             */
0248:            void setColoringAttributes(ColoringAttributes coloringAttributes) {
0249:
0250:                synchronized (liveStateLock) {
0251:                    if (source.isLive()) {
0252:
0253:                        if (this .coloringAttributes != null) {
0254:                            this .coloringAttributes.clearLive(refCount);
0255:                            this .coloringAttributes.removeMirrorUsers(this );
0256:                        }
0257:
0258:                        if (coloringAttributes != null) {
0259:                            ((ColoringAttributesRetained) coloringAttributes.retained)
0260:                                    .setLive(inBackgroundGroup, refCount);
0261:                            ((ColoringAttributesRetained) coloringAttributes.retained)
0262:                                    .copyMirrorUsers(this );
0263:                        }
0264:                        sendMessage(
0265:                                COLOR,
0266:                                (coloringAttributes != null ? ((ColoringAttributesRetained) coloringAttributes.retained).mirror
0267:                                        : null), true);
0268:                    }
0269:
0270:                    if (coloringAttributes == null) {
0271:                        this .coloringAttributes = null;
0272:                    } else {
0273:                        this .coloringAttributes = (ColoringAttributesRetained) coloringAttributes.retained;
0274:                    }
0275:                }
0276:            }
0277:
0278:            /**
0279:             * Retrieves the current coloringAttributes object.
0280:             * @return the coloringAttributes object
0281:             */
0282:            ColoringAttributes getColoringAttributes() {
0283:                return (coloringAttributes == null ? null
0284:                        : (ColoringAttributes) coloringAttributes.source);
0285:            }
0286:
0287:            /**
0288:             * Sets the transparencyAttrbutes object to the specified object.
0289:             * @param transparencyAttributes object that specifies the desired texture
0290:             * attributes
0291:             */
0292:            void setTransparencyAttributes(
0293:                    TransparencyAttributes transparencyAttributes) {
0294:
0295:                synchronized (liveStateLock) {
0296:                    if (source.isLive()) {
0297:
0298:                        if (this .transparencyAttributes != null) {
0299:                            this .transparencyAttributes.clearLive(refCount);
0300:                            this .transparencyAttributes.removeMirrorUsers(this );
0301:                        }
0302:
0303:                        if (transparencyAttributes != null) {
0304:                            ((TransparencyAttributesRetained) transparencyAttributes.retained)
0305:                                    .setLive(inBackgroundGroup, refCount);
0306:                            ((TransparencyAttributesRetained) transparencyAttributes.retained)
0307:                                    .copyMirrorUsers(this );
0308:                        }
0309:
0310:                        sendMessage(
0311:                                TRANSPARENCY,
0312:                                (transparencyAttributes != null ? ((TransparencyAttributesRetained) transparencyAttributes.retained).mirror
0313:                                        : null), true);
0314:                    }
0315:
0316:                    if (transparencyAttributes == null) {
0317:                        this .transparencyAttributes = null;
0318:                    } else {
0319:                        this .transparencyAttributes = (TransparencyAttributesRetained) transparencyAttributes.retained;
0320:
0321:                    }
0322:                }
0323:            }
0324:
0325:            /**
0326:             * Retrieves the current transparencyAttributes object.
0327:             * @return the transparencyAttributes object
0328:             */
0329:            TransparencyAttributes getTransparencyAttributes() {
0330:                return (transparencyAttributes == null ? null
0331:                        : (TransparencyAttributes) transparencyAttributes.source);
0332:            }
0333:
0334:            /**
0335:             * Sets the renderingAttrbutes object to the specified object.
0336:             * @param renderingAttributes object that specifies the desired texture
0337:             * attributes
0338:             */
0339:            void setRenderingAttributes(RenderingAttributes renderingAttributes) {
0340:
0341:                synchronized (liveStateLock) {
0342:                    if (source.isLive()) {
0343:                        if (this .renderingAttributes != null) {
0344:                            this .renderingAttributes.clearLive(refCount);
0345:                            this .renderingAttributes.removeMirrorUsers(this );
0346:                        }
0347:
0348:                        if (renderingAttributes != null) {
0349:                            ((RenderingAttributesRetained) renderingAttributes.retained)
0350:                                    .setLive(inBackgroundGroup, refCount);
0351:                            ((RenderingAttributesRetained) renderingAttributes.retained)
0352:                                    .copyMirrorUsers(this );
0353:                        }
0354:                        Object m = null;
0355:                        boolean v = true;
0356:                        if (renderingAttributes != null) {
0357:                            m = ((RenderingAttributesRetained) renderingAttributes.retained).mirror;
0358:                            v = ((RenderingAttributesRetained) renderingAttributes.retained).visible;
0359:                        }
0360:                        sendMessage(RENDERING, m, v);
0361:                        // Also need to send a message to GeometryStructure.
0362:                        sendRenderingAttributesChangedMessage(v);
0363:                    }
0364:                    if (renderingAttributes == null) {
0365:                        this .renderingAttributes = null;
0366:                    } else {
0367:                        this .renderingAttributes = (RenderingAttributesRetained) renderingAttributes.retained;
0368:
0369:                    }
0370:                }
0371:            }
0372:
0373:            /**
0374:             * Retrieves the current renderingAttributes object.
0375:             * @return the renderingAttributes object
0376:             */
0377:            RenderingAttributes getRenderingAttributes() {
0378:                if (renderingAttributes == null)
0379:                    return null;
0380:
0381:                return (RenderingAttributes) renderingAttributes.source;
0382:            }
0383:
0384:            /**
0385:             * Sets the polygonAttrbutes object to the specified object.
0386:             * @param polygonAttributes object that specifies the desired texture
0387:             * attributes
0388:             */
0389:            void setPolygonAttributes(PolygonAttributes polygonAttributes) {
0390:
0391:                synchronized (liveStateLock) {
0392:                    if (source.isLive()) {
0393:                        if (this .polygonAttributes != null) {
0394:                            this .polygonAttributes.clearLive(refCount);
0395:                            this .polygonAttributes.removeMirrorUsers(this );
0396:                        }
0397:
0398:                        if (polygonAttributes != null) {
0399:                            ((PolygonAttributesRetained) polygonAttributes.retained)
0400:                                    .setLive(inBackgroundGroup, refCount);
0401:                            ((PolygonAttributesRetained) polygonAttributes.retained)
0402:                                    .copyMirrorUsers(this );
0403:                        }
0404:                        sendMessage(
0405:                                POLYGON,
0406:                                (polygonAttributes != null ? ((PolygonAttributesRetained) polygonAttributes.retained).mirror
0407:                                        : null), true);
0408:
0409:                    }
0410:
0411:                    if (polygonAttributes == null) {
0412:                        this .polygonAttributes = null;
0413:                    } else {
0414:                        this .polygonAttributes = (PolygonAttributesRetained) polygonAttributes.retained;
0415:                    }
0416:                }
0417:            }
0418:
0419:            /**
0420:             * Retrieves the current polygonAttributes object.
0421:             * @return the polygonAttributes object
0422:             */
0423:            PolygonAttributes getPolygonAttributes() {
0424:                return (polygonAttributes == null ? null
0425:                        : (PolygonAttributes) polygonAttributes.source);
0426:            }
0427:
0428:            /**
0429:             * Sets the lineAttrbutes object to the specified object.
0430:             * @param lineAttributes object that specifies the desired texture
0431:             * attributes
0432:             */
0433:            void setLineAttributes(LineAttributes lineAttributes) {
0434:
0435:                synchronized (liveStateLock) {
0436:                    if (source.isLive()) {
0437:
0438:                        if (this .lineAttributes != null) {
0439:                            this .lineAttributes.clearLive(refCount);
0440:                            this .lineAttributes.removeMirrorUsers(this );
0441:                        }
0442:
0443:                        if (lineAttributes != null) {
0444:                            ((LineAttributesRetained) lineAttributes.retained)
0445:                                    .setLive(inBackgroundGroup, refCount);
0446:                            ((LineAttributesRetained) lineAttributes.retained)
0447:                                    .copyMirrorUsers(this );
0448:                        }
0449:                        sendMessage(
0450:                                LINE,
0451:                                (lineAttributes != null ? ((LineAttributesRetained) lineAttributes.retained).mirror
0452:                                        : null), true);
0453:                    }
0454:
0455:                    if (lineAttributes == null) {
0456:                        this .lineAttributes = null;
0457:                    } else {
0458:                        this .lineAttributes = (LineAttributesRetained) lineAttributes.retained;
0459:                    }
0460:                }
0461:            }
0462:
0463:            /**
0464:             * Retrieves the current lineAttributes object.
0465:             * @return the lineAttributes object
0466:             */
0467:            LineAttributes getLineAttributes() {
0468:                return (lineAttributes == null ? null
0469:                        : (LineAttributes) lineAttributes.source);
0470:            }
0471:
0472:            /**
0473:             * Sets the pointAttrbutes object to the specified object.
0474:             * @param pointAttributes object that specifies the desired texture
0475:             * attributes
0476:             */
0477:            void setPointAttributes(PointAttributes pointAttributes) {
0478:
0479:                synchronized (liveStateLock) {
0480:                    if (source.isLive()) {
0481:
0482:                        if (this .pointAttributes != null) {
0483:                            this .pointAttributes.clearLive(refCount);
0484:                            this .pointAttributes.removeMirrorUsers(this );
0485:                        }
0486:                        if (pointAttributes != null) {
0487:                            ((PointAttributesRetained) pointAttributes.retained)
0488:                                    .setLive(inBackgroundGroup, refCount);
0489:                            ((PointAttributesRetained) pointAttributes.retained)
0490:                                    .copyMirrorUsers(this );
0491:                        }
0492:                        sendMessage(
0493:                                POINT,
0494:                                (pointAttributes != null ? ((PointAttributesRetained) pointAttributes.retained).mirror
0495:                                        : null), true);
0496:                    }
0497:
0498:                    if (pointAttributes == null) {
0499:                        this .pointAttributes = null;
0500:                    } else {
0501:                        this .pointAttributes = (PointAttributesRetained) pointAttributes.retained;
0502:                    }
0503:                }
0504:            }
0505:
0506:            /**
0507:             * Retrieves the current pointAttributes object.
0508:             * @return the pointAttributes object
0509:             */
0510:            PointAttributes getPointAttributes() {
0511:                return (pointAttributes == null ? null
0512:                        : (PointAttributes) pointAttributes.source);
0513:            }
0514:
0515:            /**
0516:             * Sets the texCoordGeneration object to the specified object.
0517:             * @param texCoordGeneration object that specifies the texture coordinate
0518:             * generation parameters
0519:             */
0520:            void setTexCoordGeneration(TexCoordGeneration texGen) {
0521:
0522:                synchronized (liveStateLock) {
0523:                    if (source.isLive()) {
0524:
0525:                        if (this .texCoordGeneration != null) {
0526:                            this .texCoordGeneration.clearLive(refCount);
0527:                            this .texCoordGeneration.removeMirrorUsers(this );
0528:                        }
0529:
0530:                        if (texGen != null) {
0531:                            ((TexCoordGenerationRetained) texGen.retained)
0532:                                    .setLive(inBackgroundGroup, refCount);
0533:                            ((TexCoordGenerationRetained) texGen.retained)
0534:                                    .copyMirrorUsers(this );
0535:                        }
0536:                        sendMessage(
0537:                                TEXCOORD_GEN,
0538:                                (texGen != null ? ((TexCoordGenerationRetained) texGen.retained).mirror
0539:                                        : null), true);
0540:                    }
0541:
0542:                    if (texGen == null) {
0543:                        this .texCoordGeneration = null;
0544:                    } else {
0545:                        this .texCoordGeneration = (TexCoordGenerationRetained) texGen.retained;
0546:                    }
0547:                }
0548:            }
0549:
0550:            /**
0551:             * Retrieves the current texCoordGeneration object.
0552:             * @return the texCoordGeneration object
0553:             */
0554:            TexCoordGeneration getTexCoordGeneration() {
0555:                return (texCoordGeneration == null ? null
0556:                        : (TexCoordGeneration) texCoordGeneration.source);
0557:            }
0558:
0559:            /**
0560:             * Sets the texture unit state array to the specified array.
0561:             * @param textureUnitState array that specifies the texture unit state
0562:             */
0563:            void setTextureUnitState(TextureUnitState[] stateArray) {
0564:
0565:                int i;
0566:
0567:                synchronized (liveStateLock) {
0568:                    if (source.isLive()) {
0569:
0570:                        // remove the existing texture unit states from this appearance
0571:                        if (this .texUnitState != null) {
0572:                            for (i = 0; i < this .texUnitState.length; i++) {
0573:                                if (this .texUnitState[i] != null) {
0574:                                    this .texUnitState[i].clearLive(refCount);
0575:                                    this .texUnitState[i]
0576:                                            .removeMirrorUsers(this );
0577:                                }
0578:                            }
0579:                        }
0580:
0581:                        // add the specified texture unit states to this appearance
0582:                        // also make a copy of the array of references to the units
0583:                        if (stateArray != null && stateArray.length > 0) {
0584:
0585:                            Object[] args = new Object[2];
0586:
0587:                            // -1 index means the entire array is to be set
0588:                            args[0] = new Integer(-1);
0589:
0590:                            // make a copy of the array for the message,
0591:                            TextureUnitStateRetained mirrorStateArray[] = new TextureUnitStateRetained[stateArray.length];
0592:
0593:                            args[1] = (Object) mirrorStateArray;
0594:
0595:                            for (i = 0; i < stateArray.length; i++) {
0596:                                TextureUnitState tu = stateArray[i];
0597:                                if (tu != null) {
0598:                                    ((TextureUnitStateRetained) tu.retained)
0599:                                            .setLive(inBackgroundGroup,
0600:                                                    refCount);
0601:                                    ((TextureUnitStateRetained) tu.retained)
0602:                                            .copyMirrorUsers(this );
0603:                                    mirrorStateArray[i] = (TextureUnitStateRetained) ((TextureUnitStateRetained) tu.retained).mirror;
0604:                                } else {
0605:                                    mirrorStateArray[i] = null;
0606:                                }
0607:                            }
0608:                            sendMessage(TEXTURE_UNIT_STATE, args, true);
0609:
0610:                        } else {
0611:                            sendMessage(TEXTURE_UNIT_STATE, null, true);
0612:                        }
0613:                    }
0614:
0615:                    // assign the retained copy of the texture unit state to the
0616:                    // appearance
0617:                    if (stateArray == null) {
0618:                        this .texUnitState = null;
0619:                    } else {
0620:
0621:                        // make another copy of the array for the retained object
0622:                        // itself if it doesn't have a copy or the array size is
0623:                        // not the same
0624:                        if ((this .texUnitState == null)
0625:                                || (this .texUnitState.length != stateArray.length)) {
0626:                            this .texUnitState = new TextureUnitStateRetained[stateArray.length];
0627:                        }
0628:                        for (i = 0; i < stateArray.length; i++) {
0629:                            if (stateArray[i] != null) {
0630:                                this .texUnitState[i] = (TextureUnitStateRetained) stateArray[i].retained;
0631:                            } else {
0632:                                this .texUnitState[i] = null;
0633:                            }
0634:                        }
0635:                    }
0636:                }
0637:            }
0638:
0639:            void setTextureUnitState(int index, TextureUnitState state) {
0640:
0641:                synchronized (liveStateLock) {
0642:                    if (source.isLive()) {
0643:
0644:                        // remove the existing texture unit states from this appearance
0645:                        // Note: Let Java throw an exception if texUnitState is null
0646:                        // or index is >= texUnitState.length.
0647:                        if (this .texUnitState[index] != null) {
0648:                            this .texUnitState[index].clearLive(refCount);
0649:                            this .texUnitState[index].removeMirrorUsers(this );
0650:                        }
0651:
0652:                        // add the specified texture unit states to this appearance
0653:                        // also make a copy of the array of references to the units
0654:                        Object args[] = new Object[2];
0655:                        args[0] = new Integer(index);
0656:
0657:                        if (state != null) {
0658:                            ((TextureUnitStateRetained) state.retained)
0659:                                    .setLive(inBackgroundGroup, refCount);
0660:                            ((TextureUnitStateRetained) state.retained)
0661:                                    .copyMirrorUsers(this );
0662:                            args[1] = ((TextureUnitStateRetained) state.retained).mirror;
0663:                            sendMessage(TEXTURE_UNIT_STATE, args, true);
0664:                        } else {
0665:                            args[1] = null;
0666:                            sendMessage(TEXTURE_UNIT_STATE, args, true);
0667:                        }
0668:                    }
0669:
0670:                    // assign the retained copy of the texture unit state to the
0671:                    // appearance
0672:                    if (state != null) {
0673:                        this .texUnitState[index] = (TextureUnitStateRetained) state.retained;
0674:                    } else {
0675:                        this .texUnitState[index] = null;
0676:                    }
0677:                }
0678:            }
0679:
0680:            /**
0681:             * Retrieves the array of texture unit state objects from this
0682:             * Appearance object.  A shallow copy of the array of references to
0683:             * the TextureUnitState objects is returned.
0684:             *
0685:             */
0686:            TextureUnitState[] getTextureUnitState() {
0687:                if (texUnitState == null) {
0688:                    return null;
0689:                } else {
0690:                    TextureUnitState tus[] = new TextureUnitState[texUnitState.length];
0691:                    for (int i = 0; i < texUnitState.length; i++) {
0692:                        if (texUnitState[i] != null) {
0693:                            tus[i] = (TextureUnitState) texUnitState[i].source;
0694:                        } else {
0695:                            tus[i] = null;
0696:                        }
0697:                    }
0698:                    return tus;
0699:                }
0700:            }
0701:
0702:            /**
0703:             * Retrieves the texture unit state object at the specified
0704:             * index within the texture unit state array.  
0705:             */
0706:            TextureUnitState getTextureUnitState(int index) {
0707:
0708:                // let Java throw an exception if texUnitState == null or
0709:                // index is >= length
0710:                if (texUnitState[index] != null)
0711:                    return (TextureUnitState) texUnitState[index].source;
0712:                else
0713:                    return null;
0714:            }
0715:
0716:            /**
0717:             * Retrieves the length of the texture unit state array from
0718:             * this appearance object.  The length of this array specifies the
0719:             * maximum number of texture units that will be used by this
0720:             * appearance object.  If the array is null, a count of 0 is
0721:             * returned.
0722:             */
0723:
0724:            int getTextureUnitCount() {
0725:                if (texUnitState == null)
0726:                    return 0;
0727:                else
0728:                    return texUnitState.length;
0729:            }
0730:
0731:            synchronized void createMirrorObject() {
0732:                if (mirror == null) {
0733:                    // we can't check isStatic() since it sub-NodeComponent
0734:                    // create a new one, we should create a 
0735:                    // new AppearanceRetained() even though isStatic() = true.
0736:                    // For simplicity, always create a retained side.
0737:                    mirror = new AppearanceRetained();
0738:                }
0739:                initMirrorObject();
0740:            }
0741:
0742:            /**
0743:             * This routine updates the mirror appearance for this appearance.
0744:             * It also calls the update method for each node component if it
0745:             * is not null.
0746:             */
0747:            synchronized void initMirrorObject() {
0748:
0749:                AppearanceRetained mirrorApp = (AppearanceRetained) mirror;
0750:
0751:                mirrorApp.source = source;
0752:                mirrorApp.sgApp = this ;
0753:
0754:                // Fix for Issue 33: copy the changedFrequent mask to mirror
0755:                mirrorApp.changedFrequent = changedFrequent;
0756:
0757:                if (material != null) {
0758:                    mirrorApp.material = (MaterialRetained) material.mirror;
0759:                } else {
0760:                    mirrorApp.material = null;
0761:                }
0762:
0763:                if (texture != null) {
0764:                    mirrorApp.texture = (TextureRetained) texture.mirror;
0765:                } else {
0766:                    mirrorApp.texture = null;
0767:                }
0768:                if (texCoordGeneration != null) {
0769:                    mirrorApp.texCoordGeneration = (TexCoordGenerationRetained) texCoordGeneration.mirror;
0770:                } else {
0771:                    mirrorApp.texCoordGeneration = null;
0772:                }
0773:
0774:                if (textureAttributes != null) {
0775:                    mirrorApp.textureAttributes = (TextureAttributesRetained) textureAttributes.mirror;
0776:                } else {
0777:                    mirrorApp.textureAttributes = null;
0778:                }
0779:
0780:                // TextureUnitState supercedes the single texture interface
0781:                if (texUnitState != null && texUnitState.length > 0) {
0782:                    mirrorApp.texUnitState = new TextureUnitStateRetained[texUnitState.length];
0783:                    for (int i = 0; i < texUnitState.length; i++) {
0784:                        if (texUnitState[i] != null) {
0785:                            mirrorApp.texUnitState[i] = (TextureUnitStateRetained) texUnitState[i].mirror;
0786:                        }
0787:                    }
0788:                } else if (mirrorApp.texture != null
0789:                        || mirrorApp.textureAttributes != null
0790:                        || mirrorApp.texCoordGeneration != null) {
0791:
0792:                    mirrorApp.texUnitState = new TextureUnitStateRetained[1];
0793:                    mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
0794:                    mirrorApp.texUnitState[0].set(mirrorApp.texture,
0795:                            mirrorApp.textureAttributes,
0796:                            mirrorApp.texCoordGeneration);
0797:                }
0798:
0799:                if (coloringAttributes != null) {
0800:                    mirrorApp.coloringAttributes = (ColoringAttributesRetained) coloringAttributes.mirror;
0801:                } else {
0802:                    mirrorApp.coloringAttributes = null;
0803:                }
0804:                if (transparencyAttributes != null) {
0805:                    mirrorApp.transparencyAttributes = (TransparencyAttributesRetained) transparencyAttributes.mirror;
0806:                } else {
0807:                    mirrorApp.transparencyAttributes = null;
0808:                }
0809:
0810:                if (renderingAttributes != null) {
0811:                    mirrorApp.renderingAttributes = (RenderingAttributesRetained) renderingAttributes.mirror;
0812:                } else {
0813:                    mirrorApp.renderingAttributes = null;
0814:                }
0815:
0816:                if (polygonAttributes != null) {
0817:                    mirrorApp.polygonAttributes = (PolygonAttributesRetained) polygonAttributes.mirror;
0818:                } else {
0819:                    mirrorApp.polygonAttributes = null;
0820:                }
0821:
0822:                if (lineAttributes != null) {
0823:                    mirrorApp.lineAttributes = (LineAttributesRetained) lineAttributes.mirror;
0824:                } else {
0825:                    mirrorApp.lineAttributes = null;
0826:                }
0827:
0828:                if (pointAttributes != null) {
0829:                    mirrorApp.pointAttributes = (PointAttributesRetained) pointAttributes.mirror;
0830:                } else {
0831:                    mirrorApp.pointAttributes = null;
0832:                }
0833:            }
0834:
0835:            /** 
0836:             * Update the "component" field of the mirror object with the 
0837:             *  given "value"
0838:             */
0839:            synchronized void updateMirrorObject(int component, Object value) {
0840:                AppearanceRetained mirrorApp = (AppearanceRetained) mirror;
0841:                if ((component & MATERIAL) != 0) {
0842:                    mirrorApp.material = (MaterialRetained) value;
0843:                } else if ((component & TEXTURE) != 0) {
0844:                    // Issue 435: set mirror texture
0845:                    mirrorApp.texture = (TextureRetained) value;
0846:                    if (mirrorApp.texUnitState == null) {
0847:                        mirrorApp.texUnitState = new TextureUnitStateRetained[1];
0848:                        mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
0849:                    }
0850:                    mirrorApp.texUnitState[0].texture = (TextureRetained) value;
0851:                } else if ((component & TEXCOORD_GEN) != 0) {
0852:                    if (mirrorApp.texUnitState == null) {
0853:                        mirrorApp.texUnitState = new TextureUnitStateRetained[1];
0854:                        mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
0855:                    }
0856:                    mirrorApp.texUnitState[0].texGen = (TexCoordGenerationRetained) value;
0857:                } else if ((component & TEXTURE_ATTR) != 0) {
0858:                    if (mirrorApp.texUnitState == null) {
0859:                        mirrorApp.texUnitState = new TextureUnitStateRetained[1];
0860:                        mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
0861:                    }
0862:                    mirrorApp.texUnitState[0].texAttrs = (TextureAttributesRetained) value;
0863:                } else if ((component & TEXTURE_UNIT_STATE) != 0) {
0864:                    Object[] args = (Object[]) value;
0865:
0866:                    if (args == null) {
0867:                        mirrorApp.texUnitState = null;
0868:                    } else {
0869:                        int index = ((Integer) args[0]).intValue();
0870:                        if (index == -1) {
0871:                            mirrorApp.texUnitState = (TextureUnitStateRetained[]) args[1];
0872:                        } else {
0873:                            mirrorApp.texUnitState[index] = (TextureUnitStateRetained) args[1];
0874:                        }
0875:                    }
0876:                } else if ((component & COLOR) != 0) {
0877:                    mirrorApp.coloringAttributes = (ColoringAttributesRetained) value;
0878:                } else if ((component & TRANSPARENCY) != 0) {
0879:                    mirrorApp.transparencyAttributes = (TransparencyAttributesRetained) value;
0880:                } else if ((component & RENDERING) != 0) {
0881:                    mirrorApp.renderingAttributes = (RenderingAttributesRetained) value;
0882:                } else if ((component & POLYGON) != 0) {
0883:                    mirrorApp.polygonAttributes = (PolygonAttributesRetained) value;
0884:                } else if ((component & LINE) != 0) {
0885:                    mirrorApp.lineAttributes = (LineAttributesRetained) value;
0886:                } else if ((component & POINT) != 0) {
0887:                    mirrorApp.pointAttributes = (PointAttributesRetained) value;
0888:                }
0889:
0890:            }
0891:
0892:            void setLive(boolean backgroundGroup, int refCount) {
0893:                // System.err.println("AppearceRetained.setLive()");
0894:                doSetLive(backgroundGroup, refCount);
0895:                markAsLive();
0896:            }
0897:
0898:            /**
0899:             * This method calls the setLive method of all appearance bundle
0900:             * objects.
0901:             */
0902:            void doSetLive(boolean backgroundGroup, int refCount) {
0903:                // System.err.println("AppearceRetained.doSetLive()");
0904:
0905:                if (material != null) {
0906:
0907:                    material.setLive(backgroundGroup, refCount);
0908:                }
0909:
0910:                if (texture != null) {
0911:
0912:                    texture.setLive(backgroundGroup, refCount);
0913:                }
0914:
0915:                if (texCoordGeneration != null) {
0916:
0917:                    texCoordGeneration.setLive(backgroundGroup, refCount);
0918:                }
0919:
0920:                if (textureAttributes != null) {
0921:
0922:                    textureAttributes.setLive(backgroundGroup, refCount);
0923:                }
0924:
0925:                if (texUnitState != null) {
0926:                    for (int i = 0; i < texUnitState.length; i++) {
0927:                        if (texUnitState[i] != null)
0928:                            texUnitState[i].setLive(backgroundGroup, refCount);
0929:                    }
0930:                }
0931:
0932:                if (coloringAttributes != null) {
0933:                    coloringAttributes.setLive(backgroundGroup, refCount);
0934:                }
0935:
0936:                if (transparencyAttributes != null) {
0937:                    transparencyAttributes.setLive(backgroundGroup, refCount);
0938:                }
0939:
0940:                if (renderingAttributes != null) {
0941:                    renderingAttributes.setLive(backgroundGroup, refCount);
0942:                }
0943:
0944:                if (polygonAttributes != null) {
0945:                    polygonAttributes.setLive(backgroundGroup, refCount);
0946:                }
0947:
0948:                if (lineAttributes != null) {
0949:                    lineAttributes.setLive(backgroundGroup, refCount);
0950:                }
0951:
0952:                if (pointAttributes != null) {
0953:                    pointAttributes.setLive(backgroundGroup, refCount);
0954:                }
0955:
0956:                // Increment the reference count and initialize the appearance
0957:                // mirror object
0958:                super .doSetLive(backgroundGroup, refCount);
0959:            }
0960:
0961:            /**
0962:             * This method calls the clearLive method of all appearance bundle
0963:             * objects.
0964:             */
0965:            void clearLive(int refCount) {
0966:                super .clearLive(refCount);
0967:
0968:                if (texture != null) {
0969:                    texture.clearLive(refCount);
0970:                }
0971:
0972:                if (texCoordGeneration != null) {
0973:                    texCoordGeneration.clearLive(refCount);
0974:                }
0975:
0976:                if (textureAttributes != null) {
0977:                    textureAttributes.clearLive(refCount);
0978:                }
0979:
0980:                if (texUnitState != null) {
0981:                    for (int i = 0; i < texUnitState.length; i++) {
0982:                        if (texUnitState[i] != null)
0983:                            texUnitState[i].clearLive(refCount);
0984:                    }
0985:                }
0986:
0987:                if (coloringAttributes != null) {
0988:                    coloringAttributes.clearLive(refCount);
0989:                }
0990:
0991:                if (transparencyAttributes != null) {
0992:                    transparencyAttributes.clearLive(refCount);
0993:                }
0994:
0995:                if (renderingAttributes != null) {
0996:                    renderingAttributes.clearLive(refCount);
0997:                }
0998:
0999:                if (polygonAttributes != null) {
1000:                    polygonAttributes.clearLive(refCount);
1001:                }
1002:
1003:                if (lineAttributes != null) {
1004:                    lineAttributes.clearLive(refCount);
1005:                }
1006:
1007:                if (pointAttributes != null) {
1008:                    pointAttributes.clearLive(refCount);
1009:                }
1010:
1011:                if (material != null) {
1012:                    material.clearLive(refCount);
1013:                }
1014:            }
1015:
1016:            boolean isStatic() {
1017:                boolean flag;
1018:
1019:                flag = (source.capabilityBitsEmpty()
1020:                        && ((texture == null) || texture.source
1021:                                .capabilityBitsEmpty())
1022:                        && ((texCoordGeneration == null) || texCoordGeneration.source
1023:                                .capabilityBitsEmpty())
1024:                        && ((textureAttributes == null) || textureAttributes.source
1025:                                .capabilityBitsEmpty())
1026:                        && ((coloringAttributes == null) || coloringAttributes.source
1027:                                .capabilityBitsEmpty())
1028:                        && ((transparencyAttributes == null) || transparencyAttributes.source
1029:                                .capabilityBitsEmpty())
1030:                        && ((renderingAttributes == null) || renderingAttributes.source
1031:                                .capabilityBitsEmpty())
1032:                        && ((polygonAttributes == null) || polygonAttributes.source
1033:                                .capabilityBitsEmpty())
1034:                        && ((lineAttributes == null) || lineAttributes.source
1035:                                .capabilityBitsEmpty())
1036:                        && ((pointAttributes == null) || pointAttributes.source
1037:                                .capabilityBitsEmpty()) && ((material == null) || material.source
1038:                        .capabilityBitsEmpty()));
1039:
1040:                if (!flag)
1041:                    return flag;
1042:
1043:                if (texUnitState != null) {
1044:                    for (int i = 0; i < texUnitState.length && flag; i++) {
1045:                        if (texUnitState[i] != null) {
1046:                            flag = flag && texUnitState[i].isStatic();
1047:                        }
1048:                    }
1049:                }
1050:
1051:                return flag;
1052:            }
1053:
1054:            // Issue 209 - enable this method (was previously commented out)
1055:            // Simply pass along to the NodeComponents
1056:            void compile(CompileState compState) {
1057:                setCompiled();
1058:
1059:                if (texture != null) {
1060:                    texture.compile(compState);
1061:                }
1062:
1063:                if (texCoordGeneration != null) {
1064:                    texCoordGeneration.compile(compState);
1065:                }
1066:
1067:                if (textureAttributes != null) {
1068:                    textureAttributes.compile(compState);
1069:                }
1070:
1071:                if (texUnitState != null) {
1072:                    for (int i = 0; i < texUnitState.length; i++) {
1073:                        if (texUnitState[i] != null)
1074:                            texUnitState[i].compile(compState);
1075:                    }
1076:                }
1077:
1078:                if (coloringAttributes != null) {
1079:                    coloringAttributes.compile(compState);
1080:                }
1081:
1082:                if (transparencyAttributes != null) {
1083:                    transparencyAttributes.compile(compState);
1084:                }
1085:
1086:                if (renderingAttributes != null) {
1087:                    renderingAttributes.compile(compState);
1088:                }
1089:
1090:                if (polygonAttributes != null) {
1091:                    polygonAttributes.compile(compState);
1092:                }
1093:
1094:                if (lineAttributes != null) {
1095:                    lineAttributes.compile(compState);
1096:                }
1097:
1098:                if (pointAttributes != null) {
1099:                    pointAttributes.compile(compState);
1100:                }
1101:
1102:                if (material != null) {
1103:                    material.compile(compState);
1104:                }
1105:            }
1106:
1107:            /**
1108:             * Returns the hashcode for this object.
1109:             * hashcode should be constant for object but same for two objects 
1110:             * if .equals() is true.  For an appearance (where .equals() is going
1111:             * to use the values in the appearance), the only way to have a
1112:             * constant value is for all appearances to have the same hashcode, so
1113:             * we use the hashcode of the class obj.
1114:             *
1115:             * Since hashCode is only used by AppearanceMap (at present) we may be 
1116:             * able to improve efficency by calcing a hashCode from the values.
1117:             */
1118:            public int hashCode() {
1119:                return getClass().hashCode();
1120:            }
1121:
1122:            public boolean equals(Object obj) {
1123:                return ((obj instanceof  AppearanceRetained) && equals((AppearanceRetained) obj));
1124:            }
1125:
1126:            boolean equals(AppearanceRetained app) {
1127:                boolean flag;
1128:
1129:                flag = (app == this )
1130:                        || ((app != null) && (((material == app.material) || ((material != null) && material
1131:                                .equivalent(app.material)))
1132:                                && ((texture == app.texture) || ((texture != null) && texture
1133:                                        .equals(app.texture)))
1134:                                && ((renderingAttributes == app.renderingAttributes) || ((renderingAttributes != null) && renderingAttributes
1135:                                        .equivalent(app.renderingAttributes)))
1136:                                && ((polygonAttributes == app.polygonAttributes) || ((polygonAttributes != null) && polygonAttributes
1137:                                        .equivalent(app.polygonAttributes)))
1138:                                && ((texCoordGeneration == app.texCoordGeneration) || ((texCoordGeneration != null) && texCoordGeneration
1139:                                        .equivalent(app.texCoordGeneration)))
1140:                                && ((textureAttributes == app.textureAttributes) || ((textureAttributes != null) && textureAttributes
1141:                                        .equivalent(app.textureAttributes)))
1142:                                && ((coloringAttributes == app.coloringAttributes) || ((coloringAttributes != null) && coloringAttributes
1143:                                        .equivalent(app.coloringAttributes)))
1144:                                && ((transparencyAttributes == app.transparencyAttributes) || ((transparencyAttributes != null) && transparencyAttributes
1145:                                        .equivalent(app.transparencyAttributes)))
1146:                                && ((lineAttributes == app.lineAttributes) || ((lineAttributes != null) && lineAttributes
1147:                                        .equivalent(app.lineAttributes))) && ((pointAttributes == app.pointAttributes) || ((pointAttributes != null) && pointAttributes
1148:                                .equivalent(app.pointAttributes)))));
1149:
1150:                if (!flag)
1151:                    return (flag);
1152:
1153:                if (texUnitState == app.texUnitState)
1154:                    return (flag);
1155:
1156:                if (texUnitState == null || app.texUnitState == null
1157:                        || texUnitState.length != app.texUnitState.length)
1158:                    return (false);
1159:
1160:                for (int i = 0; i < texUnitState.length; i++) {
1161:                    if (texUnitState[i] == app.texUnitState[i])
1162:                        continue;
1163:
1164:                    if (texUnitState[i] == null || app.texUnitState[i] == null
1165:                            || !texUnitState[i].equals(app.texUnitState[i]))
1166:                        return (false);
1167:                }
1168:                return (true);
1169:            }
1170:
1171:            synchronized void addAMirrorUser(Shape3DRetained shape) {
1172:
1173:                super .addAMirrorUser(shape);
1174:                if (material != null)
1175:                    material.addAMirrorUser(shape);
1176:
1177:                if (texture != null)
1178:                    texture.addAMirrorUser(shape);
1179:                if (texCoordGeneration != null)
1180:                    texCoordGeneration.addAMirrorUser(shape);
1181:                if (textureAttributes != null)
1182:                    textureAttributes.addAMirrorUser(shape);
1183:
1184:                if (texUnitState != null) {
1185:                    for (int i = 0; i < texUnitState.length; i++) {
1186:                        if (texUnitState[i] != null)
1187:                            texUnitState[i].addAMirrorUser(shape);
1188:                    }
1189:                }
1190:
1191:                if (coloringAttributes != null)
1192:                    coloringAttributes.addAMirrorUser(shape);
1193:                if (transparencyAttributes != null)
1194:                    transparencyAttributes.addAMirrorUser(shape);
1195:                if (renderingAttributes != null)
1196:                    renderingAttributes.addAMirrorUser(shape);
1197:                if (polygonAttributes != null)
1198:                    polygonAttributes.addAMirrorUser(shape);
1199:                if (lineAttributes != null)
1200:                    lineAttributes.addAMirrorUser(shape);
1201:                if (pointAttributes != null)
1202:                    pointAttributes.addAMirrorUser(shape);
1203:            }
1204:
1205:            synchronized void removeAMirrorUser(Shape3DRetained shape) {
1206:                super .removeAMirrorUser(shape);
1207:                if (material != null)
1208:                    material.removeAMirrorUser(shape);
1209:                if (texture != null)
1210:                    texture.removeAMirrorUser(shape);
1211:                if (texCoordGeneration != null)
1212:                    texCoordGeneration.removeAMirrorUser(shape);
1213:                if (textureAttributes != null)
1214:                    textureAttributes.removeAMirrorUser(shape);
1215:
1216:                if (texUnitState != null) {
1217:                    for (int i = 0; i < texUnitState.length; i++) {
1218:                        if (texUnitState[i] != null)
1219:                            texUnitState[i].removeAMirrorUser(shape);
1220:                    }
1221:                }
1222:
1223:                if (coloringAttributes != null)
1224:                    coloringAttributes.removeAMirrorUser(shape);
1225:                if (transparencyAttributes != null)
1226:                    transparencyAttributes.removeAMirrorUser(shape);
1227:                if (renderingAttributes != null)
1228:                    renderingAttributes.removeAMirrorUser(shape);
1229:                if (polygonAttributes != null)
1230:                    polygonAttributes.removeAMirrorUser(shape);
1231:                if (lineAttributes != null)
1232:                    lineAttributes.removeAMirrorUser(shape);
1233:                if (pointAttributes != null)
1234:                    pointAttributes.removeAMirrorUser(shape);
1235:            }
1236:
1237:            // 3rd argument used only when Rendering Attr comp changes
1238:            final void sendMessage(int attrMask, Object attr, boolean visible) {
1239:                ArrayList univList = new ArrayList();
1240:                ArrayList gaList = Shape3DRetained.getGeomAtomsList(
1241:                        mirror.users, univList);
1242:                // Send to rendering attribute structure, regardless of
1243:                // whether there are users or not (alternate appearance case ..)
1244:                J3dMessage createMessage = new J3dMessage();
1245:                createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES;
1246:                createMessage.type = J3dMessage.APPEARANCE_CHANGED;
1247:                createMessage.universe = null;
1248:                createMessage.args[0] = this ;
1249:                createMessage.args[1] = new Integer(attrMask);
1250:                createMessage.args[2] = attr;
1251:                createMessage.args[3] = new Integer(changedFrequent);
1252:
1253:                VirtualUniverse.mc.processMessage(createMessage);
1254:
1255:                // System.err.println("univList.size is " + univList.size());
1256:                for (int i = 0; i < univList.size(); i++) {
1257:                    createMessage = new J3dMessage();
1258:                    createMessage.threads = J3dThread.UPDATE_RENDER;
1259:                    createMessage.type = J3dMessage.APPEARANCE_CHANGED;
1260:
1261:                    createMessage.universe = (VirtualUniverse) univList.get(i);
1262:                    createMessage.args[0] = this ;
1263:                    createMessage.args[1] = new Integer(attrMask);
1264:                    createMessage.args[2] = attr;
1265:
1266:                    ArrayList gL = (ArrayList) gaList.get(i);
1267:                    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
1268:                    gL.toArray(gaArr);
1269:                    createMessage.args[3] = gaArr;
1270:                    // Send the value itself, since Geometry Structure cannot rely on the
1271:                    // mirror (which may be updated lazily)
1272:                    if (attrMask == RENDERING) {
1273:                        if (attr != null) {
1274:                            createMessage.args[4] = visible ? Boolean.TRUE
1275:                                    : Boolean.FALSE;
1276:                        } else {
1277:                            createMessage.args[4] = Boolean.TRUE;
1278:                        }
1279:                    }
1280:                    VirtualUniverse.mc.processMessage(createMessage);
1281:                }
1282:            }
1283:
1284:            final void sendRenderingAttributesChangedMessage(boolean visible) {
1285:
1286:                ArrayList univList = new ArrayList();
1287:                ArrayList gaList = Shape3DRetained.getGeomAtomsList(
1288:                        mirror.users, univList);
1289:
1290:                // System.err.println("univList.size is " + univList.size());
1291:                for (int i = 0; i < univList.size(); i++) {
1292:                    J3dMessage createMessage = new J3dMessage();
1293:                    createMessage.threads = J3dThread.UPDATE_GEOMETRY;
1294:                    createMessage.type = J3dMessage.RENDERINGATTRIBUTES_CHANGED;
1295:
1296:                    createMessage.universe = (VirtualUniverse) univList.get(i);
1297:                    createMessage.args[0] = this ;
1298:                    createMessage.args[1] = null; // Sync with RenderingAttrRetained sendMessage
1299:                    createMessage.args[2] = visible ? Boolean.TRUE
1300:                            : Boolean.FALSE;
1301:
1302:                    ArrayList gL = (ArrayList) gaList.get(i);
1303:                    GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
1304:                    gL.toArray(gaArr);
1305:                    createMessage.args[3] = gaArr;
1306:                    VirtualUniverse.mc.processMessage(createMessage);
1307:                }
1308:            }
1309:
1310:            boolean isOpaque(int geoType) {
1311:                TransparencyAttributesRetained ta;
1312:                int i;
1313:
1314:                ta = transparencyAttributes;
1315:                if (ta != null
1316:                        && ta.transparencyMode != TransparencyAttributes.NONE
1317:                        && (VirtualUniverse.mc.isD3D() || (!VirtualUniverse.mc
1318:                                .isD3D() && (ta.transparencyMode != TransparencyAttributes.SCREEN_DOOR)))) {
1319:                    return (false);
1320:                }
1321:
1322:                switch (geoType) {
1323:                case GeometryRetained.GEO_TYPE_POINT_SET:
1324:                case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
1325:                    if ((pointAttributes != null)
1326:                            && pointAttributes.pointAntialiasing) {
1327:                        return (false);
1328:                    }
1329:                    break;
1330:                case GeometryRetained.GEO_TYPE_LINE_SET:
1331:                case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
1332:                case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
1333:                case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
1334:                    if ((lineAttributes != null)
1335:                            && lineAttributes.lineAntialiasing) {
1336:                        return (false);
1337:                    }
1338:                    break;
1339:                case GeometryRetained.GEO_TYPE_RASTER:
1340:                case GeometryRetained.GEO_TYPE_COMPRESSED:
1341:                    break;
1342:                default:
1343:                    if (polygonAttributes != null) {
1344:                        if ((polygonAttributes.polygonMode == PolygonAttributes.POLYGON_POINT)
1345:                                && (pointAttributes != null)
1346:                                && pointAttributes.pointAntialiasing) {
1347:                            return (false);
1348:                        } else if ((polygonAttributes.polygonMode == PolygonAttributes.POLYGON_LINE)
1349:                                && (lineAttributes != null)
1350:                                && lineAttributes.lineAntialiasing) {
1351:                            return (false);
1352:                        }
1353:                    }
1354:                    break;
1355:                }
1356:
1357:                return (true);
1358:            }
1359:
1360:            void handleFrequencyChange(int bit) {
1361:                int mask = 0;
1362:                if (bit == Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE)
1363:                    mask = COLOR;
1364:                else if (bit == Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE)
1365:                    mask = TRANSPARENCY;
1366:                else if (bit == Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE)
1367:                    mask = RENDERING;
1368:                else if (bit == Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE)
1369:                    mask = POLYGON;
1370:                else if (bit == Appearance.ALLOW_LINE_ATTRIBUTES_WRITE)
1371:                    mask = LINE;
1372:                else if (bit == Appearance.ALLOW_POINT_ATTRIBUTES_WRITE)
1373:                    mask = POINT;
1374:                else if (bit == Appearance.ALLOW_MATERIAL_WRITE)
1375:                    mask = MATERIAL;
1376:                else if (bit == Appearance.ALLOW_TEXTURE_WRITE)
1377:                    mask = TEXTURE;
1378:                else if (bit == Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE)
1379:                    mask = TEXTURE_ATTR;
1380:                else if (bit == Appearance.ALLOW_TEXGEN_WRITE)
1381:                    mask = TEXCOORD_GEN;
1382:                else if (bit == Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE)
1383:                    mask = TEXTURE_UNIT_STATE;
1384:
1385:                if (mask != 0)
1386:                    setFrequencyChangeMask(bit, mask);
1387:            }
1388:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.