home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 7.0 / Dx7.bin / DXF / samples / multimedia / vbsamples / d3drm / src / bot / dxbot.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-03  |  3.3 KB  |  103 lines

  1. VERSION 5.00
  2. Object = "{08216199-47EA-11D3-9479-00AA006C473C}#2.0#0"; "RMCONTROL.OCX"
  3. Begin VB.Form DxBot 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   5055
  6.    ClientLeft      =   1455
  7.    ClientTop       =   1560
  8.    ClientWidth     =   6750
  9.    Icon            =   "DxBot.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   337
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   450
  14.    Begin RMControl7.RMCanvas RMCanvas1 
  15.       Height          =   4770
  16.       Left            =   0
  17.       TabIndex        =   0
  18.       Top             =   0
  19.       Width           =   6330
  20.       _ExtentX        =   11165
  21.       _ExtentY        =   8414
  22.    End
  23. Attribute VB_Name = "DxBot"
  24. Attribute VB_GlobalNameSpace = False
  25. Attribute VB_Creatable = False
  26. Attribute VB_PredeclaredId = True
  27. Attribute VB_Exposed = False
  28. Private m_botAnimation As Direct3DRMAnimationSet2
  29. Private m_botFrame As Direct3DRMFrame3
  30. Private m_time As Single
  31. Private m_running As Boolean
  32. ' DxBot init code loads castle file and displays it
  33. Sub init()
  34.     Dim hr As Long
  35.     '- initialize this form to use 3d
  36.     b = RMCanvas1.StartWindowed
  37.     If (b = False) Then
  38.         MsgBox "Unable to start 3d window"
  39.         Exit Sub
  40.     End If
  41.     ' setting the background color to grey
  42.     RMCanvas1.SceneFrame.SetSceneBackgroundRGB 0.5, 0.5, 0.8
  43.                 
  44.     '- load
  45.     '  have it have it positioned at the root.
  46.     Me.Caption = "Loading ..."
  47.     FindMediaDir "skmech.x"
  48.     '- create a new frame and load the geometry and first animation
  49.     Set m_botFrame = RMCanvas1.D3DRM.CreateFrame(RMCanvas1.SceneFrame)
  50.     Set m_botAnimation = RMCanvas1.D3DRM.CreateAnimationSet()
  51.     m_botAnimation.LoadFromFile "skmech.x", 0, 0, Nothing, Nothing, m_botFrame
  52.                             
  53.     'position things so we can see the bot
  54.     m_botFrame.SetOrientation Nothing, 0, 0, -1, 0, 1, 0
  55.     m_botFrame.AddScale D3DRMCOMBINE_BEFORE, 0.3, 0.3, 0.3
  56.     RMCanvas1.CameraFrame.SetPosition Nothing, 0, 0, -100
  57.     RMCanvas1.Viewport.SetBack 1000
  58.     '- d3d makes lots of computations of first render
  59.     RMCanvas1.Update
  60.     Me.Caption = "DxBot"
  61.     '- start the render loop
  62.     RMCanvas1.SceneSpeed = 30
  63.     m_running = True
  64.     Do While m_running
  65.         RMCanvas1.Update
  66.         DoEvents
  67.     Loop
  68. End Sub
  69. Private Sub Form_Load()
  70.     Static b As Boolean
  71.     If b = True Then End
  72.     b = True
  73.     Me.Show
  74.     init
  75.     End
  76. End Sub
  77. Private Sub Form_Resize()
  78.     On Local Error Resume Next
  79.     RMCanvas1.Width = Me.ScaleWidth
  80.     RMCanvas1.Height = Me.ScaleHeight
  81.     RMCanvas1.Viewport.SetBack 1000
  82. End Sub
  83. Private Sub Form_Unload(Cancel As Integer)
  84.     m_running = False
  85. End Sub
  86. Sub FindMediaDir(sFile As String)
  87.     On Local Error Resume Next
  88.     If Mid$(App.Path, 2, 1) = ":" Then
  89.         ChDrive Mid$(App.Path, 1, 1)
  90.     End If
  91.     ChDir App.Path
  92.     If Dir$(sFile) = "" Then
  93.         ChDir "..\media"
  94.     End If
  95.     If Dir$(sFile) = "" Then
  96.         ChDir "..\..\media"
  97.     End If
  98. End Sub
  99. Private Sub RMCanvas1_SceneMove(delta As Single)
  100.         m_time = m_time + delta
  101.         m_botAnimation.SetTime m_time
  102. End Sub
  103.