Jump to Main Content
Jump to Main Content

BlinkScript Billboard Code Example



Description


This code example shows how to add a billboard to an environment. Billboards are 2D and always face the camera giving the impression of 3D. For the example we have chosen to use what looks like a lens flare. Ideal for adding to lights in a night scene. An Ogre head has been added to give the environment some depth. Note that there is no sky dome as lens flares only occur at nigth. Billboards are most often used for trees, which is very fast and hes minimal impact on the FPS compared to a tree consisting of mesh. All the code and assets are in the projects Scripts directory. You can download the project using the link above.

PostWorld.js


// Turn on debug so that Chat.printDebug() and Chat.dump() work
Chat.debugOutput = true;

// Display the stats panel in the bottom left corner of screen
Application.statsVisible = true;

// Turn on collisions, but allow the user to turn it off
Actor.setCollisionSetting( true, false );

// Turn on gravity, but allow the user to turn it off
Actor.setGravitySetting( true, false );

// Hide the chat panel
Application.chatPaneVisible = false;

// Set ambient light for the scene
Scene.ambientLightColor = Color(0.5, 0.5, 0.5, 0);

// Create a point light
oPointLight = Scene.createPointLight( "SceneLight" );
oPointLight.position = Vector( 20, 300, 50 );

// Create the floor
oGround = Scene.createGround( "MainFloor", "RustySteel", 3000.0, 3000.0, true );

// Add the Ogre head
oHeadEntity = Scene.createEntity( "OgreHead", "ogrehead.mesh" );
oHeadNode = Scene.createSceneNode( "OgreHeadNode" );
oHeadNode.attachObject( oHeadEntity );
oHeadNode.position = Vector( 0, 175, -500 );

// Create the billboard set that will hold 1 or more billboards
oBillboardSet = Scene.createBillboardSet( "FirstBillboardSet" );

// Create a scene node to attach the billboard set to
oBillboardSetNode = Scene.createSceneNode( "BillboardSetNode" );

// Attach the billboard set
oBillboardSetNode.attachObject( oBillboardSet );

// Set the position of the scene node
oBillboardSetNode.position = Vector( 50, 90, -200 );

// Set some properties for the billboard set
oBillboardSet.poolSize = 1;
oBillboardSet.defaultWidth = 100;
oBillboardSet.defaultHeight = 100;
oBillboardSet.billboardType = oBillboardSet.BILLBOARD_TYPE_POINT;

// Set the material that the billboard will use
oBillboardSet.materialName = "ParticleLensFlare";

// Create a billboard of the specifed size in the billboard set
oBillboard = oBillboardSet.createBillboard( Vector( 50, 90, -200 ) );



Related BlinkScript Examples
?????? ?????? ?????? ??????