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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "15_4 Customize"
  4.    ClientHeight    =   6915
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1425
  7.    ClientWidth     =   6690
  8.    Height          =   7290
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6915
  12.    ScaleWidth      =   6690
  13.    Top             =   1110
  14.    Width           =   6810
  15.    Begin VB.Label Label1 
  16.       Caption         =   $"15_4Customize.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          =   2535
  27.       Left            =   240
  28.       TabIndex        =   1
  29.       Top             =   240
  30.       Width           =   6255
  31.    End
  32.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  33.       Height          =   3975
  34.       Left            =   120
  35.       TabIndex        =   0
  36.       Top             =   2880
  37.       Width           =   6375
  38.       _Version        =   131072
  39.       _ExtentX        =   11245
  40.       _ExtentY        =   7011
  41.       _StockProps     =   0
  42.       decorationOn    =   0   'False
  43.       viewingOn       =   0   'False
  44.    End
  45. Attribute VB_Name = "Form1"
  46. Attribute VB_Creatable = False
  47. Attribute VB_Exposed = False
  48. Private Sub Form_Initialize()
  49.     Dim root As SoSeparator
  50.     Set root = New SoSeparator
  51.     'Create 3 translate1Draggers and place them in space.
  52.     Dim xDragSep As SoSeparator
  53.     Set xDragSep = New SoSeparator
  54.     Dim yDragSep As SoSeparator
  55.     Set yDragSep = New SoSeparator
  56.     Dim zDragSep As SoSeparator
  57.     Set zDragSep = New SoSeparator
  58.     Call root.addChild(xDragSep)
  59.     Call root.addChild(yDragSep)
  60.     Call root.addChild(zDragSep)
  61.     'Separators will each hold a different transform
  62.     Dim xDragXf As SoTransform
  63.     Set xDragXf = New SoTransform
  64.     Dim yDragXf As SoTransform
  65.     Set yDragXf = New SoTransform
  66.     Dim zDragXf As SoTransform
  67.     Set zDragXf = New SoTransform
  68.     Call xDragXf.setFieldDataString("translation  0 -4 8")
  69.     Call yDragXf.setFieldDataString("translation -8  0 8 rotation 0 0 1  1.57")
  70.     Call zDragXf.setFieldDataString("translation -8 -4 0 rotation 0 1 0 -1.57")
  71.     Call xDragSep.addChild(xDragXf)
  72.     Call yDragSep.addChild(yDragXf)
  73.     Call zDragSep.addChild(zDragXf)
  74.     'Add the draggers under the separators, after transforms
  75.     Dim xDragger As SoTranslate1Dragger
  76.     Set xDragger = New SoTranslate1Dragger
  77.     Dim yDragger As SoTranslate1Dragger
  78.     Set yDragger = New SoTranslate1Dragger
  79.     Dim zDragger As SoTranslate1Dragger
  80.     Set zDragger = New SoTranslate1Dragger
  81.     Call xDragSep.addChild(xDragger)
  82.     Call yDragSep.addChild(yDragger)
  83.     Call zDragSep.addChild(zDragger)
  84.     'Create myTranslator and myTranslatorActive.
  85.     'These are custom geometry for the draggers.
  86.     Dim myTranslator As SoSeparator
  87.     Set myTranslator = New SoSeparator
  88.     Dim myTranslatorActive As SoSeparator
  89.     Set myTranslatorActive = New SoSeparator
  90.     'Materials for the dragger in regular and active states
  91.     Dim myMtl As SoMaterial
  92.     Set myMtl = New SoMaterial
  93.     Dim myActiveMtl As SoMaterial
  94.     Set myActiveMtl = New SoMaterial
  95.     Call myMtl.diffuseColor.setValue(1, 1, 1)
  96.     Call myActiveMtl.diffuseColor.setValue(1, 1, 0)
  97.     Call myTranslator.addChild(myMtl)
  98.     Call myTranslatorActive.addChild(myActiveMtl)
  99.     'Same shape for both versions.
  100.     Dim myCube As SoCube
  101.     Set myCube = New SoCube
  102.     Call myCube.setFieldDataString("width 3 height .4 depth .4")
  103.     Call myTranslator.addChild(myCube)
  104.     Call myTranslatorActive.addChild(myCube)
  105.     ' Now, customize the draggers with the pieces we created.
  106.     Call xDragger.setPart(utlSbName("translator"), myTranslator)
  107.     Call xDragger.setPart(utlSbName("translatorActive"), myTranslatorActive)
  108.     Call yDragger.setPart(utlSbName("translator"), myTranslator)
  109.     Call yDragger.setPart(utlSbName("translatorActive"), myTranslatorActive)
  110.     Call zDragger.setPart(utlSbName("translator"), myTranslator)
  111.     Call zDragger.setPart(utlSbName("translatorActive"), myTranslatorActive)
  112.     'Create shape kit for the 3D text
  113.     'The text says 'Slide Cubes To Move Me'
  114.     Dim textKit As SoShapeKit
  115.     Set textKit = New SoShapeKit
  116.     Call root.addChild(textKit)
  117.     Dim myText3 As SoText3
  118.     Set myText3 = New SoText3
  119.     Call textKit.setPart(utlSbName("shape"), myText3)
  120.     Call myText3.justification.setValue(SoText3_CENTER)
  121.     Call myText3.Str.set1Value(0, "Slide Cubes")
  122.     Call myText3.Str.set1Value(1, "To")
  123.     Call myText3.Str.set1Value(2, "Move Me")
  124.     Call textKit.setParam("font { size 2}")
  125.     Call textKit.setParam("material { diffuseColor 1 1 0}")
  126.     'Create shape kit for surrounding box.
  127.     'It's an unpickable cube, sized as (16,8,16)
  128.     Dim boxKit As SoShapeKit
  129.     Set boxKit = New SoShapeKit
  130.     Call root.addChild(boxKit)
  131.     Dim cube As SoCube
  132.     Set cube = New SoCube
  133.     Call boxKit.setPart(utlSbName("shape"), cube)
  134.     Call boxKit.setParam("drawStyle { style LINES }")
  135.     Call boxKit.setParam("pickStyle { style UNPICKABLE }")
  136.     Call boxKit.setParam("material { emissiveColor 1 0 1 }")
  137.     Call boxKit.setParam("shape { width 16 height 8 depth 16 }")
  138.     'Create the calculator to make a translation
  139.     'for the text.  The x component of a translate1Dragger's
  140.     'translation field shows how far it moved in that
  141.     'direction. So our text's translation is:
  142.     '(xDragTranslate[0],yDragTranslate[0],zDragTranslate[0])
  143.     Static myCalc As SoCalculator
  144.     Set myCalc = New SoCalculator
  145.     Call myCalc.AU.connectFrom(xDragger.translation)
  146.     Call myCalc.BU.connectFrom(yDragger.translation)
  147.     Call myCalc.CU.connectFrom(zDragger.translation)
  148.     Call myCalc.expression.setValue("oA = vec3f(A[0],B[0],C[0])")
  149.     'Connect the the translation in textKit from myCalc
  150.     Dim textXf As SoTransform
  151.        
  152.     Set textXf = textKit.getPart(utlSbName("transform"), True)
  153.     Call textXf.translation.connectFromEngine(myCalc.oAU)
  154.     Call V3Space1.setSceneRoot(root)
  155.     Call V3Space1.viewAll
  156. End Sub
  157.