This command creates a new light object.
olight= New Light(world,position,color,radius,intensity,flag)
world | The world in which the light is created. |
position | Not the x, y, z coordinates, but another object on which the light will be situated. |
color | The color of the light using the RGB scale. The color can be controlled with the SetColor command ( please see the following code for an example). |
radius | The size of the light. |
intensity | The intensity of the light, from 0 (darkest) to 255 (brightest). This can be controlled with the SetIntensity command (please see the following code for an example). |
flag | Includes these two types: |
dynamic | A moveable light. This is the default setting. |
static | Cannot be moved. These save computation and make your program run faster. |
Lights affect only objects that are rendered with Gouraud or Lambert shading. An object made up of a flat color will not be affected.
oworld = New World(); ocamera = New Camera(oworld); sphere = oworld.CreateSphere(50,50,50,25,25); sphere.SetPosition(0,200,0); // Create a new light at the sphere position. mylight = New Light(oworld,sphere,GetRGB(255,255,0),100,255); mats = New Material(oworld,,RED,"mats"); mats.SetFlat(); sphere.ReplaceMaterial(mats); sphere.SetGouraud; plane = oworld.CreatePlane(600,600); Matplane = New Material(oworld, ,GREEN, "Matplane"); matplane.SetFlat; plane.ReplaceMaterial(matplane); plane.SetAngle(-Pi/2,0,0); plane.SetStatic(); oworld.Optimize(ocamera); ocamera.MoveBack(1200); ocamera.MoveUp(200); sphere.Walk(); // Next line is for true shadow mode. sphere.SetShadowMode(Object.SHADOW_MODE_TRUE); sphere.EnableShadow(); //Loop While(TRUE) { //Change the intensity if arrow pressed. If(IsKeyDown(Keyboard.RIGHT)) { mylight.SetIntensity(2); } //Change the color of the light. If(IsKeyDown(Keyboard.LEFT)) { mylight.SetColor(GetRGB(0,0,255)); } }