< Zurück | Inhalt | Weiter >

From SplineInterpolatorTest.java


//create a Switch group that contains two versions of the world:

//the first is a high resolution version, the second is a lower

//resolution version.

public Group createLodLand( Group g )

{

Switch switchNode = new Switch(); switchNode.setCapability( Switch.ALLOW_SWITCH_WRITE );


Group hiResGroup = createLand( switchNode );

createEnvirons( switchNode );


//create a DistanceLOD that will select the child of the Switch

//node based on distance. Here we are selecting child 0 (high res)if

//we are closer than 180 units to 0,0,0 and child 1 (low res)

//otherwise.

float[] distanceArray = {180};


DistanceLOD distanceLod = new DistanceLOD( distanceArray ); distanceLod.setSchedulingBounds( getApplicationBounds() ); distanceLod.addSwitch( switchNode );


g.addChild( distanceLod ); g.addChild( switchNode );


return hiResGroup;

}


//create a high resolution representation of the world:

//a single texture mapped square and a larger (water colored)

//square to act as a horizon. public Group createLand( Group g )

{

Land land = new Land( this, g, ComplexObject.GEOMETRY | ComplexObject.TEXTURE );

Group hiResGroup = land.createObject( new Appearance(),

new Vector3d(), new Vector3d( LAND_WIDTH,1,LAND_LENGTH ) , "boston.gif", null, null );


Appearance app = new Appearance(); app.setColoringAttributes( new ColoringAttributes(

WATER_COLOR_RED/255f, WATER_COLOR_GREEN/255f,

WATER_COLOR_BLUE/255f, ColoringAttributes.FASTEST ) );


Land base = new Land( this, hiResGroup, ComplexObject.GEOMETRY ); base.createObject( app, new Vector3d(0,−5,0), new Vector3d(

2 * LAND_WIDTH,1,2 * LAND_LENGTH ), null, null, null );


return hiResGroup;

}

//create a low resolution version of the world and

//applies the low resolution satellite image public Group createEnvirons( Group g )

{

Land environs = new Land( this, g, ComplexObject.GEOMETRY | ComplexObject.TEXTURE );

return environs.createObject( new Appearance(), new Vector3d(), new Vector3d( 2 * LAND_WIDTH,1, 2 * LAND_LENGTH) , "environs.gif", null, null );

}


image