QD3DLight implements IDirect3DRMLight.
QD3DLight Properties
QD3DLight Methods
| Method | Type | Description | Params |
|
|
|
|
| SetLightRGB | SUB (LightType%, R#, G#, B#) | Set lighting type and color | 4 |
| SetPenUmbra | SUB (Angle#) | Set light of outer cone | 1 |
| SetRange | SUB (Range#) | Set range of light | 1 |
| SetUmbra | SUB (Angle#) | Set light of inner cone | 1 |
QD3DLight Events
| Event | Type | Occurs 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
NightLight.SetPenUmbra(0.97)
NightLight.SetRange(Max.Y/10)
NightLightFrame.AddLight(NightLight) 'attach light to frame to move the light!
ViewNightTimeMnu.Checked = True
ViewDayTimeMnu.Checked = False
END SUB
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
END SUB