home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / ACTIVEX / VIS3SPAC / DATA.9 / examples / vb / 13_4Gate / 13_4Gate.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-11-10  |  5.2 KB  |  147 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "13_4 Gate"
  4.    ClientHeight    =   6630
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1425
  7.    ClientWidth     =   7365
  8.    Height          =   7005
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6630
  12.    ScaleWidth      =   7365
  13.    Top             =   1110
  14.    Width           =   7485
  15.    Begin VB.Label Label1 
  16.       Caption         =   $"13_4Gate.frx":0000
  17.       BeginProperty Font 
  18.          name            =   "MS Sans Serif"
  19.          charset         =   0
  20.          weight          =   400
  21.          size            =   12
  22.          underline       =   0   'False
  23.          italic          =   0   'False
  24.          strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   975
  27.       Left            =   120
  28.       TabIndex        =   1
  29.       Top             =   240
  30.       Width           =   7095
  31.    End
  32.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  33.       Height          =   5295
  34.       Left            =   120
  35.       TabIndex        =   0
  36.       Top             =   1320
  37.       Width           =   7215
  38.       _Version        =   131072
  39.       _ExtentX        =   12726
  40.       _ExtentY        =   9340
  41.       _StockProps     =   0
  42.       decorationOn    =   0   'False
  43.       viewingOn       =   0   'False
  44.    End
  45. Attribute VB_Name = "Form1"
  46. Attribute VB_Creatable = False
  47. Attribute VB_Exposed = False
  48. Private Sub Form_Initialize()
  49.     Dim root As SoSeparator
  50.     Set root = New SoSeparator
  51.     'Rotate scene slightly to get better view
  52.     Dim globalRotXYZ As SoRotationXYZ
  53.     Set globalRotXYZ = New SoRotationXYZ
  54.     Call globalRotXYZ.axis.setValue(0) 'SoRotationXYZ::X
  55.     Call globalRotXYZ.angle.setValue(3.1415 / 9#)
  56.     Call root.addChild(globalRotXYZ)
  57.     'Pond group
  58.     Dim pond As SoSeparator
  59.     Set pond = New SoSeparator
  60.     Call root.addChild(pond)
  61.     Dim cylMaterial As SoMaterial
  62.     Set cylMaterial = New SoMaterial
  63.     Call cylMaterial.diffuseColor.setValue(0#, 0.3, 0.8)
  64.     Call pond.addChild(cylMaterial)
  65.     Dim cylTranslation As SoTranslation
  66.     Set cylTranslation = New SoTranslation
  67.     Call cylTranslation.translation.setValue(0#, -6.725, 0#)
  68.     Call pond.addChild(cylTranslation)
  69.     Dim myCylinder As SoCylinder
  70.     Set myCylinder = New SoCylinder
  71.     Call myCylinder.radius.setValue(4#)
  72.     Call myCylinder.Height.setValue(0.5)
  73.     Call pond.addChild(myCylinder)
  74.     'Duck group
  75.     Dim duck As SoSeparator
  76.     Set duck = New SoSeparator
  77.     Call root.addChild(duck)
  78.     Dim myInput As SoInput
  79.     Set myInput = New SoInput
  80.     Dim idisp As Object
  81.     Set idisp = V3Space1.GetIDispatch
  82.     Dim duckObject As Object
  83.     Set duckObject = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\duck.iv", idisp)
  84.     If (duckObject Is Nothing) Then
  85.         Exit Sub
  86.     End If
  87.     'Set up the duck transformations
  88.     Dim duckRotXYZ As SoRotationXYZ
  89.     Set duckRotXYZ = New SoRotationXYZ
  90.     Call duck.addChild(duckRotXYZ)
  91.     Dim initialTransform As SoTransform
  92.     Set initialTransform = New SoTransform
  93.     Call initialTransform.translation.setValue(0#, 0#, 3#)
  94.     Call initialTransform.scaleFactor.setValue(6#, 6#, 6#)
  95.     Call duck.addChild(initialTransform)
  96.     Call duck.addChild(duckObject)
  97.     'Update the rotation value if the gate is enabled.
  98.     Static myGate As SoGate
  99.     Set myGate = New SoGate
  100.     Dim mffloat As SoMFFloat
  101.     Set mffloat = New SoMFFloat
  102.     Call myGate.setInputType(mffloat.getClassTypeId())
  103.     Static myCounter As SoElapsedTime
  104.     Set myCounter = New SoElapsedTime
  105.     Call myGate.inputField.connectFromEngine(myCounter.timeout)
  106.     Call duckRotXYZ.axis.setValue(1) 'SoRotationXYZ::Y
  107.     Call duckRotXYZ.angle.connectFromEngine(myGate.output)
  108.     'Add an event callback to catch mouse button presses.
  109.     'Each button press will enable or disable the duck motion.
  110.     Static myEventCB As SoEventCallback
  111.     Set myEventCB = New SoEventCallback
  112.     Static eCB As SoEventCallbackCB
  113.     Set eCB = New SoEventCallbackCB
  114.     'mouse
  115.     eCB.nType = 4
  116.     Set eCB.userDataObject = myGate
  117.     Call myEventCB.addEventCallback(idisp, eCB)
  118.     Call root.addChild(myEventCB)
  119.     Call V3Space1.setSceneRoot(root)
  120.     Dim cam As Object
  121.     Set cam = V3Space1.getCurrentCamera()
  122.     Call cam.position.setValue(0#, -4#, 8#)
  123.     Call cam.heightAngle.setValue(3.1415 / 2.5)
  124.     Call cam.nearDistance.setValue(1#)
  125.     Call cam.farDistance.setValue(15#)
  126.     Call myGate.enable.setValue(True)
  127. End Sub
  128. Private Sub V3Space1_MouseButtonEvent(ByVal eventCallbackCB As Object, ByVal eventCallback As Object)
  129.     If eventCallbackCB.userDataObject Is Nothing Then
  130.         GoTo cleanup
  131.     End If
  132.     Dim ev As Object
  133.     Set ev = eventCallback.getEvent
  134.     If Not ev.isButtonPressEvent(ev, 0) Then
  135.         GoTo cleanup
  136.     End If
  137.     If eventCallbackCB.userDataObject.enable.getValue() Then
  138.         eventCallbackCB.userDataObject.enable.setValue (False)
  139.     Else
  140.         eventCallbackCB.userDataObject.enable.setValue (True)
  141.     End If
  142. cleanup:
  143.     Set eventCallbackCB = Nothing
  144.     Set eventCallback = Nothing
  145.     Set ev = Nothing
  146. End Sub
  147.