Source Code Cross Referenced for ExponentialFog.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: ExponentialFog.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:21 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Color3f;
035:
036:        /**
037:         * The ExponentialFog leaf node extends the Fog leaf node by adding a
038:         * fog density that is used as the exponent of the fog equation. The
039:         * density is defined in the local coordinate system of the node, but
040:         * the actual fog equation will ideally take place in eye coordinates.
041:         * <P>
042:         * The fog blending factor, f, is computed as follows:
043:         * <P><UL>
044:         * f = e<sup>-(density * z)</sup><P>
045:         * where
046:         * <ul>z is the distance from the viewpoint.<br>
047:         * density is the density of the fog.<P></ul></UL>
048:         * 
049:         * In addition to specifying the fog density, ExponentialFog lets you
050:         * specify the fog color, which is represented by R, G, and B
051:         * color values, where a color of (0,0,0) represents black.
052:         */
053:        public class ExponentialFog extends Fog {
054:            /**
055:             * Specifies that this ExponentialFog node allows read access to its
056:             * density information.
057:             */
058:            public static final int ALLOW_DENSITY_READ = CapabilityBits.EXPONENTIAL_FOG_ALLOW_DENSITY_READ;
059:
060:            /**
061:             * Specifies that this ExponentialFog node allows write access to its
062:             * density information.
063:             */
064:            public static final int ALLOW_DENSITY_WRITE = CapabilityBits.EXPONENTIAL_FOG_ALLOW_DENSITY_WRITE;
065:
066:            // Array for setting default read capabilities
067:            private static final int[] readCapabilities = { ALLOW_DENSITY_READ };
068:
069:            /**
070:             * Constructs an ExponentialFog node with default parameters.
071:             * The default values are as follows:
072:             * <ul>
073:             * density : 1.0<br>
074:             * </ul>
075:             */
076:            public ExponentialFog() {
077:                // Just use the defaults
078:                // set default read capabilities
079:                setDefaultReadCapabilities(readCapabilities);
080:            }
081:
082:            /**
083:             * Constructs an ExponentialFog node with the specified fog color.
084:             * @param color the fog color
085:             */
086:            public ExponentialFog(Color3f color) {
087:                super (color);
088:
089:                // set default read capabilities
090:                setDefaultReadCapabilities(readCapabilities);
091:            }
092:
093:            /**
094:             * Constructs an ExponentialFog node with the specified fog color
095:             * and density.
096:             * @param color the fog color
097:             * @param density the density of the fog
098:             */
099:            public ExponentialFog(Color3f color, float density) {
100:                super (color);
101:
102:                // set default read capabilities
103:                setDefaultReadCapabilities(readCapabilities);
104:
105:                ((ExponentialFogRetained) this .retained).initDensity(density);
106:            }
107:
108:            /**
109:             * Constructs an ExponentialFog node with the specified fog color.
110:             * @param r the red component of the fog color
111:             * @param g the green component of the fog color
112:             * @param b the blue component of the fog color
113:             */
114:            public ExponentialFog(float r, float g, float b) {
115:                super (r, g, b);
116:
117:                // set default read capabilities
118:                setDefaultReadCapabilities(readCapabilities);
119:            }
120:
121:            /**
122:             * Constructs an ExponentialFog node with the specified fog color
123:             * and density.
124:             * @param r the red component of the fog color
125:             * @param g the green component of the fog color
126:             * @param b the blue component of the fog color
127:             * @param density the density of the fog
128:             */
129:            public ExponentialFog(float r, float g, float b, float density) {
130:                super (r, g, b);
131:
132:                // set default read capabilities
133:                setDefaultReadCapabilities(readCapabilities);
134:
135:                ((ExponentialFogRetained) this .retained).initDensity(density);
136:            }
137:
138:            /**
139:             * Sets fog density.
140:             * @param density the new density of this fog
141:             * @exception CapabilityNotSetException if appropriate capability is
142:             * not set and this object is part of live or compiled scene graph
143:             */
144:            public void setDensity(float density) {
145:                if (isLiveOrCompiled())
146:                    if (!this .getCapability(ALLOW_DENSITY_WRITE))
147:                        throw new CapabilityNotSetException(J3dI18N
148:                                .getString("ExponentialFog0"));
149:
150:                if (isLive())
151:                    ((ExponentialFogRetained) this .retained)
152:                            .setDensity(density);
153:                else
154:                    ((ExponentialFogRetained) this .retained)
155:                            .initDensity(density);
156:            }
157:
158:            /**
159:             * Gets fog density.
160:             * @return the density of this fog
161:             * @exception CapabilityNotSetException if appropriate capability is
162:             * not set and this object is part of live or compiled scene graph
163:             */
164:            public float getDensity() {
165:                if (isLiveOrCompiled())
166:                    if (!this .getCapability(ALLOW_DENSITY_READ))
167:                        throw new CapabilityNotSetException(J3dI18N
168:                                .getString("ExponentialFog1"));
169:
170:                return ((ExponentialFogRetained) this .retained).getDensity();
171:            }
172:
173:            /**
174:             * Creates the retained mode ExponentialFogRetained object that this
175:             * ExponentialFog node will point to.
176:             */
177:            void createRetained() {
178:                this .retained = new ExponentialFogRetained();
179:                this .retained.setSource(this );
180:            }
181:
182:            /**
183:             * Used to create a new instance of the node.  This routine is called
184:             * by <code>cloneTree</code> to duplicate the current node.
185:             * @param forceDuplicate when set to <code>true</code>, causes the
186:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
187:             *  <code>false</code>, the value of each node's
188:             *  <code>duplicateOnCloneTree</code> variable determines whether
189:             *  NodeComponent data is duplicated or copied.
190:             *
191:             * @see Node#cloneTree
192:             * @see Node#cloneNode
193:             * @see Node#duplicateNode
194:             * @see NodeComponent#setDuplicateOnCloneTree
195:             */
196:            public Node cloneNode(boolean forceDuplicate) {
197:                ExponentialFog ef = new ExponentialFog();
198:                ef.duplicateNode(this , forceDuplicate);
199:                return ef;
200:            }
201:
202:            /**
203:             * Copies all ExponentialFog information from
204:             * <code>originalNode</code> into
205:             * the current node.  This method is called from the
206:             * <code>cloneNode</code> method which is, in turn, called by the
207:             * <code>cloneTree</code> method.<P> 
208:             *
209:             * @param originalNode the original node to duplicate.
210:             * @param forceDuplicate when set to <code>true</code>, causes the
211:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
212:             *  <code>false</code>, the value of each node's
213:             *  <code>duplicateOnCloneTree</code> variable determines whether
214:             *  NodeComponent data is duplicated or copied.
215:             *
216:             * @exception RestrictedAccessException if this object is part of a live
217:             *  or compiled scenegraph.
218:             *
219:             * @see Node#duplicateNode
220:             * @see Node#cloneTree
221:             * @see NodeComponent#setDuplicateOnCloneTree
222:             */
223:            void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
224:                super .duplicateAttributes(originalNode, forceDuplicate);
225:
226:                ((ExponentialFogRetained) retained)
227:                        .initDensity(((ExponentialFogRetained) originalNode.retained)
228:                                .getDensity());
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.