$TYPECHECK ON
$INCLUDE "RapidQ_D3D.INC"
DECLARE SUB DXInitialize(Sender AS QDXSCREEN)
DECLARE SUB DXInitializeSurface(Sender AS QDXSCREEN)
DECLARE SUB DXTimerExpired
DECLARE SUB MakePyramidMesh (TheMeshBuilder AS QD3DMESHBUILDER)
DECLARE SUB ToggleRotation
DIM DXTimer AS QDXTIMER
DXTimer.Enabled = 1
DXTimer.Interval = 0
DXTimer.Activeonly = 0
DXTimer.OnTimer = DXTimerExpired
DIM MeshFrame AS QD3DFRAME
DIM LightFrame AS QD3DFRAME
DIM MeshBuilder AS QD3DMESHBUILDER
DIM i AS SINGLE
DIM RotAngl AS SINGLE : RotAngl = 0.03
DIM RotateIt AS SINGLE: RotateIt = 0
RANDOMIZE
CREATE Form AS QFORM
CAPTION = "Direct 3D Example - click or move mouse"
Width = 640
Height = 480
Center
CREATE DXScreen AS QDXSCREEN
Init(640,480)
Align = 5
BitCount = 16
Use3D = 1
UseHardware = 1
OnInitialize = DXInitialize
OnInitializeSurface = DXInitializeSurface
OnMouseDown = ToggleRotation
END CREATE
SHOWMODAL
END CREATE
SUB DXInitialize(Sender AS QDXSCREEN)
DIM Ambient AS QD3DLIGHT
DIM Light AS QD3DLIGHT
DXScreen.CreateFrame(MeshFrame)
DXScreen.CreateFrame(LightFrame)
DXScreen.CreateMeshBuilder(MeshBuilder)
DXScreen.CreateLightRGB(D3DRMLIGHT_AMBIENT, 0.2, 0.2, 0.3, Ambient)
DXScreen.AddLight(Ambient)
DXScreen.CreateLightRGB(D3DRMLIGHT_POINT, .8, .8, 0.1, Light)
LightFrame.AddLight(Light)
LightFrame.SetPosition(0, 2, -1)
MakePyramidMesh(MeshBuilder)
MeshBuilder.SetRGB(1, 1, 1)
MeshBuilder.SetQuality(D3DRMRENDER_GOURAUD)
MeshFrame.AddVisual(MeshBuilder)
MeshFrame.SetRotation(0, 0, 0,RotAngl)
DXScreen.SetCameraPosition(1.5, 2, 0)
DXScreen.CameraLookAt(MeshFrame, D3DRMCONSTRAIN_Z)
END SUB
SUB DXInitializeSurface(Sender AS QDXSCREEN)
DXScreen.SetRenderMode(D3DRMRENDERMODE_BLENDEDTRANSPARENCY)
END SUB
SUB DXTimerExpired
LightFrame.SetPosition(Screen.MOUSEX/200, Screen.MOUSEY/200, Screen.MOUSEY/200)
DXScreen.ForceUpdate(0,0,50,40)
DXScreen.Move(1)
DXScreen.Render
DXScreen.TextOut(10,10,"FPS: "+STR$(DXTimer.FrameRate), &HFFFFFF, -1)
DXScreen.Flip
END SUB
SUB ToggleRotation
IF RotateIt THEN
MeshFrame.SetRotation(0, 0, 0, 0)
RotateIt= 0
ELSE
MeshFrame.SetRotation(0, 0, 0, RotAngl)
LightFrame.SetPosition(-1, 2, 0)
RotateIt = 1
END IF
END SUB
SUB MakePyramidMesh (TheMeshBuilder AS QD3DMESHBUILDER)
DIM MaxX AS DOUBLE, MaxY AS DOUBLE
DIM Face AS QD3DFACE
MaxX = .5: MaxY = .5
DXScreen.CreateFace(Face)
Face.AddVertex(-MaxX, -MaxY, 0)
Face.AddVertex(MaxX, -MaxY, 0)
Face.AddVertex(0, 0, .5)
TheMeshBuilder.AddFace(Face)
DXScreen.CreateFace(Face)
Face.AddVertex(MaxX, -MaxY, 0)
Face.AddVertex(MaxX, MaxY, 0)
Face.AddVertex(0, 0, .5)
TheMeshBuilder.AddFace(Face)
DXScreen.CreateFace(Face)
Face.AddVertex(MaxX, MaxY, 0)
Face.AddVertex(-MaxX, MaxY, 0)
Face.AddVertex(0, 0, .5)
TheMeshBuilder.AddFace(Face)
DXScreen.CreateFace(Face)
Face.AddVertex(-MaxX, MaxY, 0)
Face.AddVertex(-MaxX, -MaxY, 0)
Face.AddVertex(0, 0, .5)
TheMeshBuilder.AddFace(Face)
END SUB
|
|