Hi! I'm not sure what I'm doing wrong, I'm beginner & learning, but I tried the normal and working Chapter07a.java with rl.begin(true); and it will ignore all inputs and become Not Responding application under windows 7 and I can choose to have windows Close it. To fix it, I just have to use rl.begin();
But why would this not work?
Here's the code with "true":
package org.xith.tests;
import org.jagatoo.input.*;
import org.jagatoo.input.devices.components.*;
import org.jagatoo.input.events.*;
import org.xith3d.base.*;
import org.xith3d.loop.*;
import org.xith3d.render.*;
import org.xith3d.resources.*;
import org.xith3d.scenegraph.*;
import org.xith3d.scenegraph.primitives.*;
import org.xith3d.utility.interpolate.*;
/**
* XIN - Animation example coding.
*
* @author Marvin Froehlich (aka Qudus)
*/
public class Chapter07a
extends InputAdapterRenderLoop
{
private Transform3D t3d;
private TransformGroup tg;
private AngleInterpolater angleX;
private AngleInterpolater angleY;
@SuppressWarnings( "incomplete-switch" )
@Override
public void onKeyReleased( final KeyReleasedEvent e, final Key key ) {
System.out.println( key.getName() + " " + e.getWhen() );
switch ( key.getKeyID() ) {
case ESCAPE:
end();
break;
}
}
@Override
public void onMouseButtonReleased( final MouseButtonReleasedEvent e, final MouseButton button ) {
System.out.println( "button=" + button + " " + e.getWhen() );
if ( button == MouseButtons.RIGHT_BUTTON ) {
end();
}
}
private BranchGroup createScene() {
final Cube cube = new Cube( 3.0f, "stone.jpg" );
t3d = new Transform3D();
tg = new TransformGroup( t3d );
tg.addChild( cube );
return ( new BranchGroup( tg ) );
}
@Override
protected void onRenderLoopStarted() {
angleX = new AngleInterpolater( 1.0f );
angleY = new AngleInterpolater( 1.0f );
angleX.startIncreasing( getGameMicroTime() );
angleY.startIncreasing( getGameMicroTime() );
}
@Override
protected void prepareNextFrame( final long gameTime, final long frameTime, final TimingMode tm ) {
super.prepareNextFrame( gameTime, frameTime, tm );
final long micros = tm.getMicroSeconds( gameTime );
t3d.rotXYZ( angleX.getValue( micros ), angleY.getValue( micros ), 0.0f );
tg.setTransform( t3d );
// try {
// Thread.sleep( 100 );
// } catch ( final InterruptedException e ) {
// throw Q.rethrow( e );
// }
}
public Chapter07a() throws Exception {
super( 120f );
final Xith3DEnvironment env = new Xith3DEnvironment( this );
final Canvas3D canvas = Canvas3DFactory.createWindowed( 800, 600, "Animation - Rotation" );
env.addCanvas( canvas );
InputSystem.getInstance().registerNewKeyboardAndMouse( canvas.getPeer() );
final ResourceLocator resLoc = ResourceLocator.create( "test-resources/" );
resLoc.createAndAddTSL( "textures" );
env.addPerspectiveBranch( createScene() );
}
public static void main( final String[] args ) throws Exception {
final Chapter07a rl = new Chapter07a();
rl.begin( true );
}
}