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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "03_01 Molecule"
  4.    ClientHeight    =   4905
  5.    ClientLeft      =   915
  6.    ClientTop       =   1230
  7.    ClientWidth     =   5670
  8.    Height          =   5280
  9.    Left            =   855
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4905
  12.    ScaleWidth      =   5670
  13.    Top             =   915
  14.    Width           =   5790
  15.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  16.       Height          =   4932
  17.       Left            =   0
  18.       TabIndex        =   0
  19.       Top             =   0
  20.       Width           =   5652
  21.       _Version        =   131072
  22.       _ExtentX        =   9970
  23.       _ExtentY        =   8700
  24.       _StockProps     =   0
  25.    End
  26. Attribute VB_Name = "Form1"
  27. Attribute VB_Creatable = False
  28. Attribute VB_Exposed = False
  29. Public Function makeWaterMolecule()
  30.     ' Construct all parts
  31.     Dim waterMolecule As SoGroup
  32.     Set waterMolecule = New SoGroup 'water molecule
  33.     Dim oxygen As SoGroup
  34.     Set oxygen = New SoGroup 'oxygen atom
  35.     Dim redPlastic As SoMaterial
  36.     Set redPlastic = New SoMaterial
  37.     Dim sphere1 As SoSphere
  38.     Set sphere1 = New SoSphere
  39.     Dim hydrogen1 As SoGroup ' hydrogen atoms
  40.     Set hydrogen1 = New SoGroup
  41.     Dim hydrogen2 As SoGroup
  42.     Set hydrogen2 = New SoGroup
  43.     Dim hydrogenXform1 As SoTransform
  44.     Set hydrogenXform1 = New SoTransform
  45.     Dim hydrogenXform2 As SoTransform
  46.     Set hydrogenXform2 = New SoTransform
  47.     Dim whitePlastic As SoMaterial
  48.     Set whitePlastic = New SoMaterial
  49.     Dim sphere2 As SoSphere
  50.     Set sphere2 = New SoSphere
  51.     Dim sphere3 As SoSphere
  52.     Set sphere3 = New SoSphere
  53.        
  54.     'Set all field values for the oxygen atom
  55.     Dim color As SbVec3f
  56.     Set color = New SbVec3f
  57.     Call color.setValue(1#, 0#, 0#)
  58.     Call redPlastic.ambientColor.setValueColor(color)
  59.     Call redPlastic.diffuseColor.setValueColor(color)
  60.     Call color.setValue(0.5, 0.5, 0.5)
  61.     Call redPlastic.specularColor.setValueColor(color)
  62.     Call redPlastic.shininess.setValue(0.5)
  63.     'Set all field values for the hydrogen atoms
  64.     Call hydrogenXform1.scaleFactor.setValue(0.75, 0.75, 0.75)
  65.     Call hydrogenXform1.translation.setValue(0#, -1.2, 0#)
  66.     Call hydrogenXform2.translation.setValue(1.1852, 1.3877, 0#)
  67.     Call color.setValue(1#, 1#, 1#)
  68.     Call whitePlastic.ambientColor.setValueColor(color)
  69.     Call whitePlastic.diffuseColor.setValueColor(color)
  70.     Call color.setValue(0.5, 0.5, 0.5)
  71.     Call whitePlastic.specularColor.setValueColor(color)
  72.     Call whitePlastic.shininess.setValue(0.5)
  73.     'Create a hierarchy
  74.     Call waterMolecule.addChild(oxygen)
  75.     Call waterMolecule.addChild(hydrogen1)
  76.     Call waterMolecule.addChild(hydrogen2)
  77.     Call oxygen.addChild(redPlastic)
  78.     Call oxygen.addChild(sphere1)
  79.     Call hydrogen1.addChild(hydrogenXform1)
  80.     Call hydrogen1.addChild(whitePlastic)
  81.     Call hydrogen1.addChild(sphere2)
  82.     Call hydrogen2.addChild(hydrogenXform2)
  83.     Call hydrogen2.addChild(sphere3)
  84.    Set makeWaterMolecule = waterMolecule
  85.     'Clean up
  86.     Set oxygen = Nothing
  87.     Set redPlastic = Nothing
  88.     Set sphere1 = Nothing
  89.     Set hydrogen1 = Nothing
  90.     Set hydrogen2 = Nothing
  91.     Set hydrogenXform1 = Nothing
  92.     Set hydrogenXform1 = Nothing
  93.     Set whitePlastic = Nothing
  94.     Set color = Nothing
  95.     Set waterMolecule = Nothing
  96. End Function
  97. Private Sub Form_Initialize()
  98.     Call V3Space1.deleteSceneGraph
  99.     Dim molecule As SoGroup
  100.     Set molecule = makeWaterMolecule()
  101.     Call V3Space1.setSceneRoot(molecule)
  102.     Call V3Space1.viewAll
  103.     'Clean up
  104.     Set molecule = Nothing
  105. End Sub
  106.