Hello,
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,
Pascal
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,
Pascal
Code Select
private Object3D box;
private FrameBuffer buffer = null;
private World world = null;
private boolean alive = true;
private boolean initialized = false;
@Override
// 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];
box.build();
//**************************************************
// 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:
@Override
public void run()
{
while( alive )
{
// Have the box rotate:
box.rotateY( 0.01f );
// Tell the applet to repaint itself:
this.repaint();
// Sleep for a bit:
try
{
Thread.sleep( 10 );
}
catch( Exception e )
{}
}
}
// Draw the scene:
@Override
public void paint( Graphics g )
{
// Make sure jPCT is finished initializing:
if( !initialized )
return;
buffer.clear(); // erase the previous frame
// render the world onto the buffer:
world.renderScene( buffer );
world.draw( buffer );
buffer.update();
buffer.display( g, 0, 0 );
}
// End the main game loop:
@Override
public void destroy()
{
alive = false;
}
}