Source Code Cross Referenced for PositionInterpolator.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: PositionInterpolator.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.5 $
028:         * $Date: 2008/02/28 20:17:28 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.Vector3d;
035:
036:        /**
037:         * Position interpolator behavior.  This class defines a behavior
038:         * that modifies the translational component of its target 
039:         * TransformGroup by linearly interpolating between a pair of 
040:         * specified positions (using the value generated by the 
041:         * specified Alpha object).  The interpolated position is used
042:         * to generate a translation transform along the local X-axis
043:         * of this interpolator.
044:         */
045:
046:        public class PositionInterpolator extends TransformInterpolator {
047:
048:            private Transform3D translation = new Transform3D();
049:            private Vector3d transv = new Vector3d();
050:
051:            float startPosition;
052:            float endPosition;
053:
054:            // We can't use a boolean flag since it is possible 
055:            // that after alpha change, this procedure only run
056:            // once at alpha.finish(). So the best way is to
057:            // detect alpha value change.
058:            private float prevAlphaValue = Float.NaN;
059:            private WakeupCriterion passiveWakeupCriterion = (WakeupCriterion) new WakeupOnElapsedFrames(
060:                    0, true);
061:
062:            // non-public, default constructor used by cloneNode
063:            PositionInterpolator() {
064:            }
065:
066:            /**
067:             * Constructs a trivial position interpolator with a specified target,
068:             * an axisOfTranslation set to Identity, a startPosition of 0.0f, and
069:             * an endPosition of 1.0f.
070:             * @param alpha The alpha object for this Interpolator
071:             * @param target The target for this position Interpolator 
072:             */
073:            public PositionInterpolator(Alpha alpha, TransformGroup target) {
074:                super (alpha, target);
075:
076:                this .startPosition = 0.0f;
077:                this .endPosition = 1.0f;
078:            }
079:
080:            /**
081:             * Constructs a new position interpolator that varies the target
082:             * TransformGroup's translational component (startPosition and endPosition).
083:             * @param alpha the alpha object for this interpolator
084:             * @param target the transformgroup node effected by this positionInterpolator
085:             * @param axisOfTransform the transform that defines the local coordinate
086:             * system in which this interpolator operates.  The translation is
087:             * done along the X-axis of this local coordinate system.
088:             * @param startPosition the starting position
089:             * @param endPosition the ending position
090:             */
091:            public PositionInterpolator(Alpha alpha, TransformGroup target,
092:                    Transform3D axisOfTransform, float startPosition,
093:                    float endPosition) {
094:
095:                super (alpha, target, axisOfTransform);
096:
097:                this .startPosition = startPosition;
098:                this .endPosition = endPosition;
099:            }
100:
101:            /**
102:             * This method sets the startPosition for this interpolator.
103:             * @param position The new start position
104:             */
105:            public void setStartPosition(float position) {
106:                this .startPosition = position;
107:            }
108:
109:            /**
110:             * This method retrieves this interpolator's startPosition.
111:             * @return the interpolator's start position value
112:             */
113:            public float getStartPosition() {
114:                return this .startPosition;
115:            }
116:
117:            /**
118:             * This method sets the endPosition for this interpolator.
119:             * @param position The new end position
120:             */
121:            public void setEndPosition(float position) {
122:                this .endPosition = position;
123:            }
124:
125:            /**
126:             * This method retrieves this interpolator's endPosition.
127:             * @return the interpolator's end position vslue
128:             */
129:            public float getEndPosition() {
130:                return this .endPosition;
131:            }
132:
133:            /**
134:             * @deprecated As of Java 3D version 1.3, replaced by
135:             * <code>TransformInterpolator.setTransformAxis(Transform3D)</code>
136:             */
137:            public void setAxisOfTranslation(Transform3D axisOfTranslation) {
138:                setTransformAxis(axisOfTranslation);
139:            }
140:
141:            /**
142:             * @deprecated As of Java 3D version 1.3, replaced by
143:             * <code>TransformInterpolator.getTransformAxis()</code>
144:             */
145:            public Transform3D getAxisOfTranslation() {
146:                return getTransformAxis();
147:            }
148:
149:            /**
150:             * Computes the new transform for this interpolator for a given
151:             * alpha value.
152:             *
153:             * @param alphaValue alpha value between 0.0 and 1.0
154:             * @param transform object that receives the computed transform for
155:             * the specified alpha value
156:             *
157:             * @since Java 3D 1.3
158:             */
159:            public void computeTransform(float alphaValue, Transform3D transform) {
160:
161:                double val = (1.0 - alphaValue) * startPosition + alphaValue
162:                        * endPosition;
163:
164:                // construct a Transform3D from:  axis  * translation * axisInverse
165:                transv.set(val, 0.0, 0.0);
166:                translation.setTranslation(transv);
167:
168:                transform.mul(axis, translation);
169:                transform.mul(transform, axisInverse);
170:            }
171:
172:            /**
173:             * Used to create a new instance of the node.  This routine is called
174:             * by <code>cloneTree</code> to duplicate the current node.
175:             * @param forceDuplicate when set to <code>true</code>, causes the
176:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
177:             *  <code>false</code>, the value of each node's
178:             *  <code>duplicateOnCloneTree</code> variable determines whether
179:             *  NodeComponent data is duplicated or copied.
180:             *
181:             * @see Node#cloneTree
182:             * @see Node#cloneNode
183:             * @see Node#duplicateNode
184:             * @see NodeComponent#setDuplicateOnCloneTree
185:             */
186:            public Node cloneNode(boolean forceDuplicate) {
187:                PositionInterpolator pi = new PositionInterpolator();
188:                pi.duplicateNode(this , forceDuplicate);
189:                return pi;
190:            }
191:
192:            /**
193:             * Copies all PositionInterpolator information from
194:             * <code>originalNode</code> into
195:             * the current node.  This method is called from the
196:             * <code>cloneNode</code> method which is, in turn, called by the
197:             * <code>cloneTree</code> method.<P> 
198:             *
199:             * @param originalNode the original node to duplicate.
200:             * @param forceDuplicate when set to <code>true</code>, causes the
201:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
202:             *  <code>false</code>, the value of each node's
203:             *  <code>duplicateOnCloneTree</code> variable determines whether
204:             *  NodeComponent data is duplicated or copied.
205:             *
206:             * @exception RestrictedAccessException if this object is part of a live
207:             *  or compiled scenegraph.
208:             *
209:             * @see Node#duplicateNode
210:             * @see Node#cloneTree
211:             * @see NodeComponent#setDuplicateOnCloneTree
212:             */
213:            void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
214:                super .duplicateAttributes(originalNode, forceDuplicate);
215:
216:                PositionInterpolator pi = (PositionInterpolator) originalNode;
217:
218:                setStartPosition(pi.getStartPosition());
219:                setEndPosition(pi.getEndPosition());
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.