jPCT - a 3d engine for Java => Support => Topic started by: Pascal on October 17, 2012, 02:44:42 pm

Title: View a simple .3ds model
Post by: Pascal on October 17, 2012, 02:44:42 pm
i just tested the HelloWorld Applet and it works well. But when I want to change the Object3D "box" from the given Primitives.getBox(...) to a 3D-model (commented Line below it), after compiling and opening the .html file, there is still the green Box shown and not my 3D-model. Also when I change the Primitives.getBox() to .getCube(15) there is still the green Box from the beginning and no Cube.

Why does this happen?

Thanks for your help,

Code: [Select]
private Object3D box;

    private FrameBuffer buffer = null;
    private World world = null;

    private boolean alive = true;
    private boolean initialized = false;

    // Initialize all components of the applet
    public void init()

        world = new World();  // create a new world
        World.setDefaultThread( Thread.currentThread() );

        // Add some light to the scene
        world.setAmbientLight(0, 255, 0);

        // create a new buffer to draw on:
        buffer = new FrameBuffer( getWidth(), getHeight(),
                                  FrameBuffer.SAMPLINGMODE_NORMAL );

// the lines iīm talking about
        // Create the box:
        box = Primitives.getBox(13f, 2f);
//      box = Loader.load3DS("D:/Temp/Tele.3ds",1)[0];


        // add the box our world:
        world.addObject( box );

        // set the camera's position:
        world.getCamera().setPosition( 50, -50, -5 );

        // Look at the box:
        world.getCamera().lookAt( box.getTransformedCenter() );

        // Finished initializing.  Now it is safe to paint.
        initialized = true;

        // Start the main "Game Loop":
        new Thread( this ).start();

    // Main Game Loop:
    public void run()
        while( alive )
            // Have the box rotate:
            box.rotateY( 0.01f );

            // Tell the applet to repaint itself:

            // Sleep for a bit:
                Thread.sleep( 10 );
            catch( Exception e )

    // Draw the scene:
    public void paint( Graphics g )
        // Make sure jPCT is finished initializing:
        if( !initialized )

        buffer.clear();   // erase the previous frame

        // render the world onto the buffer:
        world.renderScene( buffer );
        world.draw( buffer );

        buffer.display( g, 0, 0 );

    // End the main game loop:
    public void destroy()
    alive = false;
Title: Re: View a simple .3ds model
Post by: AGP on October 17, 2012, 02:53:11 pm
It's probably a cache issue. Clear your cache. If you're using Firefox, good luck with that (Firefox's cache is a nightmare).
Title: Re: View a simple .3ds model
Post by: Pascal on October 17, 2012, 03:20:16 pm
Thanks, an other browser and the Cube works. But importing my .3ds model still doesnīt work (the Applet loads and then there is only an empty window) and there is no Error-Message...

It is a free .3ds model that I have. Isnīt it so easy to show it in the applet as i thought? Or whatīs going wrong?

The model I used: http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=2719&count=count (http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=2719&count=count)

Iīm new in 3d-programming and experiment a little bit to get to know how it works

Best Regards,
Title: Re: View a simple .3ds model
Post by: EgonOlsen on October 17, 2012, 08:22:09 pm
The problem here is most likely that each model has different properties. Some have a large scale, some are very small. Some are located around the origin, some are way off. Chances are that your model is there, but you are just not looking at it. Try to mode the camera further away (i.e. -50 or -100 instead of -5 for the z value) and see if that helps. If it doesn't, play around with scale factor in the loading method (currently 1 in your code). Increase it to 10 or 100. Also make sure that the first array index that you are using actually contains the whole mesh (i.e. the array returned by the loader has a size of 1). If it isn't, better do something like

Code: [Select]
box = Object3D.mergeAll(Loader.load3DS("D:/Temp/Tele.3ds",1));