home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / ACTIVEX / VIS3SPAC / DATA.9 / examples / vb / 03_02Robot / 03_02Robot.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-10-13  |  5.2 KB  |  157 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "03_02 Robot"
  4.    ClientHeight    =   5430
  5.    ClientLeft      =   915
  6.    ClientTop       =   1230
  7.    ClientWidth     =   6210
  8.    Height          =   5805
  9.    Left            =   855
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5430
  12.    ScaleWidth      =   6210
  13.    Top             =   915
  14.    Width           =   6330
  15.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  16.       Height          =   5412
  17.       Left            =   0
  18.       TabIndex        =   0
  19.       Top             =   0
  20.       Width           =   6132
  21.       _Version        =   131072
  22.       _ExtentX        =   10816
  23.       _ExtentY        =   9546
  24.       _StockProps     =   0
  25.    End
  26. Attribute VB_Name = "Form1"
  27. Attribute VB_Creatable = False
  28. Attribute VB_Exposed = False
  29. Private Sub Form_Initialize()
  30.     Call V3Space1.deleteSceneGraph
  31.     Dim robot As SoSeparator
  32.     Set robot = makeRobot()
  33.     Dim sceneRoot As SoSelection
  34.     Set sceneRoot = V3Space1.getSceneRoot
  35.     Call sceneRoot.addChild(robot)
  36.     Call V3Space1.viewAll
  37. End Sub
  38. Public Function makeRobot()
  39.     'Robot with legs
  40.     'Construct parts for legs (thigh, calf and foot)
  41.     Dim thigh As SoCube
  42.     Set thigh = New SoCube
  43.     Call thigh.Width.setValue(1.2)
  44.     Call thigh.Height.setValue(2.2)
  45.     Call thigh.depth.setValue(1.1)
  46.     Dim calfTransform As SoTransform
  47.     Set calfTransform = New SoTransform
  48.     Call calfTransform.translation.setValue(0#, -2.25, 0#)
  49.     Dim calf As SoCube
  50.     Set calf = New SoCube
  51.     Call calf.Width.setValue(1#)
  52.     Call calf.Height.setValue(2.2)
  53.     Call calf.depth.setValue(1)
  54.     Dim footTransform As SoTransform
  55.     Set footTransform = New SoTransform
  56.     Call footTransform.translation.setValue(0#, -1.5, 0.5)
  57.     Dim foot As SoCube
  58.     Set foot = New SoCube
  59.     Call foot.Width.setValue(0.8)
  60.     Call foot.Height.setValue(0.8)
  61.     Call foot.depth.setValue(2#)
  62.     'Put leg parts together
  63.     Dim leg As SoGroup
  64.     Set leg = New SoGroup
  65.     Call leg.addChild(thigh)
  66.     Call leg.addChild(calfTransform)
  67.     Call leg.addChild(calf)
  68.     Call leg.addChild(footTransform)
  69.     Call leg.addChild(foot)
  70.     Dim leftTransform As SoTransform
  71.     Set leftTransform = New SoTransform
  72.     Call leftTransform.translation.setValue(1#, -4.25, 0#)
  73.     'Left leg
  74.     Dim leftLeg As SoSeparator
  75.     Set leftLeg = New SoSeparator
  76.     Call leftLeg.addChild(leftTransform)
  77.     Call leftLeg.addChild(leg)
  78.     Dim rightTransform As SoTransform
  79.     Set rightTransform = New SoTransform
  80.     Call rightTransform.translation.setValue(-1#, -4.25, 0#)
  81.     'Right leg
  82.     Dim rightLeg As SoSeparator
  83.     Set rightLeg = New SoSeparator
  84.     Call rightLeg.addChild(rightTransform)
  85.     Call rightLeg.addChild(leg)
  86.     'Parts for body
  87.     Dim bodyTransform As SoTransform
  88.     Set bodyTransform = New SoTransform
  89.     Call bodyTransform.translation.setValue(0#, 3#, 0#)
  90.     Dim bronze As SoMaterial
  91.     Set bronze = New SoMaterial
  92.     Call bronze.ambientColor.setValue(0.33, 0.22, 0.27)
  93.     Call bronze.diffuseColor.setValue(0.78, 0.57, 0.11)
  94.     Call bronze.specularColor.setValue(0.99, 0.94, 0.81)
  95.     Call bronze.shininess.setValue(0.28)
  96.     Dim bodyCylinder As SoCylinder
  97.     Set bodyCylinder = New SoCylinder
  98.     Call bodyCylinder.radius.setValue(2.5)
  99.     Call bodyCylinder.Height.setValue(6#)
  100.     'Construct body out of parts
  101.     Dim body As SoSeparator
  102.     Set body = New SoSeparator
  103.     Call body.addChild(bodyTransform)
  104.     Call body.addChild(bronze)
  105.     Call body.addChild(bodyCylinder)
  106.     Call body.addChild(leftLeg)
  107.     Call body.addChild(rightLeg)
  108.     'Head parts
  109.     Dim headTransform As SoTransform
  110.     Set headTransform = New SoTransform
  111.     Call headTransform.translation.setValue(0#, 7.5, 0#)
  112.     Call headTransform.scaleFactor.setValue(1.5, 1.5, 1.5)
  113.     Dim silver As SoMaterial
  114.     Set silver = New SoMaterial
  115.     Call silver.ambientColor.setValue(0.2, 0.2, 0.2)
  116.     Call silver.diffuseColor.setValue(0.6, 0.6, 0.6)
  117.     Call silver.specularColor.setValue(0.5, 0.5, 0.5)
  118.     Call silver.shininess.setValue(0.5)
  119.     Dim headSphere As SoSphere
  120.     Set headSphere = New SoSphere
  121.     'Construct head
  122.     Dim head As SoSeparator
  123.     Set head = New SoSeparator
  124.     Call head.addChild(headTransform)
  125.     Call head.addChild(silver)
  126.     Call head.addChild(headSphere)
  127.     'Robot is just head and body
  128.     Dim robot As SoSeparator
  129.     Set robot = New SoSeparator
  130.     Call robot.addChild(body)
  131.     Call robot.addChild(head)
  132.     Set makeRobot = robot
  133.     'Clean up
  134.     Set thigh = Nothing
  135.     Set calfTransform = Nothing
  136.     Set calf = Nothing
  137.     Set leftLeg = Nothing
  138.     Set rightTransform = Nothing
  139.     Set rightLeg = Nothing
  140.     Set bodyTransform = Nothing
  141.     Set bronze = Nothing
  142.     Set bodyCylinder = Nothing
  143.     Set footTransform = Nothing
  144.     Set foot = Nothing
  145.     Set leg = Nothing
  146.     Set leftTransform = Nothing
  147.     Set leftLeg = Nothing
  148.     Set body = Nothing
  149.     Set bodyTransform = Nothing
  150.     Set bronze = Nothing
  151.     Set headTransform = Nothing
  152.     Set silver = Nothing
  153.     Set headSphere = Nothing
  154.     Set head = Nothing
  155.     Set robot = Nothing
  156. End Function
  157.