This code example shows how to add a spot light. Notice that the spotlight appears to be over illuminating. As the width of the spot light is small, no light should be reaching the ground because it is blocked by the ogre's head. The reason this is happening is because the ground is not highly tesselated which means that the spotlight is only illuminating a single vertex on the plane and the size of the polys is causing the linear interpolation of it to be spread far wider than it should. Doing per pixel lighting in a material/shader can offer better results. All the code and assets are in the projects Scripts directory. You can download the project using the link above.
// 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 avatar Actor.showAvatar = false; // Hide the chat panel Application.chatPaneVisible = false; // Set ambient light for the scene Scene.ambientLightColor = Color(0.25, 0.25, 0.25, 0); // Create the floor var 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 Spot light oSpotLight = Scene.createSpotLight( "FirstLight" ); // Create a scene node and attach the light to it oSpotLightNode = Scene.createSceneNode( "SpotLightNode" ); oSpotLightNode.attachObject( oSpotLight ); // Set the dirstion the light points to being straight down the Y axis oSpotLight.direction = Vector( 0, -1, 0 ); // Set the angle of the inner and outter cones in radians oSpotLight.innerAngle = 0.5; oSpotLight.outerAngle = 0.6; // Position above the Ogre head to light the head only oSpotLightNode.position = Vector( 0, 220, -500 );