home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "Trimmed Nurbs Surface"
- ClientHeight = 5565
- ClientLeft = 1140
- ClientTop = 1425
- ClientWidth = 5535
- Height = 5940
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 5565
- ScaleWidth = 5535
- Top = 1110
- Width = 5655
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 5415
- Left = 0
- TabIndex = 0
- Top = 120
- Width = 5535
- _Version = 131072
- _ExtentX = 9763
- _ExtentY = 9551
- _StockProps = 0
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub Form_Initialize()
- Dim root As SoSeparator
- Set root = New SoSeparator
- Dim rot As SoRotation
- Set rot = New SoRotation
- Dim vec3f As SbVec3f
- Set vec3f = New SbVec3f
- Call vec3f.setValue(0#, 1#, 0#)
- Dim tRot As SbRotation
- Set tRot = New SbRotation
- Call tRot.setValue(vec3f, 3.14159265358979 / 2#)
- Call rot.rotation.setValue(tRot)
- Call root.addChild(rot)
- 'Create the scene graph for the carpet
- Dim carpet As SoSeparator
- Set carpet = New SoSeparator
- Dim surf As SoSeparator
- Set surf = makeSurface()
- Dim tex As SoTexture2
- Set tex = New SoTexture2
- Call tex.filename.setValue(V3Space1.getRegistryDataPath() + "\examples\/data/diamondRug.rgb")
- Call carpet.addChild(tex)
- Call carpet.addChild(surf)
- Call root.addChild(carpet)
- 'Create the scene graph for the floor
- Dim floor As SoSeparator
- Set floor = New SoSeparator
- Dim xlate As SoTranslation
- Set xlate = New SoTranslation
- Dim scale1 As SoScale
- Set scale1 = New SoScale
- Dim myInput As SoInput
- Set myInput = New SoInput
- Dim result As SoNode
- Set idisp = V3Space1.GetIDispatch
- Set result = myInput.readAllUrl("examples\data\floorData.iv", idisp)
- Call xlate.translation.setValue(-12#, -5#, -5#)
- Call scale1.scaleFactor.setValue(2#, 1#, 2#)
- Call floor.addChild(xlate)
- Call floor.addChild(scale1)
- Call floor.addChild(result)
- Call root.addChild(floor)
- 'Create the scene graph for the carpet's shadow
- Dim shadow As SoSeparator
- Set shadow = New SoSeparator
- Dim shmdl As SoLightModel
- Set shmdl = New SoLightModel
- Dim shmtl As SoMaterial
- Set shmtl = New SoMaterial
- Dim shclr As SoBaseColor
- Set shclr = New SoBaseColor
- Dim shxl As SoTranslation
- Set shxl = New SoTranslation
- Dim shscl As SoScale
- Set shscl = New SoScale
- Call shmdl.model.setValue(0) 'SoLightModel:: BASE_COLOR
- Call shclr.RGB.setValue(0.21, 0.15, 0.09)
- Call shmtl.transparency.setValue(0.3)
- Call shxl.translation.setValue(0#, -4.9, 0#)
- Call shscl.scaleFactor.setValue(1#, 0#, 1#)
- Call shadow.addChild(shmtl)
- Call shadow.addChild(shmdl)
- Call shadow.addChild(shclr)
- Call shadow.addChild(shxl)
- Call shadow.addChild(shscl)
- Call shadow.addChild(surf)
- Call root.addChild(shadow)
- Call V3Space1.setSceneRoot(root)
- Dim cam As Object
- Set cam = V3Space1.getCurrentCamera
- Call cam.position.setValue(-8.5, 13#, 23#)
- Call vec3f.setValue(-2#, -2#, -4#)
- Call cam.pointAt(vec3f)
- Set root = Nothing
- Set rot = Nothing
- Set vec3f = Nothing
- Set tRot = Nothing
- Set carpet = Nothing
- Set surf = Nothing
- Set tex = Nothing
- Set floor = Nothing
- Set xlate = Nothing
- Set scale1 = Nothing
- Set myInput = Nothing
- Set result = Nothing
- Set idisp = Nothing
- Set shadow = Nothing
- Set shmdl = Nothing
- Set shmtl = Nothing
- Set shclr = Nothing
- Set shxl = Nothing
- Set shscl = Nothing
- Set cam = Nothing
- End Sub
- Public Static Function makeSurface()
- Dim surfSep As SoSeparator
- Set surfSep = New SoSeparator
- 'Define the Bezier surface including the control
- 'points, trim curve, and a complexity.
- Dim complexity As SoComplexity
- Set complexity = New SoComplexity
- Dim controlPts As SoCoordinate3
- Set controlPts = New SoCoordinate3
- Dim surface As SoNurbsSurface
- Set surface = New SoNurbsSurface
- Call complexity.Value.setValue(0.7)
- '0 {-4.5, -2.0, 8.0},
- Call controlPts.Point.set1Value(0, -4.5, -2#, 8#)
- '1 {-2.0, 1.0, 8.0},
- Call controlPts.Point.set1Value(1, -2#, 1#, 8#)
- '2 { 2.0, -3.0, 6.0},
- Call controlPts.Point.set1Value(2, 2#, -3#, 6#)
- '3 { 5.0, -1.0, 8.0},
- Call controlPts.Point.set1Value(3, 5#, -1#, 8#)
- '4 {-3.0, 3.0, 4.0},
- Call controlPts.Point.set1Value(4, -3#, 3#, 4#)
- '5 { 0.0, -1.0, 4.0},
- Call controlPts.Point.set1Value(5, 0#, -1#, 4#)
- '6 { 1.0, -1.0, 4.0},
- Call controlPts.Point.set1Value(6, 1#, -1#, 4#)
- '7 { 3.0, 2.0, 4.0},
- Call controlPts.Point.set1Value(7, 3#, 2#, 4#)
- '8 {-5.0, -2.0, -2.0},
- Call controlPts.Point.set1Value(8, -5#, -2#, -2#)
- '9 {-2.0, -4.0, -2.0},
- Call controlPts.Point.set1Value(9, -2#, -4#, -2#)
- '10 { 2.0, -1.0, -2.0},
- Call controlPts.Point.set1Value(10, 2#, -1#, -2#)
- '11 { 5.0, 0.0, -2.0},
- Call controlPts.Point.set1Value(11, 5#, 0#, -2#)
- '12 {-4.5, 2.0, -6.0},
- Call controlPts.Point.set1Value(12, -4.5, 2#, -6#)
- '13 {-2.0, -4.0, -5.0},
- Call controlPts.Point.set1Value(13, -2#, -4#, -5#)
- '14 { 2.0, 3.0, -5.0},
- Call controlPts.Point.set1Value(14, 2#, 3#, -5#)
- '15 { 4.5, -2.0, -6.0}}
- Call controlPts.Point.set1Value(15, 4.5, -2#, -6#)
- Call surface.numUControlPoints.setValue(4)
- Call surface.numVControlPoints.setValue(4)
- 'The Bezier knot vector for the surface.
- ' This knot vector is used in both the U and
- 'V directions.
- Call surface.uKnotVector.set1Value(0, 0)
- Call surface.uKnotVector.set1Value(1, 0)
- Call surface.uKnotVector.set1Value(2, 0)
- Call surface.uKnotVector.set1Value(3, 0)
- Call surface.uKnotVector.set1Value(4, 1)
- Call surface.uKnotVector.set1Value(5, 1)
- Call surface.uKnotVector.set1Value(6, 1)
- Call surface.uKnotVector.set1Value(7, 1)
- Call surface.vKnotVector.set1Value(0, 0)
- Call surface.vKnotVector.set1Value(1, 0)
- Call surface.vKnotVector.set1Value(2, 0)
- Call surface.vKnotVector.set1Value(3, 0)
- Call surface.vKnotVector.set1Value(4, 1)
- Call surface.vKnotVector.set1Value(5, 1)
- Call surface.vKnotVector.set1Value(6, 1)
- Call surface.vKnotVector.set1Value(7, 1)
- Call surfSep.addChild(complexity)
- Call surfSep.addChild(controlPts)
- Dim trimPts As SoProfileCoordinate2
- Set trimPts = New SoProfileCoordinate2
- Dim nTrim1 As SoNurbsProfile
- Set nTrim1 = New SoNurbsProfile
- Dim nTrim2 As SoNurbsProfile
- Set nTrim2 = New SoNurbsProfile
- Dim nTrim3 As SoNurbsProfile
- Set nTrim3 = New SoNurbsProfile
- '0 {0.0, 0.0},
- Call trimPts.Point.set1Value(0, 0#, 0#)
- '1 {1.0, 0.0},
- Call trimPts.Point.set1Value(1, 1#, 0#)
- '2 {1.0, 1.0},
- Call trimPts.Point.set1Value(2, 1#, 1#)
- '3 {0.0, 1.0},
- Call trimPts.Point.set1Value(3, 0#, 1#)
- '4 {0.2, 0.2},
- Call trimPts.Point.set1Value(4, 0.2, 0.2)
- '5 {0.2, 0.7},
- Call trimPts.Point.set1Value(5, 0.2, 0.7)
- '6 {0.9, 0.7},
- Call trimPts.Point.set1Value(6, 0.9, 0.7)
- '7 {0.9, 0.2},
- Call trimPts.Point.set1Value(7, 0.9, 0.2)
- '8 {0.7, 0.0},
- Call trimPts.Point.set1Value(8, 0.7, 0#)
- '9 {0.4, 0.8}}
- Call trimPts.Point.set1Value(9, 0.4, 0.8)
- 'int32_t trimInds[5]
- Call nTrim1.Index.set1Value(0, 0)
- Call nTrim1.Index.set1Value(1, 1)
- Call nTrim1.Index.set1Value(2, 2)
- Call nTrim1.Index.set1Value(3, 3)
- Call nTrim1.Index.set1Value(4, 0)
- 'float tknots1[7] = {0, 0, 1, 2, 3, 4, 4}
- Call nTrim1.knotVector.set1Value(0, 0)
- Call nTrim1.knotVector.set1Value(1, 0)
- Call nTrim1.knotVector.set1Value(2, 1)
- Call nTrim1.knotVector.set1Value(3, 2)
- Call nTrim1.knotVector.set1Value(4, 3)
- Call nTrim1.knotVector.set1Value(5, 4)
- Call nTrim1.knotVector.set1Value(6, 4)
- Call nTrim2.linkage.setValue(1) 'SoProfile::START_NEW
- Call nTrim2.Index.set1Value(0, 4)
- Call nTrim2.Index.set1Value(1, 5)
- Call nTrim2.Index.set1Value(2, 6)
- Call nTrim2.Index.set1Value(3, 7)
- 'float tknots2[6] = {0, 0, 1, 2, 3, 3}
- Call nTrim2.knotVector.set1Value(0, 0)
- Call nTrim2.knotVector.set1Value(1, 0)
- Call nTrim2.knotVector.set1Value(2, 1)
- Call nTrim2.knotVector.set1Value(3, 2)
- Call nTrim2.knotVector.set1Value(4, 3)
- Call nTrim2.knotVector.set1Value(5, 3)
- Call nTrim3.linkage.setValue(2) 'SoProfile::ADD_TO_CURRENT)
- Call nTrim3.Index.set1Value(0, 7)
- Call nTrim3.Index.set1Value(1, 8)
- Call nTrim3.Index.set1Value(2, 9)
- Call nTrim3.Index.set1Value(3, 4)
- 'float tknots3[8] = {0, 0, 0, 0, 1, 1, 1, 1}
- Call nTrim3.knotVector.set1Value(0, 0)
- Call nTrim3.knotVector.set1Value(1, 0)
- Call nTrim3.knotVector.set1Value(2, 0)
- Call nTrim3.knotVector.set1Value(3, 0)
- Call nTrim3.knotVector.set1Value(4, 1)
- Call nTrim3.knotVector.set1Value(5, 1)
- Call nTrim3.knotVector.set1Value(6, 1)
- Call nTrim3.knotVector.set1Value(7, 1)
- Call surfSep.addChild(trimPts)
- Call surfSep.addChild(nTrim1)
- Call surfSep.addChild(nTrim2)
- Call surfSep.addChild(nTrim3)
- Call surfSep.addChild(surface)
- Set makeSurface = surfSep
- End Function
-