Source Code Cross Referenced for RenderingAttributesStructure.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: RenderingAttributesStructure.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.7 $
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:        import java.util.Arrays;
036:
037:        /**
038:         * A rendering attributes structure is an object that handles 
039:         * NodeComponent object updates.
040:         */
041:
042:        class RenderingAttributesStructure extends J3dStructure implements 
043:                ObjectUpdate {
044:            // List of textures whose resourceCreation mask should be updated
045:            ArrayList objList = new ArrayList();
046:
047:            RenderingAttributesStructure() {
048:                super (null, J3dThread.UPDATE_RENDERING_ATTRIBUTES);
049:            }
050:
051:            void processMessages(long referenceTime) {
052:                J3dMessage m;
053:                boolean addMirrorObj = false;
054:
055:                J3dMessage messages[] = getMessages(referenceTime);
056:                int nMsg = getNumMessage();
057:
058:                if (nMsg <= 0) {
059:                    return;
060:                }
061:
062:                for (int i = 0; i < nMsg; i++) {
063:                    m = messages[i];
064:                    switch (m.type) {
065:                    // Appearance is always updated immediately, since rBin needs
066:                    // the most up-to-date values for restructuring
067:                    case J3dMessage.APPEARANCE_CHANGED:
068:                    case J3dMessage.SHADER_APPEARANCE_CHANGED:
069:                    case J3dMessage.TEXTURE_UNIT_STATE_CHANGED: {
070:                        // System.err.println("1 RAS : J3dMessage type : " + m.type);
071:                        int component = ((Integer) m.args[1]).intValue();
072:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
073:                        nc.mirror.changedFrequent = ((Integer) m.args[3])
074:                                .intValue();
075:                        updateNodeComponent((Object[]) m.args);
076:                        if (nc.mirror.changedFrequent != 0) {
077:                            objList.add(m);
078:                            addMirrorObj = true;
079:                            nc.mirror.compChanged |= component;
080:                        } else {
081:                            m.decRefcount();
082:                        }
083:                    }
084:                        break;
085:                    case J3dMessage.COLORINGATTRIBUTES_CHANGED:
086:                    case J3dMessage.LINEATTRIBUTES_CHANGED:
087:                    case J3dMessage.POINTATTRIBUTES_CHANGED:
088:                    case J3dMessage.POLYGONATTRIBUTES_CHANGED:
089:                    case J3dMessage.RENDERINGATTRIBUTES_CHANGED:
090:                    case J3dMessage.TRANSPARENCYATTRIBUTES_CHANGED:
091:                    case J3dMessage.MATERIAL_CHANGED:
092:                    case J3dMessage.TEXCOORDGENERATION_CHANGED:
093:                    case J3dMessage.SHADER_ATTRIBUTE_CHANGED:
094:                    case J3dMessage.SHADER_ATTRIBUTE_SET_CHANGED: {
095:                        // System.err.println("2 RAS : J3dMessage type : " + m.type);
096:
097:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
098:                        nc.mirror.changedFrequent = ((Integer) m.args[3])
099:                                .intValue();
100:                        if (nc.mirror.changedFrequent != 0) {
101:                            objList.add(m);
102:                            addMirrorObj = true;
103:                            nc.mirror.compChanged = 1;
104:                        } else {
105:                            updateNodeComponent((Object[]) m.args);
106:                            m.decRefcount();
107:                        }
108:                    }
109:                        break;
110:                    case J3dMessage.IMAGE_COMPONENT_CHANGED: {
111:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
112:                        int changes = ((Integer) m.args[3]).intValue();
113:                        if (nc.mirror != null)
114:                            nc.mirror.changedFrequent = changes;
115:                        if (changes != 0) {
116:                            objList.add(m);
117:                            addMirrorObj = true;
118:                        } else {
119:                            updateNodeComponent((Object[]) m.args);
120:                            m.decRefcount();
121:                        }
122:                    }
123:                        break;
124:                    case J3dMessage.TEXTUREATTRIBUTES_CHANGED: {
125:
126:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
127:                        nc.mirror.changedFrequent = ((Integer) m.args[4])
128:                                .intValue();
129:
130:                        if (nc.mirror.changedFrequent != 0) {
131:                            objList.add(m);
132:                            addMirrorObj = true;
133:                            nc.mirror.compChanged = 1;
134:                        } else {
135:                            updateTextureAttributes((Object[]) m.args);
136:                            m.decRefcount();
137:                        }
138:                    }
139:                        break;
140:                    case J3dMessage.TEXTURE_CHANGED: {
141:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
142:                        nc.mirror.changedFrequent = ((Integer) m.args[3])
143:                                .intValue();
144:
145:                        objList.add(m);
146:                        nc.mirror.compChanged = 1;
147:                        addMirrorObj = true;
148:                    }
149:                        break;
150:                    case J3dMessage.GEOMETRY_CHANGED:
151:                        GeometryRetained geo = (GeometryRetained) m.args[1];
152:                        int val;
153:                        if (geo instanceof  IndexedGeometryArrayRetained) {
154:                            objList.add(m);
155:                            addMirrorObj = true;
156:                            if (m.args[2] == null) {
157:                                val = ((Integer) m.args[3]).intValue();
158:                                geo.cachedChangedFrequent = val;
159:                            }
160:                        } else {
161:                            val = ((Integer) m.args[3]).intValue();
162:                            geo.cachedChangedFrequent = val;
163:                            m.decRefcount();
164:                        }
165:                        break;
166:                    case J3dMessage.MORPH_CHANGED:
167:                        objList.add(m);
168:                        addMirrorObj = true;
169:                        break;
170:                    default:
171:                        m.decRefcount();
172:                    }
173:                }
174:                if (addMirrorObj) {
175:                    VirtualUniverse.mc.addMirrorObject(this );
176:                }
177:
178:                // clear array to prevent memory leaks
179:                Arrays.fill(messages, 0, nMsg, null);
180:            }
181:
182:            public void updateObject() {
183:
184:                int size = objList.size();
185:                for (int i = 0; i < size; i++) {
186:                    J3dMessage m = (J3dMessage) objList.get(i);
187:                    // Message Only sent to RenderingAttributesStructure
188:                    // when the geometry type is indexed
189:                    if (m.type == J3dMessage.GEOMETRY_CHANGED) {
190:                        GeometryArrayRetained geo = (GeometryArrayRetained) m.args[1];
191:                        if (m.args[2] == null) {
192:                            geo.updateMirrorGeometry();
193:                        } else {
194:                            geo.initMirrorGeometry();
195:                        }
196:                    } else if (m.type == J3dMessage.MORPH_CHANGED) {
197:                        MorphRetained morph = (MorphRetained) m.args[0];
198:                        GeometryArrayRetained geo = (GeometryArrayRetained) morph.morphedGeometryArray.retained;
199:                        geo.updateMirrorGeometry();
200:                    } else if (m.type == J3dMessage.TEXTUREATTRIBUTES_CHANGED) {
201:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
202:                        nc.mirror.compChanged = 0;
203:                        updateTextureAttributes((Object[]) m.args);
204:                    } else if (m.type == J3dMessage.APPEARANCE_CHANGED
205:                            || m.type == J3dMessage.SHADER_APPEARANCE_CHANGED
206:                            || m.type == J3dMessage.TEXTURE_UNIT_STATE_CHANGED) {
207:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
208:                        nc.mirror.compChanged = 0;
209:                    } else {
210:                        NodeComponentRetained nc = (NodeComponentRetained) m.args[0];
211:                        if (nc.mirror != null)
212:                            nc.mirror.compChanged = 0;
213:                        updateNodeComponent(m.args);
214:                    }
215:                    m.decRefcount();
216:                }
217:                objList.clear();
218:            }
219:
220:            private void updateNodeComponent(Object[] args) {
221:                // System.err.println("RAS : updateNodeComponent : " + this);	    
222:                NodeComponentRetained n = (NodeComponentRetained) args[0];
223:                n.updateMirrorObject(((Integer) args[1]).intValue(), args[2]);
224:            }
225:
226:            private void updateTextureAttributes(Object[] args) {
227:                TextureAttributesRetained n = (TextureAttributesRetained) args[0];
228:                n.updateMirrorObject(((Integer) args[1]).intValue(), args[2],
229:                        args[3]);
230:            }
231:
232:            void removeNodes(J3dMessage m) {
233:            }
234:
235:            void cleanup() {
236:            }
237:
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.