JAVA 3D: How to animate "on-the-fly"?

Hy guys,
I'm new to Java 3D and I've read a whole bunch of tutorials as well as Selman's book.
However, as great as Java 3D seems, it seems like I can't get Interpolators to work the way I want them to! Here is my goal:
Create a simulation where the View is FIXED and the main ANIMATED character (comibnation of objects) MOVE AROUND the universe through the user's keyboard commands.
I've managed the above by creating all my objects, adding them to a branchgroup, adding that branchgroup to a transformgroup, adding a few interpolator animations to the transformgroup and finally adding a cutom keyboard navigator behavior to the transformgroup.
The following problem has occurred:
I can't NICELY move the transformgroup around because I use Transform3D objects to calculate the next position of the transformgroup and I then apply it to the transformgroup by calling the "setTransform" method on that group with the Transform3D object. The result is an instantaneous leap x locale units away with no animation in between the original and final position. :o( This is the only way I got this working. The Java runtime keeps yelling at me that I can't add or remove Interpolators or transformgroups from other transformgroups or branchgroups, so I can't change interpolators on-the-fly (say, when the user wants to move in a different direction)... Can it possibly be that we can only declare and use interpolators at prior to executing a universe?!
The IDEAL solution I'm looking for (!INSERT YOUR HELP HERE! ;o) ):
Replace the ugly "setTransform" call by adding a PositionInterpolator or something to the transformgroup object in order to generate a SMOOTH ANIMATION from the original position to the final position. The end result will be must nicer and more professional.

Ok, I've modified the simple behavior class in order to extend the PositionInterpolator class and be able to get a translation that always begins from the last target position. Eventually, I'd also like to be able to modify the AXIS so I can change direction... Anyway, right now I just want what IWON managed to do in one direction.
Here's what I got that DOESN'T WORK, can someone please help me, IWON?:
// Allows an object or group of objects to be moved around SMOOTHLY by the keyboard.
public class KeyboardControlBehavior extends PositionInterpolator {
private TransformGroup source;
public static final float distance = 0.1f;
public static final long time = 200;
// create SimpleBehavior
KeyboardControlBehavior(TransformGroup source, TransformGroup target){
super(new Alpha(1, Alpha.INCREASING_ENABLE, 0000, 0, time, 0, time, 0, 0, 0), target);
// 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){
// Check which direction we're going and adjust the AXIS and endPosition
// in consequence.
KeyEvent event = (KeyEvent) ((WakeupOnAWTEvent) criteria.nextElement()).getAWTEvent()[0];
int c = event.getKeyCode();
System.out.println("KEY PRESSED = "+c);
if ( c != KeyEvent.CHAR_UNDEFINED ) {
if(c == KeyEvent.VK_UP) {
System.out.println("UP");
if(c == KeyEvent.VK_DOWN) {
System.out.println("DOWN");
if(c == KeyEvent.VK_LEFT) {
System.out.println("LEFT");
if(c == KeyEvent.VK_RIGHT) {
System.out.println("RIGHT");
// Let the PositionInterpolator animate the translation.
super.processStimulus(criteria);
// Adjust the source's position to be at the end position of the
// animation (same as target).
Transform3D newPosition = new Transform3D();
Transform3D oldPosition = new Transform3D();
source.getTransform(oldPosition);
target.getTransform(newPosition);
newPosition.mul(oldPosition);
source.setTransform(newPosition);
// Reset the Alpha class since it only executes once.
super.getAlpha().setStartTime(0);
// Consume the event.
event.consume();
// do what is necessary
this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
} // end of class SimpleBehavior

Similar Messages

  • Can't find how to create on-the-fly playlists using search

    I used to make ad-hock playlists on the fly using the quick search in iTunes 10:I would display a list of songs (the full library or from a play list), type somethings in the quicksearch box, and the list would narrow down to the search results, where then I could simply hit "play" and use these results as a temporary ad-hoc playlist.
    That features seems to be gone- even after getting iTunes 11 to LOOK like iTunes 10, typing any search term will show (partial) results in a drop down menu, not narrowing the display, and no option in a single click to simply play the results.
    Am I missing something? Did Apple really remove that functionality?

    Settings>cellular>cellular data

  • Java Comiler - How to find out the Number of lines of Executable code

    Hello,
    Is there any option we have or could have to get the "Number of Lines of Executable Code" while we run the java compiler?
    Technically Java is an interpreter. So in case the term is incorrect, please excuse me.
    Since the compiler anyway traverses through the Java files, it is easy and correct to get the number from the compiler rather than having any external tool calculating the same.
    It should remove the comments, blank lines and take care of java single sentence written in multiple lines.
    Any suggestions or help is highly appreciated.
    regards,
    Sabyasachi

    How many lines of code are there in this program?
    public class sabre20110211 {public static void main(String[] args) {for (int i = 0; i < 10; i++)System.out.println(i);}}And how many in this program?
    public
            class
            sabre20110211
        public
                static
                void
                main(
                String[]
                args
            for
                    (int i = 0;
            i < 10;
            i++
                System.out.println(i);
    }

  • How can I get the events from a java program?

    I want to make a monitor to watch a java program.How can I get the events from the GUI of this program some as mouse cliking, keyinput. So I can watch these in my monitor.
    Thanks

    Hi,
    To put a monitor to the events occuring in the GHUI u need to register required components with the appropriate EventListeners.
    Liek if u want to get notified when a mouse is clicked, then u need to add The MouseListener to the component which u want to be monitored.
    Say
    myFrame which is the JFrame object which shuld be monitored for the events.
    Then in ur program u have to add following code
    myFrame.addMouseListener( someObectReference );
    Here the someObjectReference should be an instance to a concrete class ..i.e. U write a class like the following
    public class MyMouseListener implements MouseListener {
    // override the followig methods
    public void mouseClicked(MouseEvent me){ sop("MOUSE CLICKED ON THE FRAME");}
    public void mousePressed(MouseEvent me){}
    public void mouseReleased(MouseEvent me){}
    If u dont want to use another class for listening to the events. Then u can make teh current class monitor the events. To do so ur class should implement the appropriate listener and should override the required methods.
    and u should say myFrame.addMouseListenet( this );
    thats it

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • After upgrading to mt lion, i lost the option to 'empty cache' on my safari browser. how do i get the option back or how do i empty my cache?

    After upgrading to mt lion, i lost the option to 'empty cache' on my safari browser. This interferes with some playing pogo games and other issues related to Java. How can I get the option back or how do I empty the cache? 

    Go to Safari > Preferences > Advanced and check Show Develop menu in menu bar. Then it's in the Develop menu.

  • How do I test a Java card applet with different AIDs on the fly?

    ... Like sweeping cards from employees in a queue of people lining up in the morning?
    When I created my applet, the aid is a fixed value inside the class.
    Whenever I wanted to test it with another value, I changed that AID and rerun the applet.
    I find it very cumbersome that needs to be rerun and rerun, over and over again.
    How do I test the applet easily with any values of AIDs that I'd like to put in, on the fly.
    I know I can't simulate the sweeps of card in the applet because I can't have a main method with a signature
    of Strings[] args or String[] args. I can only have JUnit to help me out, but still java card doesn't allow either
    main(Strings[] args) or TestCase to inherit from.
    Thanks
    Jack

    your question is hard to understand but:
    an applet always has one definite AID and you cant change it after install as far as i know
    a) you want to test many cards with diffrent AIDs?
    ->send a list of select commands and check the return values
    b)you want one card with the same applet to be available for many AIDs?
    ->install many dummy applets forwarding the commands to one core applet
    c)i think i didnt get your point :/

  • How to clear memory in java on the fly?

    i want to clear memory that use by Jpanel,how do i clear that memory? it's becouse i use that panel for add many images, and i want use the same panel to add others images.
    i has use panel.removeAll(), but it is not remove the memory that use by the panel.
    so how can i remove the memory that use by the panel?

    remove the references to the objects that you removed from the JPannel... when it needs it, then Garbage Collector will allow them to be disposed, but it will dispose of them when it needs to, so you may not see the memory ever returned to your system while your app is running.

  • How to create thumbnail images on the fly from JSP or servlet?

    Hi all,
    Iam new to this forum. I need a solution for the problem iam facing in building my site. Ihave groups and briefcase section in my site. I allow users to upload files and pictures.
    When they upload pictures i need to create thumbnail for them on the fly.
    Is there any taglibs or java source to do this from JSP or servlets.
    It would be very greatful if i can get an early answer.
    Please let me know if there is any other forum where i can get better answer, if not here?
    thnx.

    Here is how you can create dynamic images:
    http://developer.java.sun.com/developer/JDCTechTips/2001/tt0821.html#tip2
    However, if you want to create gifs/jpegs and save them to the disk it depends from where you want to create the images. It is different if you are creating from another image or just drawing one from scratch etc.. But in the end you will probably need to use one of the imageencoder classes and write the result to the disk with the file io classes.

  • How to get system temp dir. path on the fly ,system may be XP or Linux ??

    How to get system temp dir. path on the fly ,system may be XP or Linux ??
    please suggest solution

    The default temporary-file directory can be retrieved
    using:
    System.getProperty("java.io.tmpdir")
    Thanks a lot for u r reply this one works !!!!

  • How can i display the result of java class in InputText ?

    Hi all,
    How can i get the result of java class to InputText Or OutputText ???
    also can every one in the forum give me road map for dealing with java in oracle adf because i'm beginner in oracle adf
    i saw some samples in oracle adf corner but it's difficult for me.

    User,
    Always mention your JDev version, technologies used and clear usecase description (read through this announcement : https://forums.oracle.com/forums/ann.jspa?annID=56)
    How can i get the result of java class to InputText Or OutputText ???Can you elaborate on your requirement? Do you mean the return value of a method in a class as output text? Or an attribute in your class (bean?) as text field?
    -Arun

  • How to Dynamically construct the conditional IF statement in java

    Is there a way to dynamically construct a conditional IF statement in java?
    For example:
    Suppose i have a 2D array like:
    Array[the actual values to search for][the column number in the table to perform the search on].
    e.g.
    Array {
                 {"x"} , {1},  
                 {"y"} , {2},  
                 {"z"} , {3},  
    }How can i construct the if statement like:
    Looping over table rows (tableRow) {
        Looping over array {
            IF ( {"x"}. equals( tableModel.getValueAt( tableRow, {1})   &&
                   {"y"}. equals( tableModel.getValueAt( tableRow, {2})   &&
                   {"z"}. equals( tableModel.getValueAt( tableRow, {3})  )              
            return true;
    }The array can grow or shrink based on the values in it so therefore IF statement will grow or shrink. How can i achieve it?
    If not then how can i achieve this?

    My understanding (feeble at best) is that a sieries of && elements will be evaluated in order until the first false value is encountered. So, in an "if a && b && c" statement where b is false c will never be evaluated and the conditional executable will not run. Is that what you mean?
    Yes, logical expressions will not evaluate unnecessary operands. So you can safely write the following, for instance, without getting an error,
    if ((anArray != null) && (anArray.length > 0)) { ... }because the second operand of the '&&' will never be evaluated if 'anArray' is null.
    Also, is there a difference between & and &&?
    & is a bitwise operator, && is a boolean operator.

  • How do I upload the entire Edge Animate folder to the cloud?

    How do I upload the entire Edge Animate folder to the cloud?

    Hi there,
      Are you talking about the Creative Cloud? If so, you can compress the Edge Animate files into one folder as a .zip file, and then upload the entire .zip file by clicking the Upload button on Creative Cloud:
    I hope this helps! Let me know if you need further clarification! : )

  • I have created a 468x60 animated banner in Edge Animate. How do I save the animated image to my desktop? (not in html code)

    I have created a 468x60 animated banner in Edge Animate. How do I save the animated image to my desktop? (not in html code)

    Hi,
    This feature is not available in Adobe Edge animate. You can not export as image from Edge animate.
    Publish options available in edge describe here
    Edge Animate Help | Publish your content
    Regards,
    Devendra

  • Fedora 13: After upgrading from FF3.6 to FF6.0.2 I no longer have a Java plugin. How do I configure the Java Plugin for FF 6 ? There is no Java Plugin at the site

    I am Fedora 13x64 bit. I just installed FF v6.0.2 from the FF download site. I backed up the existing FF 3.6 as firefox_old
    I need to have a Java plugin to access company site, how do I configure the Java Plugin ?
    At the Plugin area in FF6 there is no Java Plugin available, even after a search.
    I have Java 1.6.0 installed in the OS at:
    /usr/lib/jvm/java-1.6.0/jre/lib/amd64/libnpjp2.so
    I googled how to configure Java Plugin for FF 6 for Fedora 13 and the trick was to create a soft link from /home/<userID>/.mozilla/plugins to the above libnpjp2.so

    AVtech wrote:
    . . . If a person can't get an answer here I don't know where else to turn since Sun certainly wouldn't offer tech support for a free product . . .These forums are user forums, and only occasionally visited by Sun employees. Sun does provide Java technical support options, although (of course) at a charge.
    See:
    http://developers.sun.com/services/
    . . . I guess we'll just use JRE 5 until it's unsupported, whenever that will be. I'm still waiting for an answer on that question, too. See:
    http://java.sun.com/products/archive/eol.policy.html
    http://www.sun.com/service/eosl/
    This document (part IV and Appendix) has some debugging and troubleshooting information that may allow someone involved in the problem to resolve the cause:
    See:
    http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/contents.htm
    Any steps that you can take to isolate the problem to specific Java versions, browsers, applets, web sites, operating systems (and versions), etc, would enhance the possibility of getting help.
    You can try the applets at this Sun location and see if any of them are "slow".
    See:
    http://java.sun.com/javase/6/docs/technotes/samples/demos.html

Maybe you are looking for

  • ITunes keeps removing music from my library! Is there any way to get this to stop?

    For the last three years or so iTunes intermittently removes parts of my library. I'm so sick of dealing with this! I'm beginning to intensely dislike Apple. There doesn't seem to be any pattern to what it's removing and I don't think it's the same s

  • XML photo Layering

    Does anyone know how to layer photos imported via an external source (XML) with other art elements? The imported XML photos always seem to arrive on top of anything else no matter what layer your XML code keyframe is on.

  • I can't make transport controls on Axiom 49 work in LE7

    Newby here . . . I have RTFM and lurked on several boards, but I can't find an answer. I can get the sliders, knobs, buttons, etc. to do the right thing on LE7's mixer with an M-Audio Axiom 49, but I can't figure out what LE7 wants to "hear" to get t

  • Sending Purchase Order by Email

    Hi, I need to send the purchase order by email, I've done that, but the vendor has multiple email address, let's say one for their financial dept, and another for the sales dept, I need to send the PO to the sales dept, but the PO is being sent to th

  • Auto option for BW

    Hi, I created a BlackandWhite adjustment layer in a layerSet. when I clicked the auto option in the property window, the default values has changed accordingly. While reviewing the log file (ScriptingListenerJS.log) i came to know the new values are