home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "13_4 Gate"
- ClientHeight = 6630
- ClientLeft = 1140
- ClientTop = 1425
- ClientWidth = 7365
- Height = 7005
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 6630
- ScaleWidth = 7365
- Top = 1110
- Width = 7485
- Begin VB.Label Label1
- Caption = $"13_4Gate.frx":0000
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 12
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 975
- Left = 120
- TabIndex = 1
- Top = 240
- Width = 7095
- End
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 5295
- Left = 120
- TabIndex = 0
- Top = 1320
- Width = 7215
- _Version = 131072
- _ExtentX = 12726
- _ExtentY = 9340
- _StockProps = 0
- decorationOn = 0 'False
- viewingOn = 0 'False
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub Form_Initialize()
- Dim root As SoSeparator
- Set root = New SoSeparator
- 'Rotate scene slightly to get better view
- Dim globalRotXYZ As SoRotationXYZ
- Set globalRotXYZ = New SoRotationXYZ
- Call globalRotXYZ.axis.setValue(0) 'SoRotationXYZ::X
- Call globalRotXYZ.angle.setValue(3.1415 / 9#)
- Call root.addChild(globalRotXYZ)
- 'Pond group
- Dim pond As SoSeparator
- Set pond = New SoSeparator
- Call root.addChild(pond)
- Dim cylMaterial As SoMaterial
- Set cylMaterial = New SoMaterial
- Call cylMaterial.diffuseColor.setValue(0#, 0.3, 0.8)
- Call pond.addChild(cylMaterial)
- Dim cylTranslation As SoTranslation
- Set cylTranslation = New SoTranslation
- Call cylTranslation.translation.setValue(0#, -6.725, 0#)
- Call pond.addChild(cylTranslation)
- Dim myCylinder As SoCylinder
- Set myCylinder = New SoCylinder
- Call myCylinder.radius.setValue(4#)
- Call myCylinder.Height.setValue(0.5)
- Call pond.addChild(myCylinder)
- 'Duck group
- Dim duck As SoSeparator
- Set duck = New SoSeparator
- Call root.addChild(duck)
- Dim myInput As SoInput
- Set myInput = New SoInput
- Dim idisp As Object
- Set idisp = V3Space1.GetIDispatch
- Dim duckObject As Object
- Set duckObject = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\duck.iv", idisp)
- If (duckObject Is Nothing) Then
- Exit Sub
- End If
- 'Set up the duck transformations
- Dim duckRotXYZ As SoRotationXYZ
- Set duckRotXYZ = New SoRotationXYZ
- Call duck.addChild(duckRotXYZ)
- Dim initialTransform As SoTransform
- Set initialTransform = New SoTransform
- Call initialTransform.translation.setValue(0#, 0#, 3#)
- Call initialTransform.scaleFactor.setValue(6#, 6#, 6#)
- Call duck.addChild(initialTransform)
- Call duck.addChild(duckObject)
- 'Update the rotation value if the gate is enabled.
- Static myGate As SoGate
- Set myGate = New SoGate
- Dim mffloat As SoMFFloat
- Set mffloat = New SoMFFloat
- Call myGate.setInputType(mffloat.getClassTypeId())
- Static myCounter As SoElapsedTime
- Set myCounter = New SoElapsedTime
- Call myGate.inputField.connectFromEngine(myCounter.timeout)
- Call duckRotXYZ.axis.setValue(1) 'SoRotationXYZ::Y
- Call duckRotXYZ.angle.connectFromEngine(myGate.output)
- 'Add an event callback to catch mouse button presses.
- 'Each button press will enable or disable the duck motion.
- Static myEventCB As SoEventCallback
- Set myEventCB = New SoEventCallback
- Static eCB As SoEventCallbackCB
- Set eCB = New SoEventCallbackCB
- 'mouse
- eCB.nType = 4
- Set eCB.userDataObject = myGate
- Call myEventCB.addEventCallback(idisp, eCB)
- Call root.addChild(myEventCB)
- Call V3Space1.setSceneRoot(root)
- Dim cam As Object
- Set cam = V3Space1.getCurrentCamera()
- Call cam.position.setValue(0#, -4#, 8#)
- Call cam.heightAngle.setValue(3.1415 / 2.5)
- Call cam.nearDistance.setValue(1#)
- Call cam.farDistance.setValue(15#)
- Call myGate.enable.setValue(True)
- End Sub
- Private Sub V3Space1_MouseButtonEvent(ByVal eventCallbackCB As Object, ByVal eventCallback As Object)
- If eventCallbackCB.userDataObject Is Nothing Then
- GoTo cleanup
- End If
- Dim ev As Object
- Set ev = eventCallback.getEvent
- If Not ev.isButtonPressEvent(ev, 0) Then
- GoTo cleanup
- End If
- If eventCallbackCB.userDataObject.enable.getValue() Then
- eventCallbackCB.userDataObject.enable.setValue (False)
- Else
- eventCallbackCB.userDataObject.enable.setValue (True)
- End If
- cleanup:
- Set eventCallbackCB = Nothing
- Set eventCallback = Nothing
- Set ev = Nothing
- End Sub
-