Blitz3D+ Command Reference

EntityColor entity,red#,green#,blue#

Parameters

entity - entity handle
red# - red value, 0 to 255
green# - green value, 0 to 255
blue# - blue value, 0 to 255

Description

Sets the colour of an entity.

Values run from 0 (darkest) to 255 (brightest), and the default is 255,255,255 - plain white, which leaves the entity looking exactly as its textures and lighting make it. Anything below 255 tints and darkens.

The colour multiplies with the texture, so it tints rather than repaints: white artwork takes the colour cleanly, which is why team-coloured units and coloured power-ups are usually drawn in greyscale and tinted at runtime. On an untextured primitive from CreateSphere or CreateCube, EntityColor is simply the object colour.

This is the quick entity-wide version of the same setting a brush carries. It replaces the entity colour on every surface at once; for different colours on different surfaces, build brushes with BrushColor and apply them with PaintSurface.

Colour is still lit: a dark room will darken a bright red entity. Add EntityFX entity,1 if you want the colour to show at full strength regardless of lighting.

See also: EntityAlpha, EntityShininess, EntityFX, BrushColor, VertexColor.

Example

; EntityColor Example
; -------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,0

; A power crystal pickup whose colour we will tint
crystal=CreateSphere()
PositionEntity crystal,0,0,5

red=255
green=255
blue=255

While Not KeyDown(1)

    ; Keys 1/2, 3/4 and 5/6 lower/raise the red, green and blue values
    If KeyDown(2) And red>0 Then red=red-5
    If KeyDown(3) And red<255 Then red=red+5
    If KeyDown(4) And green>0 Then green=green-5
    If KeyDown(5) And green<255 Then green=green+5
    If KeyDown(6) And blue>0 Then blue=blue-5
    If KeyDown(7) And blue<255 Then blue=blue+5

    ; Tint the crystal with the current colour
    EntityColor crystal,red,green,blue

    TurnEntity crystal,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"1/2: red   3/4: green   5/6: blue   Arrows: camera   Esc: exit"
    Text 0,20,"EntityColor crystal,"+red+","+green+","+blue

    Flip

Wend

End

Index