home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "12_1 Field Sensor"
- ClientHeight = 6030
- ClientLeft = 3270
- ClientTop = 1335
- ClientWidth = 6690
- Height = 6405
- Left = 3210
- LinkTopic = "Form1"
- ScaleHeight = 6030
- ScaleWidth = 6690
- Top = 1020
- Width = 6810
- Begin VB.TextBox cameraZ
- Height = 615
- Left = 4560
- TabIndex = 3
- Top = 5280
- Width = 1815
- End
- Begin VB.TextBox cameraY
- Height = 615
- Left = 2400
- TabIndex = 2
- Top = 5280
- Width = 1815
- End
- Begin VB.TextBox cameraX
- Height = 615
- Left = 120
- TabIndex = 1
- Top = 5280
- Width = 1815
- End
- Begin VB.Label Label4
- Caption = "This example uses a field sensor to detect changes to the scene's camera position."
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 12
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 615
- Left = 240
- TabIndex = 7
- Top = 120
- Width = 6015
- End
- Begin VB.Label Label3
- Caption = "Camera Z"
- Height = 255
- Left = 4560
- TabIndex = 6
- Top = 4800
- Width = 1455
- End
- Begin VB.Label Label2
- Caption = "Camera Y"
- Height = 255
- Left = 2400
- TabIndex = 5
- Top = 4800
- Width = 855
- End
- Begin VB.Label Label1
- Caption = "Camera X"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 4800
- Width = 855
- End
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 3855
- Left = 0
- TabIndex = 0
- Top = 840
- Width = 6615
- _Version = 131072
- _ExtentX = 11668
- _ExtentY = 6800
- _StockProps = 0
- decorationOn = 0 'False
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim mySensor As SoFieldSensor
- Private Sub Form_Initialize()
- Dim myInput As SoInput
- Dim root As Object
- Set myInput = New SoInput
- Dim idisp As Object
- Set idisp = V3Space1.GetIDispatch()
- Set root = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\bookshelf.iv", idisp)
- If root Is Nothing Then
- Exit Sub
- End If
- Call V3Space1.setSceneRoot(root)
- Call V3Space1.viewAll
- 'Get the camera from the viewer, and attach a
- 'field sensor to its position field:
- Dim camera As Object
- Set camera = V3Space1.getCurrentCamera()
- Dim X As Single
- Dim Y As Single
- Dim Z As Single
- Call camera.position.getValue(X, Y, Z)
- cameraX.Text = Str(X)
- cameraY.Text = Str(Y)
- cameraZ.Text = Str(Z)
- Static sensorCB As SoSensorCB
- Set sensorCB = New SoSensorCB
- sensorCB.sensorType = 5 'fieldSensor
- sensorCB.userDataObject = camera
- Set mySensor = New SoFieldSensor
- Call mySensor.attach(camera.position)
- Call mySensor.setFunction(idisp, sensorCB)
- cleanup:
- Set myInput = Nothing
- Set root = Nothing
- Set idisp = Nothing
- Set camera = Nothing
- End Sub
- Private Sub Text1_Change()
- End Sub
- Private Sub Text2_Change()
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Set mySensor = Nothing
- End Sub
- Private Sub V3Space1_FieldSensor(ByVal sensorCB As Object, ByVal sensor As Object)
- Dim cam As Object
- Set cam = sensorCB.userDataObject
- If cam Is Nothing Then
- GoTo cleanup
- End If
- Dim X As Single
- Dim Y As Single
- Dim Z As Single
- Call cam.position.getValue(X, Y, Z)
- cameraX.Text = Str(X)
- cameraY.Text = Str(Y)
- cameraZ.Text = Str(Z)
- cleanup:
- Set cam = Nothing
- Set sensorCB = Nothing
- Set sensor = Nothing
- End Sub
-