Java3d gaming problem *HELP*

Hi all,
I am a student completing my dissertation and need some help urgently.
I have a game that has a main JPanel added to a JFrame and want to add another JPanel to the JFrame which I have done successful.
The problem is the new JPanel, which is to load an object file, displays nothing.
Can anyone give me pointers as what i need to do - do i need to have a canvas3d, or transformgroup or something?
The idea i had in mind was to have this second Jpanel display the life of the user and link to the main JPanel so that if the user got hurt this secondpanel would update to show this.
Thanks in advance,
Catheren

Catheren,
This was taken from one of the Java 3D examples taken from the SDK. It is used to load an *.obj file. It uses the Canvas3D class.
*     @(#)ObjLoad.java 1.22 02/10/21 13:46:12
* Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
*   notice, this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright
*   notice, this list of conditions and the following disclaimer in
*   the documentation and/or other materials provided with the
*   distribution.
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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.
* You acknowledge that Software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of
* any nuclear facility.
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import com.sun.j3d.loaders.Scene;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.io.*;
import com.sun.j3d.utils.behaviors.vp.*;
import java.net.URL;
import java.net.MalformedURLException;
public class ObjLoad extends Applet {
    private boolean spin = false;
    private boolean noTriangulate = false;
    private boolean noStripify = false;
    private double creaseAngle = 60.0;
    private URL filename = null;
    private SimpleUniverse u;
    private BoundingSphere bounds;
    public BranchGroup createSceneGraph() {
     // Create the root of the branch graph
     BranchGroup objRoot = new BranchGroup();
        // Create a Transformgroup to scale all objects so they
        // appear in the scene.
        TransformGroup objScale = new TransformGroup();
        Transform3D t3d = new Transform3D();
        t3d.setScale(0.7);
        objScale.setTransform(t3d);
        objRoot.addChild(objScale);
     // Create the transform group node and initialize it to the
     // identity.  Enable the TRANSFORM_WRITE capability so that
     // our behavior code can modify it at runtime.  Add it to the
     // root of the subgraph.
     TransformGroup objTrans = new TransformGroup();
     objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
     objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
     objScale.addChild(objTrans);
     int flags = ObjectFile.RESIZE;
     if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
     if (!noStripify) flags |= ObjectFile.STRIPIFY;
     ObjectFile f = new ObjectFile(flags,
       (float)(creaseAngle * Math.PI / 180.0));
     Scene s = null;
     try {
       s = f.load(filename);
     catch (FileNotFoundException e) {
       System.err.println(e);
       System.exit(1);
     catch (ParsingErrorException e) {
       System.err.println(e);
       System.exit(1);
     catch (IncorrectFormatException e) {
       System.err.println(e);
       System.exit(1);
     objTrans.addChild(s.getSceneGroup());
     bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        if (spin) {
       Transform3D yAxis = new Transform3D();
       Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                           0, 0,
                           4000, 0, 0,
                           0, 0, 0);
       RotationInterpolator rotator =
           new RotationInterpolator(rotationAlpha, objTrans, yAxis,
                           0.0f, (float) Math.PI*2.0f);
       rotator.setSchedulingBounds(bounds);
       objTrans.addChild(rotator);
        // Set up the background
        Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
        Background bgNode = new Background(bgColor);
        bgNode.setApplicationBounds(bounds);
        objRoot.addChild(bgNode);
     return objRoot;
    private void usage()
      System.out.println(
     "Usage: java ObjLoad [-s] [-n] [-t] [-c degrees] <.obj file>");
      System.out.println("  -s Spin (no user interaction)");
      System.out.println("  -n No triangulation");
      System.out.println("  -t No stripification");
      System.out.println(
     "  -c Set crease angle for normal generation (default is 60 without");
      System.out.println(
     "     smoothing group info, otherwise 180 within smoothing groups)");
      System.exit(0);
    } // End of usage
    public void init() {
     if (filename == null) {
            // Applet
            try {
                URL path = getCodeBase();
                filename = new URL(path.toString() + "./galleon.obj");
            catch (MalformedURLException e) {
           System.err.println(e);
           System.exit(1);
     setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();
        Canvas3D c = new Canvas3D(config);
     add("Center", c);
     // Create a simple scene and attach it to the virtual universe
     BranchGroup scene = createSceneGraph();
     u = new SimpleUniverse(c);
     // add mouse behaviors to the ViewingPlatform
     ViewingPlatform viewingPlatform = u.getViewingPlatform();
     PlatformGeometry pg = new PlatformGeometry();
     // Set up the ambient light
     Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
     AmbientLight ambientLightNode = new AmbientLight(ambientColor);
     ambientLightNode.setInfluencingBounds(bounds);
     pg.addChild(ambientLightNode);
     // Set up the directional lights
     Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
     Vector3f light1Direction  = new Vector3f(1.0f, 1.0f, 1.0f);
     Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
     Vector3f light2Direction  = new Vector3f(-1.0f, -1.0f, -1.0f);
     DirectionalLight light1
         = new DirectionalLight(light1Color, light1Direction);
     light1.setInfluencingBounds(bounds);
     pg.addChild(light1);
     DirectionalLight light2
         = new DirectionalLight(light2Color, light2Direction);
     light2.setInfluencingBounds(bounds);
     pg.addChild(light2);
     viewingPlatform.setPlatformGeometry( pg );
     // This will move the ViewPlatform back a bit so the
     // objects in the scene can be viewed.
     viewingPlatform.setNominalViewingTransform();
     if (!spin) {
            OrbitBehavior orbit = new OrbitBehavior(c,
                                  OrbitBehavior.REVERSE_ALL);
            BoundingSphere bounds =
                new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
            orbit.setSchedulingBounds(bounds);
            viewingPlatform.setViewPlatformBehavior(orbit);        
     u.addBranchGraph(scene);
    // Caled if running as a program
    public ObjLoad(String[] args) {
      if (args.length != 0) {
     for (int i = 0 ; i < args.length ; i++) {
       if (args.startsWith("-")) {
     if (args[i].equals("-s")) {
     spin = true;
     } else if (args[i].equals("-n")) {
     noTriangulate = true;
     } else if (args[i].equals("-t")) {
     noStripify = true;
     } else if (args[i].equals("-c")) {
     if (i < args.length - 1) {
          creaseAngle = (new Double(args[++i])).doubleValue();
     } else usage();
     } else {
     usage();
     } else {
     try {
     if ((args[i].indexOf("file:") == 0) ||
          (args[i].indexOf("http") == 0)) {
          filename = new URL(args[i]);
     else if (args[i].charAt(0) != '/') {
          filename = new URL("file:./" + args[i]);
     else {
          filename = new URL("file:" + args[i]);
     catch (MalformedURLException e) {
     System.err.println(e);
     System.exit(1);
// Running as an applet
public ObjLoad() {
public void destroy() {
     u.cleanup();
// The following allows ObjLoad to be run as an application
// as well as an applet
public static void main(String[] args) {
new MainFrame(new ObjLoad(args), 700, 700);

Similar Messages

  • My daughter has just bought me an iPad 2 from Dubai and set it all up for me but unfortunately the iMessage function doesn't seem to work. We keep getting messages,when trying to activate it, that there is a network connection problem - help!

    My daughter has just bought me an iPad 2 from Dubai and set it all up for me but unfortunately the iMessage function doesn't seem to work. We keep getting messages,when trying to activate it, that there is a network connection problem - help!

    Thank you both for your responses but my daughter was reassured by the salesman in the iStyle store (official Apple store in the UAE) that iMessages would work but conceded that FaceTime wouldn't. My iTunes account is registered in the uk and my daughter's iPhone has iMessages even though she bought it (and uses it) in Dubai. Can anyone else throw any light on this?

  • I couldn't log into my apple account on my iPad, then i couldn't unlock it resulting in it being disabled, however it's the same as my iPhones password, I then called apple, i was hung up on twice and they said it will cost £70 to fix THEIR problem, help?

    I couldn't log into my apple account on my iPad, then i couldn't unlock it resulting in it being disabled, however it's the same as my iPhones password, I then called apple, i was hung up on twice and they said it will cost £70 to fix THEIR problem, help?

    If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup).
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.
    You may have to force iPad/iPod into Recovery Mode
    http://support.apple.com/kb/ht4097

  • IPad syncing problem - HELP!

    iPad sync problem - HELP!  I keep getting this message "...cannot be synced because there is not enough free space to hold all of the items in the iTunes library (additional ...space needed)"  and yet I seem to have plenty of space on the iPad.  This just started today.  I even tried deleting some things to make even more room, but it didn't help.  Any ideas??? 
    I was thinking of restoring, but I've never done it...  should I? 
    thank you!

    Hello florafromnv,
    Welcome to Apple Support Communities.
    The following article addresses how to resolve the issues related to this message:
    iOS: "Not enough free space" alert when trying to sync
    http://support.apple.com/kb/TS1503
    Regards,
    Jeff D.

  • MOVED: KT333 Ultra; fuzzy logic, 1.6xp overclocking problem help !!!!!

    This topic has been moved to Overclockers & Modding Corner.
    KT333 Ultra; fuzzy logic, 1.6xp overclocking problem help !!!!!

    Not that I am an expert o/c but here are some thoughts on the matter.
    My comments are based on my experiences of the KT3 Ultra2 which is basically the same as the Ultra version.
    This mobo does not have the ability to lock the PCI/AGP bus freely from the FSB. However, it does have dividers. At 133 a 1/4 divider kicks in. Above 152FSB the 1/5 divider works, so that at 166 the PCI & AGP buses will be back in sync. If you are o/c your cpu, don't go from 133 to 145, etc since you will be running the PCI/AGP buses further out of whack. Just go to either the mid 150's or to 166 in one jump. The other problem / issue relates to your cpu. From what you say you have one of the old Palominos which are not great o/c's. I would personally o/c your cpu from the BIOS rather than 'Fluffy Logic' which I would tend to stay away from. 
    With a 166FSB cpu a very stable o/c would be 175-177 beyond 180 gets decidedly tricky.
    Hope this helps

  • Itunes keeps closing as soon as i open it and states 'windows has detected a problem' HELP!!!!

    Help!! Itunes keeps closing straight away and message states 'windows has detected a problem' HELP ASAP PLEASE!!!!

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If you've already tried a complete uninstall and reinstall try opening iTunes in safe mode (hold down CTRL+SHIFT as you start iTunes) then going to Edit > Preferences > Store and turning off Show iTunes in the Cloud purchases. You may find iTunes will now start normally.
    tt2

  • I have installed photoshop elements 12. when I try use the editing features it said that i must login to Adobe to register the product. but each time i try to it said there is a problem. help the problem stated that the internet is not connected, but that

    i have installed photoshop elements 12.
    when I try use the editing features it said that i must login to Adobe to register the product.
    but each time i try to it said there is a problem.
    help
    the problem stated that the internet is not connected, but that is not the case.

    I had the same issue and I'm running Windows 7.  Tried working with technical support for several hours but they were no help.  They just had me doing the same things over and over, offering no real answers.  I finally got fed up and have decided to return my product for a full refund.

  • I can't install the itunes to my windows 7 X86 APPCRASH problem, help me guys

    i can't install the itunes to my windows 7 X86 APPCRASH problem, help me guys??  i don't know what to do..

    Why are you unable to install the iPod Updater? Are you getting an error message? Please be specific.
    Cheers!
    -Bryan

  • Camera (focus) problem - help?

    Duplicate post, please see: Camera (focus) problem - help?
    Message was edited by: Admin Moderator

    Warranty is valid only in country of original purchase. You have to return
    the iPhone to the US for evaluation. Either you return it personally or send
    it to a friend/relative/co-worker in the US to take into Apple. Apple will not
    accept international shipments for evaluation nor will Apple ship out of the
    country after repair/replacement.
    Have you tried the standard trouble shooting steps: restart, restore, restore
    as new iPhone?

  • After update iPhone4 to iOS6, its stuck, showing only USB to iTunes on the screen. What to do, how to solve problem, help

    after update iPhone4 to iOS6, its stuck, showing only USB to iTunes on the screen. What to do, how to solve problem, help 

    Connect your phone to iTunes on your computer like the diagram has indicated and restore the phone

  • Help with wireless rounter model: WRT54G gaming problem

    hi guys, i always have problem using this rounter as people can not connect to my games because the rounter is blocking. so, what can i do to stop this problem?
    thanks

    get the port numbers from the game provider and forward the same on the router ..
    if you don't know how to access the router , click here .. on the web ui , click on the "applications and gaming" tab and go to "port trigerring" subtab and enter the port numbers you have ..

  • Please Help with online gaming problem. Please.

    Hi. I am new to this website and I searched in the faqs but did not get much help. How do I play Age of Empires 2: Age of Kings with my cousin through online DirectPlay while the router is connected to my DSL modem? My cousin lives 9 to 10 blocks away from me and we usually use to play the game online through DirectPlay but ever since I got the router, he cannot enter my game any more. We don't play through a website or anything similar.
    Please Can someone help me.
    Info
    Computer: Windows XP Service Pack 2
    Router: WRT54G Version.8
    AT&T Yahoo DSL Modem
    Thank you for your time.

    This type of problem usually happens w/ DSL. On your PC lets try doing these steps. Open up Internet Explorer. On the address bar, just type the numbers 192.168.1.1 (username just leave it blank, password as default is admin). This should lead you to a linksys page. Go to status. On the status page, what is the Internet IP Address as listed there?

  • Need Help(Gaming problem)

    I don't know where else to turn 
    Here is my Specs....
    AMD64 3200(No O/C) 32C Idle 38C(Full Load)
    1GB OCZ Premier ram Dual CHannel Kit
    MSI Neo4-F NForce 4 (Latest Bios)
    7800GT CO(Non OC) Idle Temp 47C, Load 58C (Latest Bios)(Latest drivers)
    OnBoard Sound now
    DVD RW
    CD RW
    Antec 480 Ver 2.0 480 Watt Power Supply
    Harddrive: IDE Maxtor 120GB NForce controlled
    XP Home Eddition SP2 
    VCore: 1.39-1.41
    3.3v: 3.41V
    5V: 5.11
    12V: 12.26
    Situation:
    During Games, Fear, World Of Warcraft, COD II, all 3 will randomly freeze for about 45 seconds, maybe an hour, 30 mins into the game.
    When it freezes, the sound will "loop", then after 45 seconds, it's okay again.
    Switched from Sound Card to Onboard sound, different IRQ, same problem.
    Whats going on?!

    Quote from: blazing storm on 15-January-06, 06:07:30
    Try updating ALL drivers.
    I don't trust Antec, after bad reviews recently.
    Could you try a different PSU of equal or greater power?
    Does it freeze on lower graphics settings?
    Well of all games, FEAR never froze until I O/C the card...
    Don't have another another PSU to try
    Could a Mulitmeter tell me if it's not getting enough power?

  • DIMM 1/2 stopped working on MSI Z97 Gaming 5, help!

    Hello again!
    Today I was trying out a different cooler for my i7 4790K, I mounted it and everything worked fine, but results were bad, so I decided to mount previous cooler again...
    And here were the problem starts. After I mounted everything back (exactly following guide like before, thermal paste etc all done) my PC would not start the system nor BIOS.
    I wondered what could cause it, so just to check a possibility, I unplugged one RAM module from DIMM 2 (they used to work in dual-channel at 2/4 DIMMs) and it suddenly started BIOS and system up normally.
    Following this tip, I unmounted cooler's fan, because it covers DIMM 1 to check if it would work, and doesn't matter what memory I plug in DIMM 1 or 2, it won't work  Doesn't work with any combination, so I can't actually use dual-channel right now, as only DIMM 3 and 4 work at the moment (both or alone). Any module plugged in 1/2 slots doesn't work.
    All I see is that temperature monitor on my MSI Z97 Gaming 5 shows 10-55, 10-55 all the time, jumpy temps, everything works, but nothing loads. Just black screen, nothing. I work with 3/4 slots in single channel right now.
    What the hell could happen? Please help me with this! 
    Edit: Is that possible I could move a CPU from a proper pin so it doesn't connect properly with DIMM 1 and 2? My cooler moved a bit before I mounted it properly. That's only thing that comes to my mind right now.

    Quote
    EXTENT OF LIMITED WARRANTY
    Intel does not warrant that the Product will be free from design defects or errors known as “errata.” Current characterized errata are
    available upon request. Further, this Limited Warranty does NOT cover:
    any costs associated with the repair or replacement of the Product including labor, installation or other costs incurred by you, and in
    particular, any costs relating to the removal or replacement of any Product that is soldered or otherwise permanently affixed to any
    printed circuit board;
    OR
    damage to the Product due to external causes, including accident, problems with electrical power, abnormal electrical, mechanical or
    environmental conditions, usage not in accordance with product instructions, misuse, neglect, alteration, repair, improper installation, or
    improper testing;
    OR
    any Product which has been modified or operated outside of Intel’s publicly available specifications or where the original identification
    markings (trademark or serial number) has been removed, altered or obliterated from the Product.
    http://download.intel.com/support/processors/sb/warranty_procts_english.pdf
    So if you have bent the pins and didn't buy the "care package" or whatever they call for improved warranty, then I believe that it is void. But read whole PDF carefully.
    I might be wrong, I'm just a human. Contact Intel about this:
    http://www.intel.com/p/en_US/support/warranty

Maybe you are looking for