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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "12_1 Field Sensor"
  4.    ClientHeight    =   6030
  5.    ClientLeft      =   3270
  6.    ClientTop       =   1335
  7.    ClientWidth     =   6690
  8.    Height          =   6405
  9.    Left            =   3210
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6030
  12.    ScaleWidth      =   6690
  13.    Top             =   1020
  14.    Width           =   6810
  15.    Begin VB.TextBox cameraZ 
  16.       Height          =   615
  17.       Left            =   4560
  18.       TabIndex        =   3
  19.       Top             =   5280
  20.       Width           =   1815
  21.    End
  22.    Begin VB.TextBox cameraY 
  23.       Height          =   615
  24.       Left            =   2400
  25.       TabIndex        =   2
  26.       Top             =   5280
  27.       Width           =   1815
  28.    End
  29.    Begin VB.TextBox cameraX 
  30.       Height          =   615
  31.       Left            =   120
  32.       TabIndex        =   1
  33.       Top             =   5280
  34.       Width           =   1815
  35.    End
  36.    Begin VB.Label Label4 
  37.       Caption         =   "This example uses a field sensor to detect changes to the scene's camera position."
  38.       BeginProperty Font 
  39.          name            =   "MS Sans Serif"
  40.          charset         =   0
  41.          weight          =   400
  42.          size            =   12
  43.          underline       =   0   'False
  44.          italic          =   0   'False
  45.          strikethrough   =   0   'False
  46.       EndProperty
  47.       Height          =   615
  48.       Left            =   240
  49.       TabIndex        =   7
  50.       Top             =   120
  51.       Width           =   6015
  52.    End
  53.    Begin VB.Label Label3 
  54.       Caption         =   "Camera Z"
  55.       Height          =   255
  56.       Left            =   4560
  57.       TabIndex        =   6
  58.       Top             =   4800
  59.       Width           =   1455
  60.    End
  61.    Begin VB.Label Label2 
  62.       Caption         =   "Camera Y"
  63.       Height          =   255
  64.       Left            =   2400
  65.       TabIndex        =   5
  66.       Top             =   4800
  67.       Width           =   855
  68.    End
  69.    Begin VB.Label Label1 
  70.       Caption         =   "Camera X"
  71.       Height          =   255
  72.       Left            =   120
  73.       TabIndex        =   4
  74.       Top             =   4800
  75.       Width           =   855
  76.    End
  77.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  78.       Height          =   3855
  79.       Left            =   0
  80.       TabIndex        =   0
  81.       Top             =   840
  82.       Width           =   6615
  83.       _Version        =   131072
  84.       _ExtentX        =   11668
  85.       _ExtentY        =   6800
  86.       _StockProps     =   0
  87.       decorationOn    =   0   'False
  88.    End
  89. Attribute VB_Name = "Form1"
  90. Attribute VB_Creatable = False
  91. Attribute VB_Exposed = False
  92.    Dim mySensor As SoFieldSensor
  93. Private Sub Form_Initialize()
  94.     Dim myInput As SoInput
  95.     Dim root As Object
  96.     Set myInput = New SoInput
  97.     Dim idisp As Object
  98.     Set idisp = V3Space1.GetIDispatch()
  99.     Set root = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\bookshelf.iv", idisp)
  100.     If root Is Nothing Then
  101.         Exit Sub
  102.     End If
  103.     Call V3Space1.setSceneRoot(root)
  104.     Call V3Space1.viewAll
  105.     'Get the camera from the viewer, and attach a
  106.     'field sensor to its position field:
  107.     Dim camera As Object
  108.     Set camera = V3Space1.getCurrentCamera()
  109.     Dim X As Single
  110.     Dim Y As Single
  111.     Dim Z As Single
  112.     Call camera.position.getValue(X, Y, Z)
  113.     cameraX.Text = Str(X)
  114.     cameraY.Text = Str(Y)
  115.     cameraZ.Text = Str(Z)
  116.     Static sensorCB As SoSensorCB
  117.     Set sensorCB = New SoSensorCB
  118.     sensorCB.sensorType = 5 'fieldSensor
  119.     sensorCB.userDataObject = camera
  120.     Set mySensor = New SoFieldSensor
  121.     Call mySensor.attach(camera.position)
  122.     Call mySensor.setFunction(idisp, sensorCB)
  123. cleanup:
  124.     Set myInput = Nothing
  125.     Set root = Nothing
  126.     Set idisp = Nothing
  127.     Set camera = Nothing
  128. End Sub
  129. Private Sub Text1_Change()
  130. End Sub
  131. Private Sub Text2_Change()
  132. End Sub
  133. Private Sub Form_Unload(Cancel As Integer)
  134.     Set mySensor = Nothing
  135. End Sub
  136. Private Sub V3Space1_FieldSensor(ByVal sensorCB As Object, ByVal sensor As Object)
  137.     Dim cam As Object
  138.     Set cam = sensorCB.userDataObject
  139.     If cam Is Nothing Then
  140.         GoTo cleanup
  141.     End If
  142.     Dim X As Single
  143.     Dim Y As Single
  144.     Dim Z As Single
  145.     Call cam.position.getValue(X, Y, Z)
  146.     cameraX.Text = Str(X)
  147.     cameraY.Text = Str(Y)
  148.     cameraZ.Text = Str(Z)
  149. cleanup:
  150.     Set cam = Nothing
  151.     Set sensorCB = Nothing
  152.     Set sensor = Nothing
  153. End Sub
  154.