Learning 3d programming is easy by combining Java & VRML. VRML describes a 3d scene, Java can render it.
Action Events on VRML scenes anmimated with Java3d ------------- as implemented by the Sun VRML Loaders donated to Web3d.org use the __ WakeupOnAWTEvent __ to have web based applet VRML viewers respond to user events with fluid, multi-jointed animation. Sun Tutorials & Demo codes demostrate this as does do the Sun VRML Loaders ( see below ). Java3d Tutorial ( free ) View Chapters On-line ----------------------------------------------- | | Chapter 0, Preface, Appendices, and Glossary | Chapter 1, Getting Started | Chapter 2, Creating Content | Chapter 3, Easier Content Creation | Chapter 4, Interaction <----- Look here 8^) | Chapter 5, Animation | Chapter 6, Lights | Chapter 7, Textures | Download complete tutorial (3.0MB zip or 4.1MB tar) and examples (325Kb zip or 336Kb tar). | http://java.sun.com/products/java-media/3D/collateral/examples1_6.jar.zip | http://java.sun.com/products/java-media/3D/collateral/ WakeupOnAWTEvent x3d/com/sun/j3d/loaders/vrml97/impl/Evagation.java -------------------------------------------------- ( Sun VRML Loaders ) 1 /* 2 * @(#)Evagation.java 1.31 99/03/01 14:33:18 3 * 4 * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved. ... 234 void resetWakeups() { 235 //if ( !firstTime ) { 236 SceneGraphPath viewPath = 237 new SceneGraphPath(browser.locale,viewTrans); 238 //collisionEnter = new WakeupOnCollisionEntry(viewPath); 239 //collisionExit = new WakeupOnCollisionExit(viewPath); 240 //criterion[0] = collisionEnter; 241 //criterion[1] = collisionExit; 242 criterion = new WakeupCriterion[7]; 243 criterion[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED) ; 244 criterion[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED); 245 criterion[2] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED); 246 criterion[3] = new WakeupOnAWTEvent(MouseEvent.MOUSE_CLICKED); 247 criterion[4] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED); 248 criterion[5] = new WakeupOnAWTEvent(KeyEvent.KEY_RELEASED); 249 criterion[6] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED); 250 251 wakeupOn( new WakeupOr( criterion )); 252 //} else { firstTime = false; } 253 firstTime=false; 254 } 255 http://topaz.kaist.ac.kr/manual/x3d/com/sun/j3d/loaders/vrml97/impl/Evagation.java.html http://216.239.57.100/search?q=cache:RlFJLxlF94IC:topaz.kaist.ac.kr/manual/x3d/com/sun/j3d/loaders/vrml97/impl/Evagation.java.html | F.2.2.2 The Execution Environment | | The developer of a VRML 2.0 runtime environment must | also include code to propagate events along the routes | specified in a VRML file. | | Either user interactions or VRML sensors, | such as timers, can generate events that change | field values. When a field's value changes, | the thin-layer VRML node object that contains | the field first updates its underlying Java 3D | object(s), and then updates the field's associated | output fields with the new value. | | The VRML runtime code then propagates the new | output field values, through routes, to other fields. | The resulting event cascade moves through the VRML | route structure, resulting in an updated Java 3D scene graph. | | The developer must somehow integrate event generation | into the Java 3D execution environment. This can be done | using the Java 3D behavior mechanism to generate events. | | For example, a WakeupOnElapsedTime or WakeupOnElapsedFrames | wakeup criteria can trigger a VRML TimeSensor event, and a | mouse-button WakeupOnAWTEvent wakeup criteria can trigger a | VRML TouchSensor event. Other VRML sensors can be implemented | in a similar manner. | http://www.esc.auckland.ac.nz/Docs/java/j3dguide/AppendixVRML.doc.html tony lincoln wrote:
Dear friends, In j3d scence I want to do a single change per button press, for example, to rotate the cube 10 degree per button press(not animation). I guess that I have to use class WakeupOnAWTEvent. I read something already in http://www.j3d.org/tutorials/raw_j3d/chapter6/mouse.html. But there is no example codes about it. I still do not know how to use it. Do you have any example codes about using WakeupOnAWTEvent? Thanks in advance. regards. Tony lincoln
| http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&group=comp.lang.java.3d&selm=3dc4659.0302161059.6ccee416%40posting.google.com Full Java source code from Sun is below, but please note, you may not even to use that method for events on the GUI external the Canvas3d: Web Demo: Java3d, Human Model with rotating Joints: http://web3dbooks.com/java3d/jumpstart/Human.html http://www.frontiernet.net/~imaging/sourcecode/Human.java The above is a crude Human Model, this is better: Web3d.org's VRML H-Anim Avatars Animated wiht Java3d ---------------------------------------------------- http://www.frontiernet.net/~imaging/vrml_loaders_working.html Norman Badler on 'problems' with Human Animation ------------------------------------------------ | there is a relatively large group of researchers | building rich human-like agents, | but neither a coherent sense of community, | nor an extended venue to help foster discussions | on our research. ... | | Norm Badler ... [ et al. ] have been discussing | some possible first steps toward community building ... | | One of the major impediments to research | on interactive human-like characters is | the paucity of software infrastructure and standards | to support this rapidly developing area of research. | | -- Norman Badler ... [ et al. ] | http://www.ict.usc.edu/~vhumans/overview.html No Norm, Java & Web3d.org's H-Anim Avatars do that. It's been done. No Norman, your Yumetech - U.Penn Flame War ( The "Couch - Bietler Flame War" ) has been a major impediment to progress. Human Animation with Web3d.org's H-Anim Avatars is easy if you ignore the lies from Justin Couch & Norman Badler. -- Paul, Java Developer & Web Animator -------------------------------------- Imaging the Imagined: Modeling with Math & a Keyboard /* * Filename: SimpleBehaviorApp.java * * Implements: rotates cube 0.1 radians every key press * * Date: 1.1 00/09/22 16:24 * * Copyright (c) 1996-2000 Sun Microsystems, Inc. All Rights Reserved. * * from: http://java.sun.com/products/java-media/3D/collateral/examples1_6.jar.zip * example: * Interaction/SimpleBehaviorApp.java */ import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Frame; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; import java.awt.event.*; import java.util.Enumeration; // SimpleBehaviorApp renders a single ColorCube // that rotates when any key is pressed. public class SimpleBehaviorApp extends Applet { public class SimpleBehavior extends Behavior{ private TransformGroup targetTG; private Transform3D rotation = new Transform3D(); private double angle = 0.0; // create SimpleBehavior SimpleBehavior(TransformGroup targetTG){ this.targetTG = targetTG; } // initialize the Behavior // set initial wakeup condition // called when behavior beacomes live public void initialize(){ // set initial wakeup condition this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED)); } // behave // called by Java 3D when appropriate stimulus occures public void processStimulus(Enumeration criteria){ // decode event // do what is necessary angle += 0.1; rotation.rotY(angle); targetTG.setTransform(rotation); this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED)); } } // end of class SimpleBehavior public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); SimpleBehavior myRotationBehavior = new SimpleBehavior(objRotate); myRotationBehavior.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myRotationBehavior); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; } // end of CreateSceneGraph method of SimpleBehaviorApp // Create a simple scene and attach it to the virtual universe public SimpleBehaviorApp() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(config); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } // end of SimpleBehaviorApp (constructor) // The following allows this to be run as an application // as well as an applet public static void main(String[] args) { System.out.print("SimpleBehaviorApp.java \n- a demonstration of creating a simple"); System.out.println("behavior class to provide interaction in a Java 3D scene."); System.out.println("When the app loads, press any key to make the cube rotate."); System.out.println("This is a simple example progam from The Java 3D API Tutorial."); System.out.println("The Java 3D Tutorial is available on the web at:"); System.out.println("http://java.sun.com/products/java-media/3D/collateral"); Frame frame = new MainFrame(new SimpleBehaviorApp(), 256, 256); } // end of main (method of SimpleBehaviorApp) } // end of class SimpleBehaviorApp /* * @(#)SimpleBehaviorApp.java 1.1 00/09/22 16:24 * * Copyright (c) 1996-2000 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */ Sun's VRML Loaders Animate VRML in a browser with Java3d -------------------------------------------------------- > Justin Couch:> Hey, what sort of crack are you on ? > Justin Couch:> > Justin Couch:> That codebase [ the Sun's VRML Loaders ] > Justin Couch:> didn't even support protos let alone H-anim. > Justin Couch:> > Justin Couch:> Scripting support was barely functional and the > Justin Couch:> event model was nowhere near spec compliant. > Justin Couch:> > Justin Couch:> You're bullshitting again. > > Rick Goldberg:> This [ Justin Couch's statement ] is false. Rick Goldberg:> Rick Goldberg:> The code __ did __ support protos Rick Goldberg:> __ before __ you touched it. Rick Goldberg:> Rick Goldberg:> Scripting support was by Rick Goldberg:> the letter of the law, Rick Goldberg:> and highly functional. Rick Goldberg:> Rick Goldberg:> Sounds like you are smoking Rick Goldberg:> some shrubbery of your own. | http://www.web3d.org/TaskGroups/source/hypermail/2001/0591.html http://www.web3d.org/TaskGroups/source/hypermail/2001/0587.html =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
