home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "13_5Boolean"
- ClientHeight = 5700
- ClientLeft = 1140
- ClientTop = 1425
- ClientWidth = 6780
- Height = 6075
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 5700
- ScaleWidth = 6780
- Top = 1110
- Width = 6900
- Begin VB.Label Label1
- Caption = $"13_5Boolean.frx":0000
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 12
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 1575
- Left = 120
- TabIndex = 1
- Top = 120
- Width = 6615
- End
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 3855
- Left = 120
- TabIndex = 0
- Top = 1800
- Width = 6615
- _Version = 131072
- _ExtentX = 11668
- _ExtentY = 6800
- _StockProps = 0
- decorationOn = 0 'False
- viewingOn = 0 'False
- selectionEnable = -1 'True
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim bigDuckGate As SoGate
- Dim bigDuckTime As SoElapsedTime
- Dim myEventCB As SoEventCallback
- Dim myBoolean As SoBoolOperation
- Dim smallDuckGate As SoGate
- Dim smallDuckTime As SoElapsedTime
- Dim smallDuckRotXYZ As SoRotationXYZ
- Dim bigDuckRotXYZ As SoRotationXYZ
- Private Sub Form_Initialize()
- Dim root As SoSeparator
- Set root = New SoSeparator
- 'Add a camera and light
- Dim myCamera As SoPerspectiveCamera
- Set myCamera = V3Space1.getCurrentCamera
- Call myCamera.position.setValue(0#, -4#, 8#)
- Call myCamera.heightAngle.setValue(M_PI / 2.5)
- Call myCamera.nearDistance.setValue(1#)
- Call myCamera.farDistance.setValue(15#)
- Dim myLight As SoDirectionalLight
- Set myLight = New SoDirectionalLight
- Call root.addChild(myLight)
- 'Rotate scene slightly to get better view
- Dim globalRotXYZ As SoRotationXYZ
- Set globalRotXYZ = New SoRotationXYZ
- Call globalRotXYZ.axis.setValue(SoRotationXYZ_X)
- Call globalRotXYZ.angle.setValue(M_PI / 9)
- Call root.addChild(globalRotXYZ)
- 'Pond group
- Dim pond As SoSeparator
- Set pond = New SoSeparator
- Call root.addChild(pond)
- Dim pondTranslation As SoTranslation
- Set pondTranslation = New SoTranslation
- Call pondTranslation.translation.setValue(0#, -6.725, 0#)
- Call pond.addChild(pondTranslation)
- 'water
- Dim waterMaterial As SoMaterial
- Set waterMaterial = New SoMaterial
- Call waterMaterial.diffuseColor.setValue(0#, 0.3, 0.8)
- Call pond.addChild(waterMaterial)
- Dim waterCylinder As SoCylinder
- Set waterCylinder = New SoCylinder
- Call waterCylinder.radius.setValue(4#)
- Call waterCylinder.Height.setValue(0.5)
- Call pond.addChild(waterCylinder)
- 'rock
- Dim rockMaterial As SoMaterial
- Set rockMaterial = New SoMaterial
- Call rockMaterial.diffuseColor.setValue(0.8, 0.23, 0.03)
- Call pond.addChild(rockMaterial)
- Dim rockSphere As SoSphere
- Set rockSphere = New SoSphere
- Call rockSphere.radius.setValue(0.9)
- Call pond.addChild(rockSphere)
- 'Read the duck object from a file and add to the group
- Dim myInput As SoInput
- Set myInput = New SoInput
- Dim duckObject As Object
- Set duckObject = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\duck.iv", V3Space1.GetIDispatch())
- If duckObject Is Nothing Then
- Exit Sub
- End If
- 'CODE FOR The Inventor Mentor STARTS HERE
- 'Bigger duck group
- Dim bigDuck As SoSeparator
- Set bigDuck = New SoSeparator
- Call root.addChild(bigDuck)
- Set bigDuckRotXYZ = New SoRotationXYZ
- Call bigDuck.addChild(bigDuckRotXYZ)
- Dim bigInitialTransform As SoTransform
- Set bigInitialTransform = New SoTransform
- Call bigInitialTransform.translation.setValue(0#, 0#, 3.5)
- Call bigInitialTransform.scaleFactor.setValue(6#, 6#, 6#)
- Call bigDuck.addChild(bigInitialTransform)
- Call bigDuck.addChild(duckObject)
- 'Smaller duck group
- Dim smallDuck As SoSeparator
- Set smallDuck = New SoSeparator
- Call root.addChild(smallDuck)
- Set smallDuckRotXYZ = New SoRotationXYZ
- Call smallDuck.addChild(smallDuckRotXYZ)
- Dim smallInitialTransform As SoTransform
- Set smallInitialTransform = New SoTransform
-
- Call smallInitialTransform.translation.setValue(0#, -2.24, 1.5)
- Call smallInitialTransform.scaleFactor.setValue(4#, 4#, 4#)
- Call smallDuck.addChild(smallInitialTransform)
- Call smallDuck.addChild(duckObject)
- 'Use a gate engine to start/stop the rotation of
- 'the bigger duck.
- Set bigDuckGate = New SoGate
- Dim mffloat As SoMFFloat
- Set mffloat = New SoMFFloat
- Call bigDuckGate.setInputType(mffloat.getClassTypeId())
- Set bigDuckTime = New SoElapsedTime
- Call bigDuckGate.inputField.connectFromEngine(bigDuckTime.timeout)
- Call bigDuckRotXYZ.axis.setValue(SoRotationXYZ_Y)
- Call bigDuckRotXYZ.angle.connectFromEngine(bigDuckGate.output)
- 'Each mouse button press will enable/disable the gate
- 'controlling the bigger duck.
- Set myEventCB = New SoEventCallback
- Static eCB As SoEventCallbackCB
- Set eCB = New SoEventCallbackCB
- 'mouse
- eCB.nType = SoEventCallbackCB_MOUSEBUTTON
- Set eCB.userDataObject = bigDuckGate
- Call myEventCB.addEventCallback(V3Space1.GetIDispatch(), eCB)
- Call root.addChild(myEventCB)
- 'Use a Boolean engine to make the rotation of the smaller
- 'duck depend on the bigger duck. The smaller duck moves
- 'only when the bigger duck is still.
- Set myBoolean = New SoBoolOperation
- Call myBoolean.a.connectFrom(bigDuckGate.enable)
- Call myBoolean.operation.setValue(SoBoolOperation_NOT_A)
- Set smallDuckGate = New SoGate
- Call smallDuckGate.setInputType(mffloat.getClassTypeId())
- Set smallDuckTime = New SoElapsedTime
- Call smallDuckGate.inputField.connectFromEngine(smallDuckTime.timeout)
- Call smallDuckGate.enable.connectFromEngine(myBoolean.output)
- Call smallDuckRotXYZ.axis.setValue(SoRotationXYZ_Y)
- Call smallDuckRotXYZ.angle.connectFromEngine(smallDuckGate.output)
- Call V3Space1.setSceneRoot(root)
- End Sub
- Private Sub Form_Terminate()
- Call smallDuckRotXYZ.angle.disconnect
- Call bigDuckRotXYZ.angle.disconnect
- End Sub
- Private Sub V3Space1_MouseButtonEvent(ByVal eventCallbackCB As Object, ByVal eventCallback As Object)
- Dim event As SOEVENT
- Set event = eventCallback.getEvent()
- If Not event.isButtonPressEvent(event, 0) Then
- Exit Sub
- End If
- Dim gate As SoGate
- Set gate = eventCallbackCB.userDataObject
- If (gate.enable.getValue()) Then
- Call gate.enable.setValue(0)
- Else
- Call gate.enable.setValue(True)
- End If
-
- Call eventCallback.setHandled
- End Sub
-