Guidance
指路人
g.yi.org
software / RapidQ / RQ Doc / html / qd3dface.html

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
Appendix B: QD3DFACE
Rapid-Q Documentation by William Yu (c)1999 Appendix B: QD3DFACE


QD3DFACE Component

QD3DFace implements IDirect3DRMFace.

QD3DFace Properties
FieldTypeR/WDefault




VertexCountINTEGERR

QD3DFace Methods
MethodTypeDescriptionParams




AddVertexSUB (X#, Y#, Z#)Add a vertex3
GetVertexSUB (Index AS LONG, Position AS QD3DVector, Normal AS QD3DVector)Retrieve the position and normal of a vertex3
SetColorRGBSUB (R#, G#, B#)Set face color3

QD3DFace Events
EventTypeOccurs when...Params






QD3DFace Examples
' Direct 3D construction using Faces

$TYPECHECK ON

CONST alClient = 5

'-- Light Types
CONST D3DRMLIGHT_AMBIENT = 0
CONST D3DRMLIGHT_POINT = 1
CONST D3DRMLIGHT_SPOT = 2
CONST D3DRMLIGHT_DIRECTIONAL = 3
CONST D3DRMLIGHT_PARALLELPOINT = 4

'-- Renderer modes
CONST D3DRMRENDERMODE_BLENDEDTRANSPARENCY = 1
CONST D3DRMRENDERMODE_SORTEDTRANSPARENCY = 2
CONST D3DRMRENDERMODE_LIGHTINMODELSPACE = 8
CONST D3DRMRENDERMODE_VIEWDEPENDENTSPECULAR = 16
CONST D3DRMRENDERMODE_DISABLESORTEDALPHAZWRITE = 32


DECLARE SUB DXInitialize(Sender AS QDXScreen)
DECLARE SUB DXInitializeSurface(Sender AS QDXScreen)
DECLARE SUB DXTimerExpired

DIM DXTimer AS QDXTimer
    DXTimer.Enabled = 1
    DXTimer.Interval = 0
    DXTimer.Activeonly = 0
    DXTimer.OnTimer = DXTimerExpired
DIM MeshBuilder AS QD3DMeshBuilder
DIM MeshFrame AS QD3DFrame

CREATE Form AS QForm
    Caption = "Direct 3D Example"
    Width = 640
    Height = 480
    Center
    CREATE DXScreen AS QDXScreen
        Init(640,480)
        Align = alClient
        BitCount = 16
        Use3D = 1
        UseHardware = 0        '' This is for non-3D accelerated video cards.
                               '' 3D will be emulated using software, which
                               '' is much slower.
        OnInitialize = DXInitialize
        OnInitializeSurface = DXInitializeSurface
    END CREATE
    ShowModal
END CREATE


SUB DXInitialize(Sender AS QDXScreen)
   DIM Light AS QD3DLight, Ambient AS QD3DLight
   DIM LightFrame AS QD3DFrame
   DIM Face AS QD3DFace

   DXScreen.CreateFrame(LightFrame)
   DXScreen.CreateFrame(MeshFrame)

   DXScreen.CreateLightRGB(D3DRMLIGHT_DIRECTIONAL, 0.9, 0.9, 0.9, Light)
   LightFrame.AddLight(Light)

   DXScreen.CreateLightRGB(D3DRMLIGHT_AMBIENT, 0.6, 0.6, 0.6, Ambient)
   DXScreen.AddLight(Ambient)

   LightFrame.SetPosition(2, 0, 22)
   DXScreen.SetCameraPosition(-5, 10, 0)

   MeshFrame.AddLight(Ambient)
   MeshFrame.SetPosition(0, 0, 0)
   MeshFrame.SetRotation(0, 0, 0, 0.05)       ' Angle of rotation = 0.05

   DXScreen.CreateMeshBuilder(MeshBuilder)
   DXScreen.CreateFace(Face)


   Face.AddVertex(0.996094,1.000000,-0.995850)
   Face.AddVertex(-0.995850,1.000000,-0.995850)
   Face.AddVertex(-0.995850,1.000000,0.996094)
   Face.AddVertex(0.996094,1.000000,0.996094)
   Face.AddVertex(0.996094,-0.999756,-0.995850)
   Face.AddVertex(-0.995850,-0.999756,-0.995850)
   Face.AddVertex(-0.995850,-0.999756,0.996094)
   Face.AddVertex(0.996094,-0.999756,0.996094)

   MeshBuilder.AddFace(Face)

   MeshBuilder.Scale(2,2,2)
   MeshBuilder.SetRGB(1, 1, .7)
   MeshFrame.AddVisual(MeshBuilder)
   DXScreen.CameraLookAt(MeshFrame, 1)
END SUB

SUB DXInitializeSurface(Sender AS QDXScreen)
   DXScreen.SetRenderMode(D3DRMRENDERMODE_BLENDEDTRANSPARENCY OR D3DRMRENDERMODE_SORTEDTRANSPARENCY)
END SUB

SUB DXTimerExpired
   DXScreen.ForceUpdate(0,0,50,40)     ' Update FPS text only
   DXScreen.Move(1)                    ' This does the rotation by 2 times
   DXScreen.Render
   DXScreen.TextOut(10,10,"FPS: "+STR$(DXTimer.FrameRate), &HFFFFFF, -1)
   DXScreen.Flip
END SUB

Prev Component Contents Next Component
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Mon 2017-11-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2015-12-25 19:42:31