Source Code Cross Referenced for LinearFogRetained.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: LinearFogRetained.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:25 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.Vector;
035:        import javax.vecmath.*;
036:        import java.util.ArrayList;
037:
038:        /**
039:         * The LinearFog leaf node defines distance parameters for
040:         * linear fog.
041:         */
042:        class LinearFogRetained extends FogRetained {
043:            /**
044:             * Fog front and back   distance
045:             */
046:            private double frontDistance = 0.1;
047:            private double backDistance = 1.0;
048:            private double frontDistanceInEc;
049:            private double backDistanceInEc;
050:
051:            // dirty bits for LinearFog
052:            static final int FRONT_DISTANCE_CHANGED = FogRetained.LAST_DEFINED_BIT << 1;
053:            static final int BACK_DISTANCE_CHANGED = FogRetained.LAST_DEFINED_BIT << 2;
054:
055:            LinearFogRetained() {
056:                this .nodeType = NodeRetained.LINEARFOG;
057:            }
058:
059:            /**
060:             * Initializes front  distance for fog before the object is live
061:             */
062:            void initFrontDistance(double frontDistance) {
063:                this .frontDistance = frontDistance;
064:            }
065:
066:            /**
067:             * Sets front   distance for fog and sends a message
068:             */
069:            void setFrontDistance(double frontDistance) {
070:                this .frontDistance = frontDistance;
071:                J3dMessage createMessage = new J3dMessage();
072:                createMessage.threads = targetThreads;
073:                createMessage.type = J3dMessage.FOG_CHANGED;
074:                createMessage.universe = universe;
075:                createMessage.args[0] = this ;
076:                createMessage.args[1] = new Integer(FRONT_DISTANCE_CHANGED);
077:                createMessage.args[2] = new Double(frontDistance);
078:                VirtualUniverse.mc.processMessage(createMessage);
079:
080:            }
081:
082:            /**
083:             * Gets front   distance for fog
084:             */
085:            double getFrontDistance() {
086:                return this .frontDistance;
087:            }
088:
089:            /**
090:             * Initializes back   distance for fog
091:             */
092:            void initBackDistance(double backDistance) {
093:                this .backDistance = backDistance;
094:            }
095:
096:            /**
097:             * Sets back  distance for fog
098:             */
099:            void setBackDistance(double backDistance) {
100:                this .backDistance = backDistance;
101:                J3dMessage createMessage = new J3dMessage();
102:                createMessage.threads = targetThreads;
103:                createMessage.type = J3dMessage.FOG_CHANGED;
104:                createMessage.universe = universe;
105:                createMessage.args[0] = this ;
106:                createMessage.args[1] = new Integer(BACK_DISTANCE_CHANGED);
107:                createMessage.args[2] = new Double(backDistance);
108:                VirtualUniverse.mc.processMessage(createMessage);
109:            }
110:
111:            /**
112:             * Gets back   distance for fog
113:             */
114:            double getBackDistance() {
115:                return this .backDistance;
116:            }
117:
118:            /** 
119:             * This method and its native counterpart update the native context
120:             * fog values.
121:             */
122:            void update(Context ctx, double scale) {
123:                validateDistancesInEc(scale);
124:                Pipeline.getPipeline().updateLinearFog(ctx, color.x, color.y,
125:                        color.z, frontDistanceInEc, backDistanceInEc);
126:            }
127:
128:            void setLive(SetLiveState s) {
129:                GroupRetained group;
130:
131:                super .setLive(s);
132:
133:                // Initialize the mirror object, this needs to be done, when
134:                // renderBin is not accessing any of the fields
135:                J3dMessage createMessage = new J3dMessage();
136:                createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
137:                createMessage.universe = universe;
138:                createMessage.type = J3dMessage.FOG_CHANGED;
139:                createMessage.args[0] = this ;
140:                // a snapshot of all attributes that needs to be initialized
141:                // in the mirror object
142:                createMessage.args[1] = new Integer(INIT_MIRROR);
143:                ArrayList addScopeList = new ArrayList();
144:                for (int i = 0; i < scopes.size(); i++) {
145:                    group = (GroupRetained) scopes.get(i);
146:                    tempKey.reset();
147:                    group.addAllNodesForScopedFog(mirrorFog, addScopeList,
148:                            tempKey);
149:                }
150:                Object[] scopeInfo = new Object[2];
151:                scopeInfo[0] = ((scopes.size() > 0) ? Boolean.TRUE
152:                        : Boolean.FALSE);
153:                scopeInfo[1] = addScopeList;
154:                createMessage.args[2] = scopeInfo;
155:                Color3f clr = new Color3f(color);
156:                createMessage.args[3] = clr;
157:
158:                Object[] obj = new Object[6];
159:                obj[0] = boundingLeaf;
160:                obj[1] = (regionOfInfluence != null ? regionOfInfluence.clone()
161:                        : null);
162:                obj[2] = (inBackgroundGroup ? Boolean.TRUE : Boolean.FALSE);
163:                obj[3] = geometryBackground;
164:                obj[4] = new Double(frontDistance);
165:                obj[5] = new Double(backDistance);
166:
167:                createMessage.args[4] = obj;
168:                VirtualUniverse.mc.processMessage(createMessage);
169:
170:            }
171:
172:            // The update Object function.
173:            // Note : if you add any more fields here , you need to update
174:            // updateFog() in RenderingEnvironmentStructure
175:            synchronized void updateMirrorObject(Object[] objs) {
176:
177:                int component = ((Integer) objs[1]).intValue();
178:                Transform3D trans;
179:
180:                if ((component & FRONT_DISTANCE_CHANGED) != 0)
181:                    ((LinearFogRetained) mirrorFog).frontDistance = ((Double) objs[2])
182:                            .doubleValue();
183:                if ((component & BACK_DISTANCE_CHANGED) != 0)
184:                    ((LinearFogRetained) mirrorFog).backDistance = ((Double) objs[2])
185:                            .doubleValue();
186:                if ((component & INIT_MIRROR) != 0) {
187:                    ((LinearFogRetained) mirrorFog).frontDistance = ((Double) ((Object[]) objs[4])[4])
188:                            .doubleValue();
189:                    ((LinearFogRetained) mirrorFog).backDistance = ((Double) ((Object[]) objs[4])[5])
190:                            .doubleValue();
191:
192:                }
193:                ((LinearFogRetained) mirrorFog)
194:                        .setLocalToVworldScale(getLastLocalToVworld()
195:                                .getDistanceScale());
196:
197:                super .updateMirrorObject(objs);
198:            }
199:
200:            /**
201:             * Scale distances from local to eye coordinate
202:             */
203:            protected void validateDistancesInEc(double vworldToCoexistenceScale) {
204:                // vworldToCoexistenceScale can be used here since
205:                // CoexistenceToEc has a unit scale
206:                double localToEcScale = getLocalToVworldScale()
207:                        * vworldToCoexistenceScale;
208:
209:                frontDistanceInEc = frontDistance * localToEcScale;
210:                backDistanceInEc = backDistance * localToEcScale;
211:            }
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.