Source Code Cross Referenced for LinearFog.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: LinearFog.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.6 $
028:         * $Date: 2008/02/28 20:17:25 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Color3f;
035:
036:        /**
037:         * The LinearFog leaf node defines fog distance parameters for
038:         * linear fog.
039:         * LinearFog extends the Fog node by adding a pair of distance values,
040:         * in Z, at which the fog should start obscuring the scene and should maximally
041:         * obscure the scene.
042:         * <P>
043:         * The front and back fog distances are defined in the local coordinate system of
044:         * the node, but the actual fog equation will ideally take place in eye
045:         * coordinates.
046:         * <P>
047:         * The linear fog blending factor, <code>f</code>, is computed as follows:
048:         * <ul>
049:         * <code>f = (backDistance - z) / (backDistance - frontDistance)</code>
050:         * </ul>
051:         * where:
052:         * <ul>
053:         * <code>z</code> is the distance from the viewpoint.<br>
054:         * <code>frontDistance</code> is the distance at which fog starts obscuring objects.<br>
055:         * <code>backDistance</code> is the distance at which fog totally obscurs objects.
056:         * </ul>
057:         */
058:        public class LinearFog extends Fog {
059:            /**
060:             * Specifies that this LinearFog node allows read access to its distance
061:             * information.
062:             */
063:            public static final int ALLOW_DISTANCE_READ = CapabilityBits.LINEAR_FOG_ALLOW_DISTANCE_READ;
064:
065:            /**
066:             * Specifies that this LinearFog node allows write access to its distance
067:             * information.
068:             */
069:            public static final int ALLOW_DISTANCE_WRITE = CapabilityBits.LINEAR_FOG_ALLOW_DISTANCE_WRITE;
070:
071:            // Array for setting default read capabilities
072:            private static final int[] readCapabilities = { ALLOW_DISTANCE_READ };
073:
074:            /**
075:             * Constructs a LinearFog node with default parameters.
076:             * The default values are as follows:
077:             * <ul>
078:             * front distance : 0.1<br>
079:             * back distance : 1.0<br>
080:             * </ul>
081:             */
082:            public LinearFog() {
083:                // Just use the defaults
084:                // set default read capabilities
085:                setDefaultReadCapabilities(readCapabilities);
086:            }
087:
088:            /**
089:             * Constructs a LinearFog node with the specified fog color.
090:             * @param color the fog color
091:             */
092:            public LinearFog(Color3f color) {
093:                super (color);
094:
095:                // set default read capabilities
096:                setDefaultReadCapabilities(readCapabilities);
097:            }
098:
099:            /**
100:             * Constructs a LinearFog node with the specified fog color and distances.
101:             * @param color the fog color
102:             * @param frontDistance the front   distance for the fog
103:             * @param backDistance the back   distance for the fog
104:             */
105:            public LinearFog(Color3f color, double frontDistance,
106:                    double backDistance) {
107:                super (color);
108:
109:                // set default read capabilities
110:                setDefaultReadCapabilities(readCapabilities);
111:
112:                ((LinearFogRetained) this .retained)
113:                        .initFrontDistance(frontDistance);
114:                ((LinearFogRetained) this .retained)
115:                        .initBackDistance(backDistance);
116:            }
117:
118:            /**
119:             * Constructs a LinearFog node with the specified fog color.
120:             * @param r the red component of the fog color
121:             * @param g the green component of the fog color
122:             * @param b the blue component of the fog color
123:             */
124:            public LinearFog(float r, float g, float b) {
125:                super (r, g, b);
126:
127:                // set default read capabilities
128:                setDefaultReadCapabilities(readCapabilities);
129:            }
130:
131:            /**
132:             * Constructs a LinearFog node with the specified fog color and distances.
133:             * @param r the red component of the fog color
134:             * @param g the green component of the fog color
135:             * @param b the blue component of the fog color
136:             * @param frontDistance the front   distance for the fog
137:             * @param backDistance the back   distance for the fog
138:             */
139:            public LinearFog(float r, float g, float b, double frontDistance,
140:                    double backDistance) {
141:                super (r, g, b);
142:
143:                // set default read capabilities
144:                setDefaultReadCapabilities(readCapabilities);
145:
146:                ((LinearFogRetained) this .retained)
147:                        .initFrontDistance(frontDistance);
148:                ((LinearFogRetained) this .retained)
149:                        .initBackDistance(backDistance);
150:            }
151:
152:            /**
153:             * Sets front distance for fog.
154:             * @param frontDistance the distance at which fog starts obscuring objects
155:             * @exception CapabilityNotSetException if appropriate capability is
156:             * not set and this object is part of live or compiled scene graph
157:             */
158:            public void setFrontDistance(double frontDistance) {
159:                if (isLiveOrCompiled())
160:                    if (!this .getCapability(ALLOW_DISTANCE_WRITE))
161:                        throw new CapabilityNotSetException(J3dI18N
162:                                .getString("LinearFog0"));
163:
164:                if (isLive())
165:                    ((LinearFogRetained) this .retained)
166:                            .setFrontDistance(frontDistance);
167:                else
168:                    ((LinearFogRetained) this .retained)
169:                            .initFrontDistance(frontDistance);
170:
171:            }
172:
173:            /**
174:             * Gets front distance for fog.
175:             * @return  the distance at which fog starts obscuring objects
176:             * @exception CapabilityNotSetException if appropriate capability is
177:             * not set and this object is part of live or compiled scene graph
178:             */
179:            public double getFrontDistance() {
180:                if (isLiveOrCompiled())
181:                    if (!this .getCapability(ALLOW_DISTANCE_READ))
182:                        throw new CapabilityNotSetException(J3dI18N
183:                                .getString("LinearFog1"));
184:
185:                return ((LinearFogRetained) this .retained).getFrontDistance();
186:            }
187:
188:            /**
189:             * Sets back distance for fog.
190:             * @param backDistance the distance at which fog totally obscurs objects
191:             * @exception CapabilityNotSetException if appropriate capability is
192:             * not set and this object is part of live or compiled scene graph
193:             */
194:            public void setBackDistance(double backDistance) {
195:                if (isLiveOrCompiled())
196:                    if (!this .getCapability(ALLOW_DISTANCE_WRITE))
197:                        throw new CapabilityNotSetException(J3dI18N
198:                                .getString("LinearFog0"));
199:                if (isLive())
200:                    ((LinearFogRetained) this .retained)
201:                            .setBackDistance(backDistance);
202:                else
203:                    ((LinearFogRetained) this .retained)
204:                            .initBackDistance(backDistance);
205:
206:            }
207:
208:            /**
209:             * Gets back distance for fog.
210:             * @return the distance at which fog totally obscurs objects
211:             * @exception CapabilityNotSetException if appropriate capability is
212:             * not set and this object is part of live or compiled scene graph
213:             */
214:            public double getBackDistance() {
215:                if (isLiveOrCompiled())
216:                    if (!this .getCapability(ALLOW_DISTANCE_READ))
217:                        throw new CapabilityNotSetException(J3dI18N
218:                                .getString("LinearFog1"));
219:
220:                return ((LinearFogRetained) this .retained).getBackDistance();
221:            }
222:
223:            /**
224:             * Creates the retained mode LinearFogRetained object that this
225:             * LinearFog node will point to.
226:             */
227:            void createRetained() {
228:                this .retained = new LinearFogRetained();
229:                this .retained.setSource(this );
230:            }
231:
232:            /**
233:             * Used to create a new instance of the node.  This routine is called
234:             * by <code>cloneTree</code> to duplicate the current node.
235:             * @param forceDuplicate when set to <code>true</code>, causes the
236:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
237:             *  <code>false</code>, the value of each node's
238:             *  <code>duplicateOnCloneTree</code> variable determines whether
239:             *  NodeComponent data is duplicated or copied.
240:             *
241:             * @see Node#cloneTree
242:             * @see Node#cloneNode
243:             * @see Node#duplicateNode
244:             * @see NodeComponent#setDuplicateOnCloneTree
245:             */
246:            public Node cloneNode(boolean forceDuplicate) {
247:                LinearFog lf = new LinearFog();
248:                lf.duplicateNode(this , forceDuplicate);
249:                return lf;
250:            }
251:
252:            /**
253:             * Copies all LinearFog information from
254:             * <code>originalNode</code> into
255:             * the current node.  This method is called from the
256:             * <code>cloneNode</code> method which is, in turn, called by the
257:             * <code>cloneTree</code> method.<P> 
258:             *
259:             * @param originalNode the original node to duplicate.
260:             * @param forceDuplicate when set to <code>true</code>, causes the
261:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
262:             *  <code>false</code>, the value of each node's
263:             *  <code>duplicateOnCloneTree</code> variable determines whether
264:             *  NodeComponent data is duplicated or copied.
265:             *
266:             * @exception RestrictedAccessException if this object is part of a live
267:             *  or compiled scenegraph.
268:             *
269:             * @see Node#duplicateNode
270:             * @see Node#cloneTree
271:             * @see NodeComponent#setDuplicateOnCloneTree
272:             */
273:            void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
274:                super .duplicateAttributes(originalNode, forceDuplicate);
275:
276:                LinearFogRetained attr = (LinearFogRetained) originalNode.retained;
277:                LinearFogRetained rt = (LinearFogRetained) retained;
278:
279:                rt.initFrontDistance(attr.getFrontDistance());
280:                rt.initBackDistance(attr.getBackDistance());
281:            }
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.