Rapid-Q Documentation by William Yu (c)1999, John Kelly Appendix B: QD3DLIGHT

QD3DLIGHT Component

QD3DLight implements IDirect3DRMLight.

QD3DLight Properties

ParentQFORM/QPANEL  (undocumented) Set parent property
Possible? QD3DLIGHT.PARENT = QD3DFrame

QD3DLight Methods

SetLightRGBSUB (LightType%, R#, G#, B#)Set lighting type and color4
SetPenUmbraSUB (Angle#)Set light of outer cone1
SetRangeSUB (Range#)Set range of light1
SetUmbraSUB (Angle#)Set light of inner cone1

QD3DLight Events
EventTypeOccurs when...Params

QD3DLight Examples

'declare at GLOBAL level
'Master (parent) frame all 3d objects moving together attached to this frame
DIM WorldFrame      AS QD3DFrame 
DIM AmbientLight    AS QD3DLight
DIM DayLight        AS QD3DLight 
DIM DayLightFrame   AS QD3DFrame 'lights on a frame to turn on/off
DIM NightLight      AS QD3DLight 'like a flash light (spot/point light) in the dark
DIM NightLightFrame AS QD3DFrame 'This one for dark

'Then put this sample code in the QDXScreen.OnInit section:
 'ambient is dark for baseline darkness!!
DXScreen.CreateLightRGB(D3DRMLIGHT_AMBIENT, 0.3, 0.3, 0.3, AmbientLight)
DXScreen.AddLight(AmbientLight) 'this light moves with root frame
'true ambient day light
DXScreen.CreateLightRGB(D3DRMLIGHT_AMBIENT, 1.0, 0.91, 0.8, DayLight) DayLightFrame.AddLight(DayLight) 'to a frame so we can remove from scene
DayLightFrame.SetPosition(0, 30, 0) 'x,y,z position, some arbitary value until load a terrain
DayLightFrame.SetOrientation(0, -1, 0, 0, 1, 0) 'points straight down
' Could add on another sun light
' -- D3DRMLIGHT_DIRECTIONAL, or D3DRMLIGHT_POINT 'point is most computational,
' i.e., DXScreen.CreateLightRGB(D3DRMLIGHT_DIRECTIONAL, 0.3, 0.45, 0.5, SunLight)
 'directional is less computational
 'a cone of light works w/ the next commands
DXScreen.CreateLightRGB(D3DRMLIGHT_SPOT, 1.0, 1.0, 0.6, NightLight)
NightLightFrame.AddLight(NightLight) 'to a frame so we can remove from scene
NightLightFrame.SetPosition(0, 2, -20) 'x,y,z position, 
NightLightFrame.SetOrientation(0, 0, 1, 0, 1, 0) 'points forward
View_Day_Time 'turn on day time


SUB View_Night_Time
DayLightFrame.DeleteLight(DayLight) 'attach light to frame to move the light!
'can't do this NightLight.SetLightRGB(D3DRMLIGHT_SPOT,0.505, 0.505, 0.02) 
'simulate tungsten light
NightLight.SetUmbra(0.45) 'inner cone range in angle
NightLightFrame.AddLight(NightLight) 'attach light to frame to move the light!
ViewNightTimeMnu.Checked = True
ViewDayTimeMnu.Checked = False

SUB View_Day_Time
NightLightFrame.DeleteLight(NightLight) 'attach light to frame to move the light!
DayLightFrame.AddLight(DayLight) 'attach light to frame to move the light!
' this code only sets ambient once and only once, can't change
' DXScreen.CreateLightRGB(D3DRMLIGHT_AMBIENT, 1.0, 1.0, 0.1, AmbientLight)
'ambient is dark for baseline darkness!!
' DXScreen.AddLight(AmbientLight) 'this light moves with root frame
ViewNightTimeMnu.Checked = False
ViewDayTimeMnu.Checked = True

Prev Component Contents Next Component