Source Code Cross Referenced for Gesture.java in  » 6.0-JDK-Modules » java-3d » com » db » hanim » 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 » com.db.hanim 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2000-2001 Silvere Martin-Michiellot All Rights Reserved.
003:         *
004:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005:         * royalty free, license to use, but not to modify or redistribute this
006:         * software in source and binary code form,
007:         * provided that i) this copyright notice and license appear on all copies of
008:         * the software; and ii) Licensee does not utilize the software in a manner
009:         * which is disparaging to Silvere Martin-Michiellot.
010:         *
011:         * This software is provided "AS IS," without a warranty of any kind. ALL
012:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022:         * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024:         *
025:         * This software is not designed or intended for use in on-line control of
026:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027:         * the design, construction, operation or maintenance of any nuclear
028:         * facility. Licensee represents and warrants that it will not use or
029:         * redistribute the Software for such purposes.
030:         *
031:         * @Author: Silvere Martin-Michiellot for Digital Biosphere
032:         * @Version: 1.1 (to stay in touch with h-anim)
033:         *
034:         */
035:
036:        package com.db.hanim;
037:
038:        import java.util.*;
039:        import javax.vecmath.*;
040:        import javax.media.j3d.*;
041:
042:        /**
043:         * This class to implement a H-Anim 1.1 compatible avatar Gesture.
044:         *
045:         * @author Silvere Martin-Michiellot
046:         * @version 1.1
047:         */
048:
049:        public class Gesture extends Object {
050:
051:            protected Humanoid humanoid;
052:            protected TransformGroup humanoidTransformGroup;
053:            protected String name;
054:            protected long duration;
055:            protected int loop;
056:            //One Transform3D could have been used for axisOfTranslation, axisOfRotation, axisOfRotPos
057:            protected Transform3D axisOfTranslation;
058:            protected Transform3D axisOfRotation;
059:            protected Transform3D axisOfRotPos;
060:            protected Alpha alpha;
061:            protected BranchGroup branchGroup;
062:
063:            /**
064:             * Constructs a new Gesture. Each Gesture is a combination of movements. Each movement describes the position and orientation of a Joint using an Interpolator.
065:             * @param humanoid the humanoid to apply the Gesture to
066:             * @param gestureName the human readable name for this gesture
067:             * @param duration the total duration of this gesture
068:             * @param loop the number of loops to apply to this gesture
069:             */
070:            public Gesture(Humanoid humanoid, String gestureName,
071:                    long duration, int loop) {
072:
073:                super ();
074:                this .humanoid = humanoid;
075:                humanoidTransformGroup = (TransformGroup) (humanoid
076:                        .getBranchGroup().getChild(0));
077:                this .name = gestureName;
078:                this .duration = duration;
079:                this .loop = loop;
080:                this .axisOfTranslation = new Transform3D();
081:                this .axisOfRotation = new Transform3D();
082:                this .axisOfRotPos = new Transform3D();
083:                this .alpha = new Alpha(this .loop, Alpha.INCREASING_ENABLE, 0,
084:                        0, this .duration, 0, 0, 0, 0, 0);
085:                this .branchGroup = new BranchGroup();
086:                this .branchGroup.setUserData(gestureName);
087:                this .branchGroup.setCapability(Node.ALLOW_BOUNDS_READ);
088:                this .branchGroup.setCapability(Group.ALLOW_CHILDREN_READ);
089:                this .branchGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
090:                this .branchGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
091:
092:            }
093:
094:            /**
095:             * Gets the Humanoid used with this Gesture
096:             * @return the Humanoid
097:             */
098:            public Humanoid getHumanoid() {
099:
100:                return this .humanoid;
101:
102:            }
103:
104:            /**
105:             * Gets the String name of this Gesture
106:             * @return the name of this Gesture
107:             */
108:            public String getName() {
109:
110:                return this .name;
111:
112:            }
113:
114:            /**
115:             * Gets the total duration of this Gesture
116:             * @return the duration of the gesture. An Alpha component is used is the underlying implementation. See Java3D documentation.
117:             */
118:            public long getDuration() {
119:
120:                return this .duration;
121:
122:            }
123:
124:            /**
125:             * Gets the number of loops for this Gesture
126:             * @return the number of loops of the gesture. An Alpha component is used is the underlying implementation. See Java3D documentation.
127:             */
128:            public int getLoop() {
129:
130:                return this .loop;
131:
132:            }
133:
134:            /**
135:             * Adds a movement for a Joint as a position component
136:             * @param Joint the Joint to which these time sliced translations are applied
137:             * @param knots the float array that defines the time slices.
138:             * @param positions the Point3f array that describes the successive positions of the Joint
139:             * @exception java.lang.IllegalArgumentException if the Joint doesn't exist in the Humanoid used for this gesture.
140:             */
141:            //User should check that the Joint exist otherwise an error will be thrown
142:            public void addGesturePositionComponent(Joint joint, float[] knots,
143:                    Point3f[] positions) {
144:
145:                TransformGroup target;
146:                PositionPathInterpolator positionPathInterpolator;
147:
148:                target = findJoint(humanoidTransformGroup, joint.getName());
149:                if (target != null) {
150:                    positionPathInterpolator = new PositionPathInterpolator(
151:                            this .alpha,
152:                            ((TransformGroup) ((TransformGroup) target
153:                                    .getChild(0)).getChild(0)),
154:                            this .axisOfTranslation, knots, positions);
155:                    positionPathInterpolator.setUserData(joint.getName());
156:                    branchGroup.addChild(positionPathInterpolator);
157:                } else {
158:                    throw new java.lang.IllegalArgumentException(
159:                            "Joint could not be found in the considered humanoid.");
160:                }
161:
162:            }
163:
164:            /**
165:             * Adds a movement for a Joint as a rotation component
166:             * @param Joint the Joint to which these time sliced rotations are applied
167:             * @param knots the float array that defines the time slices.
168:             * @param quats the Quat4f array that describes the successive rotations of the Joint
169:             * @exception java.lang.IllegalArgumentException if the Joint doesn't exist in the Humanoid used for this gesture.
170:             */
171:            //User should check that the Joint exist otherwise an error will be thrown
172:            public void addGestureRotationComponent(Joint joint, float[] knots,
173:                    Quat4f[] quats) {
174:
175:                TransformGroup target;
176:                RotationPathInterpolator rotationPathInterpolator;
177:
178:                target = findJoint(humanoidTransformGroup, joint.getName());
179:                if (target != null) {
180:                    rotationPathInterpolator = new RotationPathInterpolator(
181:                            this .alpha,
182:                            ((TransformGroup) ((TransformGroup) target
183:                                    .getChild(0)).getChild(0)),
184:                            this .axisOfRotation, knots, quats);
185:                    rotationPathInterpolator.setUserData(joint.getName());
186:                    branchGroup.addChild(rotationPathInterpolator);
187:                } else {
188:                    throw new java.lang.IllegalArgumentException(
189:                            "Joint could not be found in the considered humanoid.");
190:                }
191:
192:            }
193:
194:            /**
195:             * Adds a movement for a Joint as a position and rotation component
196:             * @param Joint the Joint to which these time sliced translations and roations are applied
197:             * @param knots the float array that defines the time slices.
198:             * @param positions the Point3f array that describes the successive positions of the Joint
199:             * @param positions the Point3f array that describes the successive rotations of the Joint
200:             * @exception java.lang.IllegalArgumentException if the Joint doesn't exist in the Humanoid used for this gesture.
201:             */
202:            //User should check that the Joint exist otherwise an error will be thrown
203:            public void addGestureRotPosComponent(Joint joint, float[] knots,
204:                    Quat4f[] quats, Point3f[] positions) {
205:
206:                TransformGroup target;
207:                RotPosPathInterpolator rotPosPathInterpolator;
208:
209:                target = findJoint(humanoidTransformGroup, joint.getName());
210:                if (target != null) {
211:                    rotPosPathInterpolator = new RotPosPathInterpolator(
212:                            this .alpha,
213:                            ((TransformGroup) ((TransformGroup) target
214:                                    .getChild(0)).getChild(0)),
215:                            this .axisOfRotPos, knots, quats, positions);
216:                    rotPosPathInterpolator.setUserData(joint.getName());
217:                    branchGroup.addChild(rotPosPathInterpolator);
218:                } else {
219:                    throw new java.lang.IllegalArgumentException(
220:                            "Joint could not be found in the considered humanoid.");
221:                }
222:
223:            }
224:
225:            /**
226:             * Gets the BranchGroup that can be used by Java3D to animate the Humanoid. Every element in the resulting BranchGroup has its userData set to the Name of the corresponding Joint.
227:             * @return the BranchGroup that contains all the interpolators to be added to the Java3D graph
228:             */
229:            public BranchGroup getBranchGroup() {
230:                //retrieves the interpolators to be added to the Java3D graph
231:                //Every element in the resulting BranchGroup has its userData set to the Name of the corresponding Joint.
232:
233:                return this .branchGroup;
234:
235:            }
236:
237:            private TransformGroup findJoint(TransformGroup transformGroup,
238:                    String jointName) {
239:
240:                TransformGroup resultTransformGroup;
241:                Hashtable hashtable;
242:                Enumeration enumeration;
243:                Object object;
244:                boolean found;
245:
246:                System.out.println((String) transformGroup.getUserData());
247:                if (((String) transformGroup.getUserData()).equals(jointName)) {
248:                    return transformGroup;
249:                } else {
250:                    enumeration = transformGroup.getAllChildren();
251:                    found = false;
252:                    resultTransformGroup = null;
253:                    while ((enumeration.hasMoreElements()) && (!found)) {
254:                        object = enumeration.nextElement();
255:                        if (object instanceof  TransformGroup) {
256:                            resultTransformGroup = findJoint(
257:                                    (TransformGroup) object, jointName);
258:                            found = (resultTransformGroup != null);
259:                        }
260:                    }
261:                    return resultTransformGroup;
262:
263:                }
264:
265:            }
266:
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.