Exemplo n.º 1
0
void setup()
{
	size(1024, 768);
	background(0);
	setFrameRate(60);

	// Setup lighting
	ambientLight(30);
	light.init(200, 200, 200, 0, 3, 0);

	// Uncomment this line to see the position of the light
	light.drawDebug(true);

	// Init 3d object's properties
	box.init(50, 25, 75);
	box.setPosition(width/2.0f, height/2.0f);

	sphere1.init(30);
	sphere2.init(60);
	sphere3.init(100);

	// Now, we make the spheres children of the box's (scene node)
	box.addChild( sphere1 );
	box.addChild( sphere2 );
	box.addChild( sphere3 );

	// Translate the sphere (relative to its parent, the box)
	// This way, when we rotate the box (parent object), the spheres will orbitate around it
	sphere1.setPosition( 2, 0, 0 );
	sphere2.setPosition( 5, 0, 0 );
	sphere3.setPosition( 7, 0, 0 );

	// Add the second light as child of one of the spheres
	sphere1.addChild( light );
}
Exemplo n.º 2
0
void setup()
{
	size(1024, 768);
	background(0);
	enableShadows( STENCIL_MODULATIVE );
	applyCoordinateSystemTransform(OPENGL3D);

	// Setup lighting
	ambientLight(10);
	light.init(255, 255, 255, width/2 + 100, height/2 + 100, 100);
	
	// Uncomment this line to see the position of the light
	light.drawDebug();

	// Init 3d object's properties
	box.init(10, 4, 14);
	box.setPosition(width/2.0f, 100);
	sphere1.init(6);
	sphere2.init(12);
	sphere3.init(20);

	// Now, we make the spheres children of the box's (scene node)
	box.addChild( sphere1 );
	box.addChild( sphere2 );
	box.addChild( sphere3 );

	// Translate the sphere (relative to its parent, the box)
	// This way, when we rotate the box (parent object), the spheres will orbitate around it
	sphere1.setPosition( 2, -2, 0 );
	sphere2.setPosition( 5, -7, 0 );
	sphere3.setPosition( 7, -12, 0 );
	
	// Ground
	ground.init(5000, 25, 5000 );
	ground.setPosition( width/2, -200 );

	// Camera control
	enableDefault3DCameraControl();
}