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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "13_6 Calculator"
  4.    ClientHeight    =   6435
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1425
  7.    ClientWidth     =   7035
  8.    Height          =   6810
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6435
  12.    ScaleWidth      =   7035
  13.    Top             =   1110
  14.    Width           =   7155
  15.    Begin VB.Label Label1 
  16.       Caption         =   $"13_6Calculator.frx":0000
  17.       BeginProperty Font 
  18.          name            =   "MS Sans Serif"
  19.          charset         =   0
  20.          weight          =   700
  21.          size            =   12
  22.          underline       =   0   'False
  23.          italic          =   0   'False
  24.          strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   1575
  27.       Left            =   120
  28.       TabIndex        =   1
  29.       Top             =   120
  30.       Width           =   6735
  31.    End
  32.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  33.       Height          =   4455
  34.       Left            =   120
  35.       TabIndex        =   0
  36.       Top             =   1920
  37.       Width           =   6735
  38.       _Version        =   131072
  39.       _ExtentX        =   11880
  40.       _ExtentY        =   7858
  41.       _StockProps     =   0
  42.       decorationOn    =   0   'False
  43.    End
  44. Attribute VB_Name = "Form1"
  45. Attribute VB_Creatable = False
  46. Attribute VB_Exposed = False
  47. Private Sub Form_Initialize()
  48.     Dim root As SoSeparator
  49.     Set root = New SoSeparator
  50.     'Add a camera and light
  51.     Dim myCamera As SoPerspectiveCamera
  52.     Set myCamera = V3Space1.getCurrentCamera
  53.     Call myCamera.position.setValue(-0.5, -1#, 19#)
  54.     Call myCamera.nearDistance.setValue(10#)
  55.     Call myCamera.farDistance.setValue(26#)
  56.     'Call root.addChild(myCamera)
  57.     Dim myLight As SoDirectionalLight
  58.     Set myLight = New SoDirectionalLight
  59.     Call root.addChild(myLight)
  60.     'Rotate scene slightly to get better view
  61.     Dim globalRotXYZ As SoRotationXYZ
  62.     Set globalRotXYZ = New SoRotationXYZ
  63.     Call globalRotXYZ.axis.setValue(SoRotationXYZ_X)
  64.     Call globalRotXYZ.angle.setValue(M_PI / 7)
  65.     Call root.addChild(globalRotXYZ)
  66.     'Read the background path from a file and add to the group
  67.     Dim myInput As SoInput
  68.     Set myInput = New SoInput
  69.     Dim flowerPath As Object
  70.     Set flowerPath = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\flowerPath.iv", V3Space1.GetIDispatch())
  71.     Call root.addChild(flowerPath)
  72.     '/////////////////////////////////////////////////////////////
  73.     '// CODE FOR The Inventor Mentor STARTS HERE
  74.     '// Flower group
  75.     Dim flowerGroup As SoSeparator
  76.     Set flowerGroup = New SoSeparator
  77.     Call root.addChild(flowerGroup)
  78.     'Read the flower object from a file and add to the group
  79.     Dim flower As Object
  80.     Set flower = myInput.readAllUrl(V3Space1.getRegistryDataPath() + "\examples\data\flower.iv", V3Space1.GetIDispatch())
  81.     'Set up the flower transformations
  82.     Dim danceTranslation As SoTranslation
  83.     Set danceTranslation = New SoTranslation
  84.     Dim initialTransform As SoTransform
  85.     Set initialTransform = New SoTransform
  86.     Call flowerGroup.addChild(danceTranslation)
  87.     Call initialTransform.scaleFactor.setValue(10#, 10#, 10#)
  88.     Call initialTransform.translation.setValue(0#, 0#, 5#)
  89.     Call flowerGroup.addChild(initialTransform)
  90.     Call flowerGroup.addChild(flower)
  91.     'Set up an engine to calculate the motion path:
  92.     'r = 5*cos(5*theta); x = r*cos(theta); z = r*sin(theta)
  93.     'Theta is incremented using a time counter engine,
  94.     'and converted to radians using an expression in
  95.     'the calculator engine.
  96.     Dim calcXZ As SoCalculator
  97.     Set calcXZ = New SoCalculator
  98.     Dim thetaCounter As SoTimeCounter
  99.     Set thetaCounter = New SoTimeCounter
  100.     Call thetaCounter.Max.setValue(360)
  101.     Call thetaCounter.step.setValue(4)
  102.     Call thetaCounter.frequency.setValue(0.075)
  103.     Call calcXZ.a.connectFromEngine(thetaCounter.output)
  104.     Call calcXZ.expression.set1Value(0, "ta=a*M_PI/180") 'theta
  105.     Call calcXZ.expression.set1Value(1, "tb=5*cos(5*ta)") 'r
  106.     Call calcXZ.expression.set1Value(2, "td=tb*cos(ta)") 'x
  107.     Call calcXZ.expression.set1Value(3, "te=tb*sin(ta)") 'z
  108.     Call calcXZ.expression.set1Value(4, "oA=vec3f(td,0,te)") '
  109.     Call danceTranslation.translation.connectFromEngine(calcXZ.oAU)
  110.     Call V3Space1.setSceneRoot(root)
  111. End Sub
  112.