Source Code Cross Referenced for ExponentialFogRetained.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: ExponentialFogRetained.java,v $
003:         *
004:         * Copyright 1997-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:21 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Color3f;
035:        import java.util.ArrayList;
036:
037:        /**
038:         * The ExponentialFog leaf node defines distance parameters for
039:         * exponential fog.
040:         */
041:        class ExponentialFogRetained extends FogRetained {
042:            // Fog density
043:            private float density = 1.0f;
044:
045:            // Issue 144: density in Eye Coordinates (EC)
046:            private float densityInEc;
047:
048:            // dirty bits for ExponentialFog
049:            static final int DENSITY_CHANGED = FogRetained.LAST_DEFINED_BIT << 1;
050:
051:            ExponentialFogRetained() {
052:                this .nodeType = NodeRetained.EXPONENTIALFOG;
053:            }
054:
055:            /**
056:             * initializes fog density
057:             */
058:            void initDensity(float density) {
059:                this .density = density;
060:            }
061:
062:            /**
063:             * Sets fog density and send a message
064:             */
065:            void setDensity(float density) {
066:                this .density = density;
067:                J3dMessage createMessage = new J3dMessage();
068:                createMessage.threads = targetThreads;
069:                createMessage.type = J3dMessage.FOG_CHANGED;
070:                createMessage.universe = universe;
071:                createMessage.args[0] = this ;
072:                createMessage.args[1] = new Integer(DENSITY_CHANGED);
073:                createMessage.args[2] = new Float(density);
074:                VirtualUniverse.mc.processMessage(createMessage);
075:            }
076:
077:            /**
078:             * Gets fog density
079:             */
080:            float getDensity() {
081:                return this .density;
082:            }
083:
084:            void setLive(SetLiveState s) {
085:                super .setLive(s);
086:                GroupRetained group;
087:
088:                // Initialize the mirror object, this needs to be done, when
089:                // renderBin is not accessing any of the fields
090:                J3dMessage createMessage = new J3dMessage();
091:                createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
092:                createMessage.universe = universe;
093:                createMessage.type = J3dMessage.FOG_CHANGED;
094:                createMessage.args[0] = this ;
095:                // a snapshot of all attributes that needs to be initialized
096:                // in the mirror object
097:                createMessage.args[1] = new Integer(INIT_MIRROR);
098:                ArrayList addScopeList = new ArrayList();
099:                for (int i = 0; i < scopes.size(); i++) {
100:                    group = (GroupRetained) scopes.get(i);
101:                    tempKey.reset();
102:                    group.addAllNodesForScopedFog(mirrorFog, addScopeList,
103:                            tempKey);
104:                }
105:                Object[] scopeInfo = new Object[2];
106:                scopeInfo[0] = ((scopes.size() > 0) ? Boolean.TRUE
107:                        : Boolean.FALSE);
108:                scopeInfo[1] = addScopeList;
109:                createMessage.args[2] = scopeInfo;
110:                Color3f clr = new Color3f(color);
111:                createMessage.args[3] = clr;
112:
113:                Object[] obj = new Object[5];
114:                obj[0] = boundingLeaf;
115:                obj[1] = (regionOfInfluence != null ? regionOfInfluence.clone()
116:                        : null);
117:                obj[2] = (inBackgroundGroup ? Boolean.TRUE : Boolean.FALSE);
118:                obj[3] = geometryBackground;
119:                obj[4] = new Float(density);
120:
121:                createMessage.args[4] = obj;
122:                VirtualUniverse.mc.processMessage(createMessage);
123:
124:            }
125:
126:            /** 
127:             * This method and its native counterpart update the native context
128:             * fog values.
129:             */
130:            void update(Context ctx, double scale) {
131:                // Issue 144: recompute the density in EC, and send it to native code
132:                validateDistancesInEc(scale);
133:                Pipeline.getPipeline().updateExponentialFog(ctx, color.x,
134:                        color.y, color.z, densityInEc);
135:            }
136:
137:            // The update Object function.
138:            // Note : if you add any more fields here , you need to update
139:            // updateFog() in RenderingEnvironmentStructure
140:            void updateMirrorObject(Object[] objs) {
141:
142:                int component = ((Integer) objs[1]).intValue();
143:
144:                if ((component & DENSITY_CHANGED) != 0)
145:                    ((ExponentialFogRetained) mirrorFog).density = ((Float) objs[2])
146:                            .floatValue();
147:
148:                if ((component & INIT_MIRROR) != 0) {
149:                    ((ExponentialFogRetained) mirrorFog).density = ((Float) ((Object[]) objs[4])[4])
150:                            .floatValue();
151:
152:                }
153:                // Issue 144: store the local to vworld scale used to transform the density
154:                ((ExponentialFogRetained) mirrorFog)
155:                        .setLocalToVworldScale(getLastLocalToVworld()
156:                                .getDistanceScale());
157:
158:                super .updateMirrorObject(objs);
159:            }
160:
161:            // Clone the retained side only, internal use only	
162:            protected Object clone() {
163:                ExponentialFogRetained efr = (ExponentialFogRetained) super 
164:                        .clone();
165:
166:                efr.initDensity(getDensity());
167:
168:                return efr;
169:            }
170:
171:            // Issue 144: method to recompute the density in EC by multiplying the specified
172:            // density by the inverse of the local to EC scale
173:            /**
174:             * Scale distances from local to eye coordinate.
175:             */
176:            protected void validateDistancesInEc(double vworldToCoexistenceScale) {
177:                // vworldToCoexistenceScale can be used here since
178:                // CoexistenceToEc has a unit scale
179:                double localToEcScale = getLocalToVworldScale()
180:                        * vworldToCoexistenceScale;
181:
182:                densityInEc = (float) (density / localToEcScale);
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.