How do you add a ViewingPlatform to a Transform Group, and make it move?

Hello,
I am reasonably new to Java3d and have been looking around the forum about how to add a ViewingPlatform to a transform group. I did find several posts and they did help to get me to put a ViewingPlatform into a transform group, but now I have a problem of not being bale to move it:
The public void actionPerformed(ActionEvent e ) is where the code changes the xloc and zloc variables and make the transform group move. However I get an error when I try to add the Camera to this transform group which is moved.
Thanks in Advance.
Mahen.net

My code is:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.WindowAdapter;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.Sphere;
import javax.swing.Timer;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.loaders.*;
public class BouncingBall extends Applet implements ActionListener, KeyListener {
     private Button go = new Button("Go");
     private TransformGroup objTrans;
     private TransformGroup vpTrans;
     private Transform3D trans = new Transform3D();
     private Transform3D trans2 = new Transform3D();
     private Timer timer;
     private float xloc=0.0f;
     private float zloc=0.0f;
     public BranchGroup createSceneGraph(SimpleUniverse su) {
        BranchGroup objRoot = new BranchGroup();
        // lanscape
        TransformGroup tg = new TransformGroup();
        TransformGroup tg1 = new TransformGroup();
        TransformGroup tg2 = new TransformGroup();
        TransformGroup tg3 = new TransformGroup();
        TransformGroup tg4 = new TransformGroup();
        tg.addChild(tg1);
        tg.addChild(tg2);
        tg.addChild(tg3);
        tg.addChild(tg4);
        Transform3D transform1 = new Transform3D();
        Transform3D transform2 = new Transform3D();
        Transform3D transform3 = new Transform3D();
        Transform3D transform4 = new Transform3D();
        transform1.setTranslation(new Vector3f(2.0f,0.0f,0.0f));
        transform2.setTranslation(new Vector3f(-1.5f,0.0f,0.0f));
        transform3.setTranslation(new Vector3f(1.0f,1.0f,-2.0f));
        transform4.setTranslation(new Vector3f(-2.0f,-1.0f,1.0f));
        tg1.setTransform(transform1);
        tg2.setTransform(transform2);
        tg3.setTransform(transform3);
        tg4.setTransform(transform4);
        tg1.addChild(new ColorCube(0.4));
        tg2.addChild(new ColorCube(0.4));
        tg3.addChild(new ColorCube(0.4));
        tg4.addChild(new ColorCube(0.4));
        objRoot.addChild(tg);
        //character
        objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRoot.addChild(objTrans);
        objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        Transform3D pos1 = new Transform3D();
        pos1.setTranslation(new Vector3f(0.0f,-0.5f,0.0f));
        objTrans.setTransform(pos1);
        // loading object
        try
               Scene s = null;
               ObjectFile f = new ObjectFile ();
                    f.setFlags (ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY);
               String s1 = "gun.obj";
               s = f.load (s1);
               objTrans.addChild (s.getSceneGroup ());
          catch (java.io.FileNotFoundException ex){
        objRoot.addChild(objTrans);
        // lighting
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
        Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
        DirectionalLight light1  = new DirectionalLight(light1Color, light1Direction);
        light1.setInfluencingBounds(bounds);
        objRoot.addChild(light1);
        Color3f ambientColor = new Color3f(1.0f, 1.0f, 1.0f);
        //camera
        Vector3f translate = new Vector3f();
        TransformGroup vpTrans = new TransformGroup();         
        vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        vpTrans = su.getViewingPlatform().getViewPlatformTransform();
        vpTrans = new TransformGroup();
        vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        Transform3D T3D = new Transform3D();     
        T3D.setTranslation(translate);
        translate.set( 0.0f, 0.0f, 3.0f);
        vpTrans.setTransform(T3D);
        return objRoot;
     }

Similar Messages

  • How do you Customize the weather on the home page and make it default to that setting? I have Customize several times and it keeps changing back to McLean, VA in English

    How do you Customize the weather on the home page and make it default to that setting? I have Customize several times and it keeps changing back to McLean, VA in English.
    [email protected]

    '''''What''''' webpage do you have set as your homepage? <br />
    Are you saving cookies for that page?

  • How Do You Add Multiple CSS Rules to Text?

    Hi everyone, I have these css rules in my css styles window they are all assigned to some text in a cell on my page.
    .Def14grey4 <body>
    .def14grey4 a:link <a>
    .def14grey4 a:visited <a>
    .def14grey4 a:hover <a>
    .def14grey4 a:active <a>
    .def14grey4 a:focus <a>
    How do you add (all of) these styles to the text in the first place, I know how to add the first one (.Def14grey4), you select the text in the cell and choose the rule from the drop-down menu in the css panel, but how do you add the other ones to some text as well, so that it can have the same link properties.
    Basically I have some more text elsewhere on the page and want to assign these rules to that as well.
    thanks Gareth

    You would want to change your order as shown here -
    .Def14grey4 <body>
    .def14grey4 a:link <a>
    .def14grey4 a:visited <a>
    .def14grey4 a:hover, .def14grey4 a:focus <a>
    .def14grey4 a:active <a>
    That way, the hover and the focus states are equivalent.
    How do you add (all of) these styles to the text in the first place, I know how to add the first one
    You don't really.  The 4 bottom selectors say -
    "find an element with a class of 'def14grey4', and style any link inside that element this way"
    So, <span class="def14grey4"><a href="whatever.html">Whatever</a></span> would get the pseudo-class styles, as would any of the following -
    <span class="def14grey4"><a href="whatever.html">Whatever</a></span>
    <td class="def14grey4"><a href="whatever.html">Whatever</a></td>
    <p class="def14grey4"><a href="whatever.html">Whatever</a></p>
    <body class="def14grey4"><a href="whatever.html">Whatever</a></body>
    <div class="def14grey4"><a href="whatever.html">Whatever</a></div>
    <strong class="def14grey4"><a href="whatever.html">Whatever</a></strong>
    and so on.  These examples assume that there isn't some other more specific rule that would apply to the same links.  You need to study up on the CSS cascade and specificity....

  • How do you add a google calendar to muse web site, that updates are synced

    how do you add a google calendar to muse web site, that updates are synced?

    You can add Google Calender using iframe which Google provides if you go to calender settings.
    Once you insert this code in Muse page through Object > Insert HTML , the calender will be displayed on page.
    https://support.google.com/calendar/answer/41207?hl=en
    Thanks,
    Sanjit

  • How do you add non-Garage band instruments into a Logic project so that you can hear them on playback?

    How do you add non-Garage band instruments (orchestral instruments) into a Logic Pro (8) project so that you can hear those insrtruments' sounds on playback?  I've tried to understand and follow the Logic Pro 8 User Manual, but the process comes off as so complex and the writing so technical that it does not help but only confuses.
    To be precise - I want to add instruments (orchestral) that are not offered in the current Garage band menu which is offered in the Mixer's channel strip menus for Logic Pro 8.  To be clear, the instruments that are offered are Bass / Drum Kits / Guitars / Mallets / Organs / Pianos and Keyboards / Synth Basics / Synth Leads / Synth Pads.  Most of these that I've tried seem to work and give their characteristic sound when placed in a particular channel and playback is clicked. 
    However - there is one orchestra instrument offered in the standard Logic Pro 8 Mixer channel menu and it's the item labelled "Performance - 000 flute 1 or 001 flute 1."  And it is this instrument that presents a problem. When I click on it and choose it from the menu and enter it as the instrument of choice for a specfic channel / track in my Logic Pro project arrangement, when playing back the music for the overall piece this particular track, the flute, does not playback and produce the notes (Midi events) in the track in the sound of the flute.  Instead, nothing comes out at all.  I can't imagine why this does not work.  Any ideas, anyone? Again, when choosing this instrument for a track and clicking the playback no flute sound is forthcoming.  Why not? I have not tried them all, but when most of the other various types of keyboards, such as an electric piano or an organ, are chosen for a track the playback successfully renders the sound of these instruments.  Why then does playback not produce the sound of the flute when it has clearly been chosen to play and sound the Midi events given it?
    Anyway, the overall, larger issue for me is the inability I have to choose and get non-Garageband instruments (largely orchestral) to play the Midi events given on various tracks. If my guess is correct then technically, orchestral instruments not offered in the standard Logic Pro 8 Garageband Mixer channel menu are referred to as external Midi sampled instruments - still, IMHO the process is not clearly spelled out in the User Manual.  The simple step by step process whereby a non-Garage band instrument, say an orchestral instrument, is placed in a channel replete with Midi event (notes) waiting to be played should be easy, logical and given in a simple to follow format, but is not.
    What with all the talk of routes, busses, auxillary channels, GM devices, GM mixers, audio bins, libraries and audio files this Logic Pro User is confused to the max.  Can someone please help me and, in simple English, describe the step by step process whereby presumably external sampled orchestral instruments can be successfully employed, in any given Logic Pro arrangement project, to render their characteristic sounds upon playback?
    On my two Macs, one a laptop and one a much larger Mac, I have any number of the GSO (Garritan Symphony Orceshtra) and Vienna Symphony Orchestra instrument library samples - and yet - I've yet to figure out how to actually get them INTO a Logic Pro project of any kind!  To put this as a question, even as a humble request, how can I make good use of these orchestral sample libraries in a Logic Pro project?  Can someone steer my to a clear resolution of this issue.  I'd sincerely appreciate it!  Thanks all! 
    DavidBacon

    DavidBacon wrote:
    Anyway, the overall, larger issue for me is the inability I have to choose and get non-Garageband instruments (largely orchestral) to play the Midi events given on various tracks. If my guess is correct then technically, orchestral instruments not offered in the standard Logic Pro 8 Garageband Mixer channel menu are referred to as external Midi sampled instruments - still, IMHO the process is not clearly spelled out in the User Manual.  The simple step by step process whereby a non-Garage band instrument, say an orchestral instrument, is placed in a channel replete with Midi event (notes) waiting to be played should be easy, logical and given in a simple to follow format, but is not.
    What with all the talk of routes, busses, auxillary channels, GM devices, GM mixers, audio bins, libraries and audio files this Logic Pro User is confused to the max.
    David,  you understand that this is professional software and is not necessarily meant to be easy but is in fact designed to give the professional user as many choices as possible, that's why it's in the Pro Apps section. You WILL need to learn about buses, GM Devices, Audio Bins, Libraries...etc..etc if you intend to use Logic.
    That said, you are looking in the wrong place in the channel strip.
      May I offer you advice?
    Go here:
    http://documentation.apple.com/en/logicpro/
    Open "Exploring Logic Pro"  (a short PDF Document). Pay special attention to chapter 3. Also pay special attention to the included graphics of the channel strips.
    I encourage you to read the whole document as it will clear up many things... even though it's a Logic 9 document.
    Post back

  • How do you add an iTunes Gift Card & how is it charged?

    Hey all,
    I currently pay for my iTunes downloads direct from my Debit Card. If I add a gift card to my account will the cost of downloads come from that automatically or do I need to let iTunes know thats what I want?
    Also - how do you add the card? I'm probably being totally stupid but can't seem to find an "add credit here" option.
    Help appreciated

    If you redeem an iTunes gift card, the next purchases you make up to the value of the gift card will be made from it automatically. To add the card, click here; this link will open iTunes.
    (34512)

  • How do you add multiple iTunes to Keynote

    How do you add multiple songs from the iTunes to your Keynote presentation?

    Jer&Renee,
    welcome to Apple Discussions.
    It depends where you want them in your presentation.
    Open the Media inspector and choose a playlist. In the list of entries, mark those you want to add to Keynote (use command-click to mark multiple titles not in one block).
    Then drag the marked titles either on a slide or on the small Audio field (looks like a frame) in Document inspector. When you then hover the cursor at the Audio "frame", you'll see the quick info "Multiple Files". You cannot change the order or remove one of the files, but only all of them.

  • How do you add pictures to your photo book after saving it? Can you re-save it to send to blurb?

    How do you add pictures to your photo book once you have saved it? Moreover, can you save it again and send it to Blurb.

    Go back to Library and drag the extra photos into the book collection.

  • How do you add multiple users to an itunes account

    how do you add multiple users to an itunes account

    First :
    Using an iPhone without a wireless service plan
    Then restore the iPod to factory settings/new iPod on the computer your kids will use:
    iTunes: Restoring iOS software
    If you are using the same computer
    How to use multiple iPods, iPads, or iPhones with one computer

  • How do you add adobe flash player to your mac computer

    How do you add adobe flash player on a mac computer so you can watch youtube and or listen to music?

    Click here and download it.
    (119142)

  • How do you add the ipad device to your itunes account? Please!!

    How do you add the ipad 2 device to your itunes account

    There is no need to add the iPad, just sign into your iTunes account when you need to.

  • How do you add visual video controls to widget video in ibooks author?

    How do you add video controls to video using ibooks author?

    I have the same question as VideoImage. I would like the controls to appear in some of my videos so that the reader can speed them up or slow them down. This would save me having to run them through iMovie at 4X say and saving them that way. As far as I can see, the video fast forward, fast reverse, go to end, go to beginning controls only appear in the Widget inspector. What is their purpose then? 

  • How do you add a video clip to a slide show?

    How do you add a video clip to a slide show using elements 12?

    You can import some very short video clips into Photoshop and make gifs.  I can import short (10 second or so) .mvi video clips I've taken with my point and shoot camera.
    Use File ->Import->Video Frames to Layers
    CS3 doesn't recognize .mvi files until you enter *.* in the box, hit load, then find the file you want.
    After the file has been loaded, go to Windows, and check Animation.
    After the Animation bar loads, go to the right side arrow, check Make Frames from Layers.
    Then Save for Web and Devices, and you've got your gif.
    I find it much easier to use the separate software.

  • How do you add a new thumbnail to a slide show when using in-browser editing?

    how do you add a new thumbnail to a slide show when using in-browser editing?

    At this moment you can’t add pictures to a slideshow. You only can replace them.

  • How do you add a Christmas frame to an image in Elements 10?

    How do you add a Christmas frame to an image in Elements 10?

    In PSE 10, go to Full Edit mode. 
    Open your image.
    Open the Content panel.
    In the first dropdown choose "By Event".
    In the second dropdown choose Christmas.

Maybe you are looking for

  • How to select an item from a dropdown menu using Enter key

    A website I frequently use opens with a dropdown menu. Using my former browser, I was able to select the an item from the dropdown list by hitting the first letter with my keyboard and then hitting Enter. (Think of entering an address and selecting T

  • When importing photos from iphoto to Aperture....

    When importing photos from iphoto to Aperture 3 it shows two versions of each image. One is original and one is iphoto edited.  It shows this for every picture even if it was never edited in iphoto.  Has anyone ever experienced this?  Is so, what ima

  • Socket security layer for 8330 curve

    With no warning my company added socket security layering on our e-mail exchange server.  Now all of us with blackberries cannot receive our mail on our phone.  I have a 8330 curve.  I'm not able to figure out if there is a setting for this.  Please

  • Addition of config keys for transaction CT04

    For transaction code CT04 for a material for which i have output types ZCRE and ZCHG under variant config we have configuration value and configuration description. i would like to add additional config keys like configuration key part3 and configura

  • Connection reset by peer : Socket write

    Hi, everybody I am working with weblogic5.1 with servicepack 8. Our server is running for 24X7X365 but i got some weired error this morning saying that "IO Exception :Connection reset by peer : Socket write error". I believe this has to do with weblo