Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8609409
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类:

2006-11-26 19:44:13

Option Explicit

Private TV3D As TVEngine

Private Teapot As TVMesh

Private Scene As TVScene

Private DoLoop As Boolean

Private sngAngle As Single

Private Sub cmdQuit_Click()

    DoLoop = False

End Sub

Private Sub Form_Load()

    Set TV3D = New TVEngine
    
    TV3D.SetDebugFile "c:\debug8.Txt"
 '设置搜索目录路径
    TV3D.SetSearchDirectory App.Path
 '初始化窗口模式
    TV3D.Init3DWindowedMode Picture1.hWnd

    TV3D.DisplayFPS = True
 '设置坐标系统
    TV3D.SetAngleSystem TV_ANGLE_DEGREE

    Set Scene = New TVScene
 '场景中加载材质
    Scene.LoadTexture "..\..\..\Media\texture.bmp", , , "TeapotTexture"

    Set Teapot = New TVMesh

    Set Teapot = Scene.CreateMeshBuilder

    Teapot.CreateTeapot
 '设置材质
    Teapot.SetTexture GetTex("TeapotTexture")

    Teapot.EnableSphereMapping True

    Teapot.SetPosition 0, 0, 10

    sngAngle = 0
    
    '设置角度
    Teapot.SetRotation 0, sngAngle, sngAngle

    Form1.Show

    DoLoop = True
    Main_Loop

End Sub

Private Sub Form_Unload(Cancel As Integer)

    DoLoop = False

    Main_Quit

End Sub

Private Sub Main_Loop()

    Do

        DoEvents

        
        sngAngle = sngAngle + (TV3D.AccurateTimeElapsed * 0.01)
        Teapot.SetRotation sngAngle, sngAngle, -sngAngle

        TV3D.Clear
 '渲染场景中所有模型
        Scene.RenderAllMeshes

        TV3D.RenderToScreen

    Loop Until DoLoop = False

    Main_Quit

End Sub

Private Sub Main_Quit()
        
    ' We want to quit the project, so we destroy the teapot object.
    Set Teapot = Nothing
    
    ' Then, we destroy the scene object.
    Set Scene = Nothing
    
    ' We finish the frenetic destroy with the TV3D object.
    Set TV3D = Nothing
    
    ' We end the application.
    End

End Sub


阅读(2578) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~