home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / Direct3D / AutoParts / auto.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-08  |  23.6 KB  |  719 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Auto Collision Parts Database"
  6.    ClientHeight    =   8520
  7.    ClientLeft      =   480
  8.    ClientTop       =   615
  9.    ClientWidth     =   10875
  10.    Icon            =   "auto.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   568
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   725
  17.    Begin MSComctlLib.TreeView TreeView1 
  18.       Height          =   3495
  19.       Left            =   120
  20.       TabIndex        =   27
  21.       Top             =   480
  22.       Width           =   3975
  23.       _ExtentX        =   7011
  24.       _ExtentY        =   6165
  25.       _Version        =   393217
  26.       HideSelection   =   0   'False
  27.       Style           =   7
  28.       Appearance      =   1
  29.    End
  30.    Begin VB.TextBox Text8 
  31.       Enabled         =   0   'False
  32.       Height          =   375
  33.       Left            =   9000
  34.       TabIndex        =   25
  35.       Top             =   7380
  36.       Width           =   1695
  37.    End
  38.    Begin VB.PictureBox Picture2 
  39.       Height          =   735
  40.       Left            =   120
  41.       ScaleHeight     =   675
  42.       ScaleWidth      =   10515
  43.       TabIndex        =   19
  44.       Top             =   4080
  45.       Width           =   10575
  46.       Begin VB.Label Label9 
  47.          Caption         =   $"auto.frx":0442
  48.          Height          =   495
  49.          Left            =   120
  50.          TabIndex        =   20
  51.          Top             =   120
  52.          Width           =   9495
  53.       End
  54.    End
  55.    Begin VB.CommandButton Command1 
  56.       Caption         =   "Add To Invoice"
  57.       Height          =   495
  58.       Left            =   120
  59.       TabIndex        =   16
  60.       Top             =   7920
  61.       Width           =   3975
  62.    End
  63.    Begin MSComctlLib.ListView ListView1 
  64.       Height          =   2355
  65.       Left            =   4320
  66.       TabIndex        =   15
  67.       Top             =   4920
  68.       Width           =   6375
  69.       _ExtentX        =   11245
  70.       _ExtentY        =   4154
  71.       View            =   3
  72.       LabelWrap       =   -1  'True
  73.       HideSelection   =   0   'False
  74.       _Version        =   393217
  75.       ForeColor       =   -2147483640
  76.       BackColor       =   -2147483643
  77.       BorderStyle     =   1
  78.       Appearance      =   1
  79.       NumItems        =   5
  80.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  81.          Key             =   "price"
  82.          Text            =   "DESCRIPTION"
  83.          Object.Width           =   5821
  84.       EndProperty
  85.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  86.          SubItemIndex    =   1
  87.          Key             =   "part"
  88.          Text            =   "PRICE"
  89.          Object.Width           =   2117
  90.       EndProperty
  91.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  92.          SubItemIndex    =   2
  93.          Key             =   "id"
  94.          Text            =   "ID"
  95.          Object.Width           =   2117
  96.       EndProperty
  97.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  98.          SubItemIndex    =   3
  99.          Key             =   "modid"
  100.          Text            =   "MODID"
  101.          Object.Width           =   0
  102.       EndProperty
  103.       BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  104.          SubItemIndex    =   4
  105.          Object.Width           =   38100
  106.       EndProperty
  107.    End
  108.    Begin VB.CommandButton Command3 
  109.       Caption         =   "Process Order"
  110.       Height          =   495
  111.       Left            =   7680
  112.       TabIndex        =   3
  113.       Top             =   7920
  114.       Width           =   3015
  115.    End
  116.    Begin VB.CommandButton Command2 
  117.       Caption         =   "Remove From Invoice"
  118.       Height          =   495
  119.       Left            =   4320
  120.       TabIndex        =   2
  121.       Top             =   7920
  122.       Width           =   3135
  123.    End
  124.    Begin VB.PictureBox largepict 
  125.       Height          =   3495
  126.       Left            =   4320
  127.       ScaleHeight     =   229
  128.       ScaleMode       =   3  'Pixel
  129.       ScaleWidth      =   421
  130.       TabIndex        =   1
  131.       Top             =   480
  132.       Width           =   6375
  133.    End
  134.    Begin VB.PictureBox Picture1 
  135.       Height          =   2835
  136.       Left            =   120
  137.       ScaleHeight     =   2775
  138.       ScaleWidth      =   3915
  139.       TabIndex        =   0
  140.       Top             =   4920
  141.       Width           =   3975
  142.       Begin VB.TextBox Text7 
  143.          Enabled         =   0   'False
  144.          Height          =   285
  145.          Left            =   1440
  146.          TabIndex        =   26
  147.          Top             =   2400
  148.          Width           =   1695
  149.       End
  150.       Begin VB.TextBox Text6 
  151.          Enabled         =   0   'False
  152.          Height          =   285
  153.          Left            =   1440
  154.          TabIndex        =   24
  155.          Top             =   2040
  156.          Width           =   1695
  157.       End
  158.       Begin VB.TextBox Text5 
  159.          Enabled         =   0   'False
  160.          Height          =   285
  161.          Left            =   1440
  162.          TabIndex        =   13
  163.          Top             =   1680
  164.          Width           =   1695
  165.       End
  166.       Begin VB.TextBox Text4 
  167.          Enabled         =   0   'False
  168.          Height          =   285
  169.          Left            =   1440
  170.          TabIndex        =   11
  171.          Top             =   1320
  172.          Width           =   1695
  173.       End
  174.       Begin VB.TextBox Text3 
  175.          Enabled         =   0   'False
  176.          Height          =   285
  177.          Left            =   1440
  178.          TabIndex        =   9
  179.          Top             =   960
  180.          Width           =   1695
  181.       End
  182.       Begin VB.TextBox Text2 
  183.          Enabled         =   0   'False
  184.          Height          =   285
  185.          Left            =   1440
  186.          TabIndex        =   7
  187.          Top             =   600
  188.          Width           =   1695
  189.       End
  190.       Begin VB.TextBox Text1 
  191.          Enabled         =   0   'False
  192.          Height          =   285
  193.          Left            =   1440
  194.          TabIndex        =   4
  195.          Top             =   240
  196.          Width           =   1695
  197.       End
  198.       Begin VB.Label Label12 
  199.          Caption         =   "MAKE"
  200.          Height          =   255
  201.          Left            =   120
  202.          TabIndex        =   23
  203.          Top             =   2400
  204.          Width           =   735
  205.       End
  206.       Begin VB.Label Label11 
  207.          Caption         =   "Label11"
  208.          Height          =   15
  209.          Left            =   240
  210.          TabIndex        =   22
  211.          Top             =   2640
  212.          Width           =   735
  213.       End
  214.       Begin VB.Label Label10 
  215.          Caption         =   "STOCK"
  216.          Height          =   255
  217.          Left            =   120
  218.          TabIndex        =   21
  219.          Top             =   2040
  220.          Width           =   1095
  221.       End
  222.       Begin VB.Label Label5 
  223.          Caption         =   "ASSEMBLY"
  224.          Height          =   375
  225.          Left            =   120
  226.          TabIndex        =   12
  227.          Top             =   1680
  228.          Width           =   1335
  229.       End
  230.       Begin VB.Label Label4 
  231.          Caption         =   "COMPAT PARTS"
  232.          Height          =   255
  233.          Left            =   120
  234.          TabIndex        =   10
  235.          Top             =   1320
  236.          Width           =   1335
  237.       End
  238.       Begin VB.Label Label3 
  239.          Caption         =   "PRICE"
  240.          Height          =   255
  241.          Left            =   120
  242.          TabIndex        =   8
  243.          Top             =   960
  244.          Width           =   1095
  245.       End
  246.       Begin VB.Label Label2 
  247.          Caption         =   "DESCRIPTION"
  248.          Height          =   375
  249.          Left            =   120
  250.          TabIndex        =   6
  251.          Top             =   600
  252.          Width           =   1215
  253.       End
  254.       Begin VB.Label Label1 
  255.          Caption         =   "PARTID"
  256.          Height          =   255
  257.          Left            =   120
  258.          TabIndex        =   5
  259.          Top             =   240
  260.          Width           =   735
  261.       End
  262.    End
  263.    Begin VB.Label Label8 
  264.       Caption         =   "Select Assembly"
  265.       Height          =   255
  266.       Left            =   120
  267.       TabIndex        =   18
  268.       Top             =   120
  269.       Width           =   2895
  270.    End
  271.    Begin VB.Label Label7 
  272.       Caption         =   "Click On a Part From Assembly - Use the mouse to Rotate the Assembly"
  273.       Height          =   255
  274.       Left            =   4320
  275.       TabIndex        =   17
  276.       Top             =   120
  277.       Width           =   5895
  278.    End
  279.    Begin VB.Label Label6 
  280.       Caption         =   "TOTAL"
  281.       Height          =   255
  282.       Left            =   4440
  283.       TabIndex        =   14
  284.       Top             =   7380
  285.       Width           =   1455
  286.    End
  287.    Begin VB.Menu MENU_FILE 
  288.       Caption         =   "&File"
  289.       Begin VB.Menu MENU_EXIT 
  290.          Caption         =   "E&xit"
  291.       End
  292.    End
  293.    Begin VB.Menu MENU_HELP 
  294.       Caption         =   "&Help"
  295.       Begin VB.Menu MENU_ABOUT 
  296.          Caption         =   "&About..."
  297.       End
  298.    End
  299. Attribute VB_Name = "Form1"
  300. Attribute VB_GlobalNameSpace = False
  301. Attribute VB_Creatable = False
  302. Attribute VB_PredeclaredId = True
  303. Attribute VB_Exposed = False
  304. Option Explicit
  305. 'The model used by this sample, engine1.x, is provided courtesy of Viewpoint
  306. 'Digital, Inc. (www.viewpoint.com).  It is provided for use with this sample
  307. 'only and cannot be distributed with any application without prior written
  308. 'consent.  V6 Engine Model copyright 1999 Viewpoint Digital, Inc..
  309. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  310. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  311. '  File:       auto.frm
  312. '  Content:    Example of display and picking geometry
  313. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  314. Dim m_assemblies(100) As CD3DFrame
  315. Dim m_assemblyName(100) As String
  316. Dim m_nAssembly As Long
  317. Dim m_scene As CD3DFrame
  318. Dim m_root As CD3DFrame
  319. Dim m_bMouseDown As Boolean
  320. Dim m_lastX As Integer
  321. Dim m_lastY As Integer
  322. Dim m_current As CD3DFrame
  323. Dim m_bInLoad As Boolean
  324. Dim m_binit As Boolean
  325. Dim m_data As New Data
  326. Dim fLoading As Boolean
  327. Dim m_backcolor As Long
  328. Dim m_mediadir As String
  329. Implements DirectXEvent8
  330. Private Sub DirectXEvent8_DXCallback(ByVal eventid As Long)
  331.     Dim b As Boolean
  332. End Sub
  333. '- Form_Load
  334. '  Initialize the D3DUtil Framework
  335. '  Initialize the parts info text database
  336. '  Initialize the treeview control
  337. Private Sub Form_Load()
  338.     Dim b As Boolean
  339.     Me.Show
  340.     DoEvents
  341.     ' Initialize D3D Window
  342.     b = D3DUtil_DefaultInitWindowed(0, largepict.hwnd)
  343.     If b = False Then
  344.         MsgBox "Exiting, Unable to initialize 3D device"
  345.         End
  346.     End If
  347.     'Add some default light and turn on lighting
  348.     g_lWindowWidth = largepict.ScaleWidth
  349.     g_lWindowHeight = largepict.ScaleHeight
  350.     D3DUtil.D3DUtil_SetupDefaultScene
  351.     'Find Media Directory
  352.     m_mediadir = FindMediaDir("partstable.txt", False)
  353.     'Open Text Database
  354.     m_data.InitData m_mediadir + "partstable.txt"
  355.                
  356.     'Save our initial background color
  357.     m_backcolor = &HFF90D090
  358.     'Fill the Tree view with its root node
  359.     FillTreeViewControl
  360.         
  361. End Sub
  362.      
  363. '- SelectPart
  364. '  fill in the text boxes given a certain identifier
  365. '  from a model. We query the database for the identifier
  366. '  and from there we get the rest of the info
  367. Sub SelectPart(strName As String, strObject As String)
  368.    If m_data.MoveToModelPartRecord(strName) = False Then Exit Sub
  369.    Text1.Text = m_data.PartID
  370.    Text2.Text = m_data.Description
  371.    Text3.Text = format$(m_data.Price, "#0.00")
  372.    Text4.Text = m_data.CompatibleParts
  373.    Text5.Text = "Engine"
  374.    Text6.Text = m_data.Stock
  375.    Text7.Text = m_data.PartMake
  376.    If Not m_root Is Nothing Then
  377.         
  378.         'Turn the selected object red
  379.         If Not m_current Is Nothing Then
  380.             With m_current.GetChildMesh(0)
  381.                 .bUseMaterials = True
  382.                 .bUseMaterialOverride = False
  383.             End With
  384.         End If
  385.         
  386.         Set m_current = m_scene.FindChildObject(strObject, 0)
  387.         
  388.         If Not (m_current Is Nothing) Then
  389.             Dim mat As D3DMATERIAL8
  390.             With m_current.GetChildMesh(0)
  391.                 .bUseMaterials = False
  392.                 .bUseMaterialOverride = True
  393.                 mat.emissive.r = 0.5
  394.                 mat.emissive.a = 1
  395.                 mat.diffuse.r = 0.3
  396.                 mat.diffuse.a = 1
  397.                 .SetMaterialOverride mat
  398.             End With
  399.         End If
  400.     End If
  401. errOut:
  402. End Sub
  403. '- Rotate Track ball
  404. '  given a point on the screen the mouse was moved to
  405. '  simulate a track ball
  406. Private Sub RotateTrackBall(x As Integer, y As Integer)
  407.     Dim delta_x As Single, delta_y As Single
  408.     Dim delta_r As Single, radius As Single, denom As Single, angle As Single
  409.     ' rotation axis in camcoords, worldcoords, sframecoords
  410.     Dim axisC As D3DVECTOR
  411.     Dim wc As D3DVECTOR
  412.     Dim axisS As D3DVECTOR
  413.     Dim base As D3DVECTOR
  414.     Dim origin As D3DVECTOR
  415.     delta_x = x - m_lastX
  416.     delta_y = y - m_lastY
  417.     m_lastX = x
  418.     m_lastY = y
  419.             
  420.      delta_r = Sqr(delta_x * delta_x + delta_y * delta_y)
  421.      radius = 50
  422.      denom = Sqr(radius * radius + delta_r * delta_r)
  423.     If (delta_r = 0 Or denom = 0) Then Exit Sub
  424.     angle = (delta_r / denom)
  425.     axisC.x = (-delta_y / delta_r)
  426.     axisC.y = (-delta_x / delta_r)
  427.     axisC.z = 0
  428.     'transform camera space vector to world space
  429.     'm_largewindow.m_cameraFrame.Transform wc, axisC
  430.     g_dev.GetTransform D3DTS_VIEW, g_viewMatrix
  431.     D3DXVec3TransformCoord wc, axisC, g_viewMatrix
  432.     'transform world space vector into Model space
  433.     m_scene.UpdateFrames
  434.     axisS = m_root.InverseTransformCoord(wc)
  435.         
  436.     'transform origen camera space to world coordinates
  437.     'm_largewindow.m_cameraFrame.Transform  wc, origin
  438.     D3DXVec3TransformCoord wc, origin, g_viewMatrix
  439.     'transfer cam space origen to model space
  440.     base = m_root.InverseTransformCoord(wc)
  441.     axisS.x = axisS.x - base.x
  442.     axisS.y = axisS.y - base.y
  443.     axisS.z = axisS.z - base.z
  444.     m_root.AddRotation COMBINE_BEFORE, axisS.x, axisS.y, axisS.z, angle
  445. End Sub
  446. '- LoadAssembly
  447. '  See if we have the assembly loaded
  448. '  if not figure out which model to use from a db
  449. '  and load it
  450. '  by default it will attach it to the scene
  451. Function LoadAssembly(sname As String) As Long
  452.     Dim i As Long
  453.     Dim strCap As String
  454.     Dim strModel As String
  455.     Static b As Boolean
  456.     If b = True Then Exit Function
  457.     b = True
  458.     'make sure we dont habe it already
  459.     For i = 1 To m_nAssembly
  460.         If sname = m_assemblyName(i) Then
  461.             LoadAssembly = i
  462.             b = False
  463.             Exit Function
  464.         End If
  465.     Next
  466.     m_nAssembly = m_nAssembly + 1
  467.     m_assemblyName(m_nAssembly) = sname
  468.     'look up the model we need to load
  469.     'for this example we only show 1 model
  470.     'but one could query for the files from a database
  471.     strModel = "engine1.x"
  472.     strCap = Me.Caption
  473.     Me.Caption = "Loading- please wait"
  474.     DoEvents
  475.     Err.Number = 0
  476.     Form2.Top = Me.Top + Me.height / 4
  477.     Form2.Left = Me.Left + Me.width / 8
  478.     Form2.Show
  479.     DoEvents
  480.     Set m_assemblies(m_nAssembly) = New CD3DFrame
  481.     b = m_assemblies(m_nAssembly).InitFromFile(g_dev, m_mediadir + strModel, Nothing, Nothing)
  482.         
  483.     If b = False Then
  484.         Set m_assemblies(m_nAssembly) = Nothing
  485.         m_assemblyName(m_nAssembly) = ""
  486.         m_nAssembly = m_nAssembly - 1
  487.         Unload Form2
  488.         Me.Caption = strCap
  489.         GoTo errOut
  490.     End If
  491.     Me.Caption = strCap
  492.     m_assemblies(m_nAssembly).SetFVF g_dev, D3DFVF_VERTEX
  493.     m_assemblies(m_nAssembly).ComputeNormals
  494.     g_dev.SetRenderState D3DRS_AMBIENT, &H90909090
  495.     'Release the previous scene
  496.     Set m_scene = Nothing
  497.     Set m_root = Nothing
  498.     Set m_current = Nothing
  499.     'Create a root object for the scene
  500.     Set m_scene = New CD3DFrame
  501.     'Create a new root object to use for rotation matrix
  502.     Set m_root = D3DUtil_CreateFrame(m_scene)
  503.     'Add our assembly to the tree
  504.     m_root.AddChild m_assemblies(m_nAssembly)
  505.        
  506.     'Position our assembly
  507.     m_assemblies(m_nAssembly).AddTranslation COMBINE_replace, 0, 0, 5
  508.     'Recolor m_assemblies(m_nAssembly)
  509.         
  510.     LoadAssembly = m_nAssembly
  511.     Unload Form2
  512.     DoEvents
  513.     If fLoading Then End
  514.     RenderScene
  515.     DoEvents
  516.     Set m_root = m_assemblies(m_nAssembly)
  517.     m_binit = True
  518. errOut:
  519.     b = False
  520.     TreeView1.Enabled = True
  521.     largepict.SetFocus
  522.     DoEvents
  523. End Function
  524.      
  525. ' Command1_Click
  526. ' Add To Invoice
  527. Private Sub Command1_Click()
  528.     Dim itm As ListItem
  529.     If Text1.Text = "" Then Exit Sub
  530.     Set itm = ListView1.ListItems.Add(, , Text2.Text)
  531.     itm.SubItems(1) = Text3.Text
  532.     itm.SubItems(2) = Text1.Text
  533.     Set ListView1.SelectedItem = itm
  534.     itm.EnsureVisible
  535.     Text8.Text = format(val(Text8.Text) + val(Text3.Text), "#0.00")
  536. End Sub
  537. ' Command1_Click
  538. ' Delete from Invoice
  539. Private Sub Command2_Click()
  540.     If ListView1.SelectedItem Is Nothing Then Exit Sub
  541.     Text8 = format(val(Text8.Text) - val(ListView1.SelectedItem.SubItems(1)), "#0.00")
  542.     ListView1.ListItems.Remove ListView1.SelectedItem.index
  543. End Sub
  544.        
  545. ' Form_QueryUnload
  546. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  547.     fLoading = True
  548. End Sub
  549. '- MouseDown
  550. Private Sub largepict_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  551.     If m_binit = False Then Exit Sub
  552.     Dim b As Boolean
  553.     Dim mb As CD3DMesh
  554.     Dim r As Integer, c As Integer
  555.     Dim f As CD3DFrame
  556.     Dim p As CD3DFrame
  557.     Dim strName As String
  558.     Dim pick As CD3DPick
  559.     Dim n As Long
  560.     '- save our current position
  561.     m_bMouseDown = True
  562.     m_lastX = x
  563.     m_lastY = y
  564.     If Button = 1 Then
  565.         
  566.         'Get the frame under the the mouse
  567.         Set pick = New CD3DPick
  568.         If Not pick.ViewportPick(m_scene, x, y) Then Exit Sub
  569.                        
  570.                         
  571.         n = pick.FindNearest()
  572.         If n < 0 Then Exit Sub
  573.         Set f = pick.GetFrame(n)
  574.         
  575.                 
  576.         'Get its id and call SelectPart
  577.         'to fill in our text boxes
  578.         strName = f.ObjectName
  579.         strName = Right$(strName, Len(strName) - 1)
  580.         'The words V6 and Chevy are part of the manifold cover.
  581.         If strName = "words" Or strName = "v6" Then strName = "manifoldt"
  582.         
  583.         SelectPart strName, f.ObjectName
  584.         SelectTreeview strName
  585.         DoEvents
  586.         
  587.     End If
  588.     RenderScene
  589. End Sub
  590. '- MOUSE MOVE
  591. Private Sub largepict_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  592.     '- dont do anything unless the mouse is down
  593.     If m_bMouseDown = False Then
  594.         Exit Sub
  595.     End If
  596.     '- Rotate the object
  597.     RotateTrackBall CInt(x), CInt(y)
  598.     '- Rerender
  599.     RenderScene
  600.         
  601. End Sub
  602. '- MOUSE UP
  603. '  reset the mouse state
  604. Private Sub largepict_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  605.     m_bMouseDown = False
  606. End Sub
  607. '- largepict_Paint UP
  608. Private Sub largepict_Paint()
  609.     If Not m_binit Then Exit Sub
  610.     RenderScene
  611. End Sub
  612. '- MENU_ABOUT_Click
  613. Private Sub MENU_ABOUT_Click()
  614.     MsgBox "The model used by this sample, engine1.x, is provided courtesy of Viewpoint" + Chr(10) + Chr(13) + _
  615.         "Digital, Inc. (www.viewpoint.com).  It is provided for use with this sample" + Chr(10) + Chr(13) + _
  616.         "only and cannot be distributed with any application without prior written" + Chr(10) + Chr(13) + _
  617.         "consent.  V6 Engine Model copyright 1999 Viewpoint Digital, Inc.."
  618. End Sub
  619. ' MENU_EXIT_Click
  620. Private Sub MENU_EXIT_Click()
  621.     End
  622. End Sub
  623. ' TreeView1_Expand
  624. Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node)
  625.     Dim i As Long
  626.     Static b As Boolean
  627.         
  628.     If b Then Exit Sub
  629.     b = True
  630.         
  631.     'See if they are asking for a new assembly alltogether
  632.     If Mid$(Node.Tag, 1, 8) = "ASSMBLY:" Then
  633.         m_bInLoad = True
  634.         i = LoadAssembly(Node.Tag)
  635.         If i = 0 Then
  636.             MsgBox "Assembly not available at this time- try a different Engine"
  637.             b = False
  638.             Exit Sub
  639.         End If
  640.         
  641.     End If
  642.     b = False
  643. End Sub
  644. '- TreeView1_NodeClick
  645. Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
  646.             
  647.     Static b As Boolean
  648.     If b Then Exit Sub
  649.     b = True
  650.     Dim o As CD3DFrame
  651.     Dim i  As Long
  652.     If Node.Tag = "" Then
  653.         b = False
  654.         Exit Sub
  655.     End If
  656.     'Fill in the text boxes
  657.     SelectPart Node.Tag, "_" & Node.Tag
  658.     DoEvents
  659.         
  660.     'Render
  661.     RenderScene
  662.     DoEvents
  663.     b = False
  664. End Sub
  665. '- FillTreeViewControl
  666. Sub FillTreeViewControl()
  667.     TreeView1.Nodes.Clear
  668.     Dim sPartID As String
  669.     Dim sDesc As String
  670.     'A non-demo application would build the tree view
  671.     'from the database and dynamically load in new
  672.     'information into the treeview
  673.     Dim n As Node
  674.     Call TreeView1.Nodes.Add(, , "ASSEMBLIES", "Assemblies - [click here to start]")
  675.     Set n = TreeView1.Nodes.Add("ASSEMBLIES", tvwChild, "ENG V6 1996", "V6 4 Liter 1996 - [click here]")
  676.     n.Tag = "ASSMBLY:ENG V6 1996"
  677.     n.Selected = True
  678.     TreeView1.Nodes.Add("ASSEMBLIES", tvwChild, "ENG V8 1998", "V8 6 Liter 1998 - [not available]").Tag = ""
  679.     TreeView1.Nodes.Add("ASSEMBLIES", tvwChild, "OTHERENG", "Other Assemblies not available").Tag = ""
  680.     m_data.MoveTop
  681.     Do While m_data.IsEOF() = False
  682.         sPartID = m_data.ModelPart
  683.         sDesc = m_data.Description
  684.         TreeView1.Nodes.Add("ENG V6 1996", tvwChild, sPartID, sDesc).Tag = sPartID
  685.         m_data.MoveNext
  686.     Loop
  687. End Sub
  688. Sub SelectTreeview(sname As String)
  689.     On Local Error Resume Next
  690.     TreeView1.Nodes(sname).Selected = True
  691.     DoEvents
  692. End Sub
  693. '- RenderScene
  694. Sub RenderScene()
  695.     Dim hr As Long
  696.     If m_scene Is Nothing Then Exit Sub
  697.      
  698.     'See what state the device is in.
  699.     hr = g_dev.TestCooperativeLevel
  700.     If hr = D3DERR_DEVICENOTRESET Then
  701.         g_dev.Reset g_d3dpp
  702.         
  703.         'reset our state
  704.         g_lWindowWidth = largepict.ScaleWidth
  705.         g_lWindowHeight = largepict.ScaleHeight
  706.         D3DUtil.D3DUtil_SetupDefaultScene
  707.         DoEvents
  708.     ElseIf hr <> 0 Then
  709.         Exit Sub
  710.     End If
  711.     D3DXMatrixLookAtLH g_viewMatrix, vec3(0, 0, -1), vec3(0, 0, 0), vec3(0, 1, 0)
  712.     g_dev.SetTransform D3DTS_VIEW, g_viewMatrix
  713.     D3DUtil_ClearAll m_backcolor
  714.     g_dev.BeginScene
  715.     m_scene.Render g_dev
  716.     g_dev.EndScene
  717.     D3DUtil_PresentAll 0
  718. End Sub
  719.