Source Code Cross Referenced for DirectionalLightRetained.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: DirectionalLightRetained.java,v $
003:         *
004:         * Copyright 1996-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.*;
035:
036:        /**
037:         * An infinite directional light source object.
038:         */
039:
040:        class DirectionalLightRetained extends LightRetained {
041:            static final int DIRECTION_CHANGED = LAST_DEFINED_BIT << 1;
042:
043:            // The direction in which this light source is pointing.
044:            Vector3f direction = new Vector3f(0.0f, 0.0f, -1.0f);
045:
046:            // The transformed direction
047:            Vector3f xformDirection = new Vector3f(0.0f, 0.0f, -1.0f);
048:
049:            DirectionalLightRetained() {
050:                this .nodeType = NodeRetained.DIRECTIONALLIGHT;
051:                lightType = 2;
052:                localBounds = new BoundingBox();
053:                ((BoundingBox) localBounds).setLower(1.0, 1.0, 1.0);
054:                ((BoundingBox) localBounds).setUpper(-1.0, -1.0, -1.0);
055:            }
056:
057:            /**
058:             * Initializes this light's direction from the vector provided.
059:             * @param direction the new direction
060:             */
061:            void initDirection(Vector3f direction) {
062:                this .direction.set(direction);
063:                if (staticTransform != null) {
064:                    staticTransform.transform.transform(this .direction,
065:                            this .direction);
066:                }
067:            }
068:
069:            /**
070:             * Sets this light's direction from the vector provided.
071:             * and sends a message
072:             * @param direction the new direction
073:             */
074:            void setDirection(Vector3f direction) {
075:                initDirection(direction);
076:                J3dMessage createMessage = new J3dMessage();
077:                createMessage.threads = targetThreads;
078:                createMessage.type = J3dMessage.LIGHT_CHANGED;
079:                createMessage.universe = universe;
080:                createMessage.args[0] = this ;
081:                createMessage.args[1] = new Integer(DIRECTION_CHANGED);
082:                if (inSharedGroup)
083:                    createMessage.args[2] = new Integer(numMirrorLights);
084:                else
085:                    createMessage.args[2] = new Integer(1);
086:                createMessage.args[3] = mirrorLights.clone();
087:                createMessage.args[4] = new Vector3f(direction);
088:                VirtualUniverse.mc.processMessage(createMessage);
089:
090:            }
091:
092:            /**
093:             * Initializes this light's direction from the three values provided.
094:             * @param x the new x direction
095:             * @param y the new y direction
096:             * @param z the new z direction
097:             */
098:            void initDirection(float x, float y, float z) {
099:                this .direction.x = x;
100:                this .direction.y = y;
101:                this .direction.z = z;
102:
103:                if (staticTransform != null) {
104:                    staticTransform.transform.transform(this .direction,
105:                            this .direction);
106:                }
107:            }
108:
109:            /**
110:             * Sets this light's direction from the three values provided.
111:             * @param x the new x direction
112:             * @param y the new y direction
113:             * @param z the new z direction
114:             */
115:            void setDirection(float x, float y, float z) {
116:                setDirection(new Vector3f(x, y, z));
117:            }
118:
119:            /**
120:             * Retrieves this light's direction and places it in the
121:             * vector provided.
122:             * @param direction the variable to receive the direction vector
123:             */
124:            void getDirection(Vector3f direction) {
125:                direction.set(this .direction);
126:                if (staticTransform != null) {
127:                    Transform3D invTransform = staticTransform
128:                            .getInvTransform();
129:                    invTransform.transform(direction, direction);
130:                }
131:            }
132:
133:            void setLive(SetLiveState s) {
134:                super .setLive(s);
135:                J3dMessage createMessage = super .initMessage(8);
136:                Object[] objs = (Object[]) createMessage.args[4];
137:                objs[7] = new Vector3f(direction);
138:                VirtualUniverse.mc.processMessage(createMessage);
139:
140:            }
141:
142:            /** 
143:             * This update function, and its native counterpart,
144:             * updates a directional light.  This includes its
145:             * color and its transformed direction.
146:             */
147:            // Note : if you add any more fields here , you need to update
148:            // updateLight() in RenderingEnvironmentStructure
149:            void updateMirrorObject(Object[] objs) {
150:                int i;
151:                int component = ((Integer) objs[1]).intValue();
152:                Transform3D trans;
153:                int numLgts = ((Integer) objs[2]).intValue();
154:
155:                LightRetained[] mLgts = (LightRetained[]) objs[3];
156:                DirectionalLightRetained ml;
157:                if ((component & DIRECTION_CHANGED) != 0) {
158:
159:                    for (i = 0; i < numLgts; i++) {
160:                        if (mLgts[i].nodeType == NodeRetained.DIRECTIONALLIGHT) {
161:                            ml = (DirectionalLightRetained) mLgts[i];
162:                            ml.direction = (Vector3f) objs[4];
163:                            ml.getLastLocalToVworld().transform(ml.direction,
164:                                    ml.xformDirection);
165:                            ml.xformDirection.normalize();
166:                        }
167:                    }
168:                }
169:
170:                if ((component & INIT_MIRROR) != 0) {
171:                    for (i = 0; i < numLgts; i++) {
172:                        if (mLgts[i].nodeType == NodeRetained.DIRECTIONALLIGHT) {
173:                            ml = (DirectionalLightRetained) mLgts[i];
174:                            ml.direction = (Vector3f) ((Object[]) objs[4])[7];
175:                            ml.getLastLocalToVworld().transform(ml.direction,
176:                                    ml.xformDirection);
177:                            ml.xformDirection.normalize();
178:                        }
179:                    }
180:                }
181:                // call the parent's mirror object update routine
182:                super .updateMirrorObject(objs);
183:            }
184:
185:            void update(Context ctx, int lightSlot, double scale) {
186:                Pipeline.getPipeline().updateDirectionalLight(ctx, lightSlot,
187:                        color.x, color.y, color.z, xformDirection.x,
188:                        xformDirection.y, xformDirection.z);
189:            }
190:
191:            // Clones only the retained side, internal use only
192:            protected Object clone() {
193:                DirectionalLightRetained dr = (DirectionalLightRetained) super 
194:                        .clone();
195:                dr.direction = new Vector3f(direction);
196:                dr.xformDirection = new Vector3f(0.0f, 0.0f, -1.0f);
197:                return dr;
198:            }
199:
200:            // Called on the mirror object
201:            void updateTransformChange() {
202:                super .updateTransformChange();
203:
204:                getLastLocalToVworld().transform(direction, xformDirection);
205:                xformDirection.normalize();
206:
207:            }
208:
209:            void mergeTransform(TransformGroupRetained xform) {
210:                super.mergeTransform(xform);
211:                xform.transform.transform(direction, direction);
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.