home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "08_1B-Spline Curve"
- ClientHeight = 4860
- ClientLeft = 1155
- ClientTop = 1650
- ClientWidth = 6075
- Height = 5235
- Left = 1095
- LinkTopic = "Form1"
- ScaleHeight = 4860
- ScaleWidth = 6075
- Top = 1335
- Width = 6195
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 4815
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 6015
- _Version = 131072
- _ExtentX = 10610
- _ExtentY = 8493
- _StockProps = 0
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub Form_Initialize()
- 'CODE FOR The Inventor Mentor ENDS HERE
- '////////////////////////////////////////////////////////////
- Dim root As SoSeparator
- Set root = New SoSeparator
- 'Create the scene graph for the heart
- Dim heart As SoSeparator
- Set heart = New SoSeparator
- Dim curveSep As SoSeparator
- Set curveSep = makeCurve()
- Dim lmodel As SoLightModel
- Set lmodel = New SoLightModel
- Dim clr As SoBaseColor
- Set clr = New SoBaseColor
- Call lmodel.model.setValue(0) '= SoLightModel::BASE_COLOR;
- Call clr.RGB.setValue(1#, 0#, 0#)
- Call heart.addChild(lmodel)
- Call heart.addChild(clr)
- Call heart.addChild(curveSep)
- Call root.addChild(heart)
- 'Create the scene graph for the floor
- Dim floor As Object
- Set floor = New SoSeparator
- Dim xlate As SoTranslation
- Set xlate = New SoTranslation
- Dim rot As SoRotation
- Set rot = New SoRotation
- Dim scale1 As SoScale
- Set scale1 = New SoScale
- Dim myInput As SoInput
- Set myInput = New SoInput
- Dim result As SoGroup
- Dim idisp As Object
- Set idisp = V3Space1.GetIDispatch
- Set result = myInput.readAllUrl("file://d:\oiv40\v3space\vbDemos\data\floorData.iv", idisp)
- Call xlate.translation.setValue(-12#, -5#, -5#)
- Call scale1.scaleFactor.setValue(2#, 1#, 2#)
- 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.1415 / 2#)
- Call rot.rotation.setValue(tRot)
- Call floor.addChild(rot)
- Call floor.addChild(xlate)
- Call floor.addChild(scale1)
- Call floor.addChild(result)
- Call root.addChild(floor)
- 'Create the scene graph for the heart'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 shx1 = 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.5)
- Call shx1.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(shx1)
- Call shadow.addChild(shscl)
- Call shadow.addChild(curveSep)
- Call root.addChild(shadow)
- Call V3Space1.setSceneRoot(root)
- Dim cam As Object
- Set cam = V3Space1.getCurrentCamera
- Call cam.position.setValue(-6#, 8#, 20#)
- Call vec3f.setValue(0#, -2#, -4#)
- Call cam.pointAt(vec3f)
- Set root = Nothing
- Set cam = Nothing
- Set heart = Nothing
- Set curveSep = Nothing
- Set lmodel = Nothing
- Set clr = Nothing
- Set floor = Nothing
- Set xlate = Nothing
- Set vec3f = Nothing
- Set rot = Nothing
- Set scale1 = Nothing
- Set myInput = Nothing
- Set idisp = Nothing
- Set result = Nothing
- Set tRot = Nothing
- Set shadow = Nothing
- Set shmdl = Nothing
- Set shclr = Nothing
- Set shxl = Nothing
- Set shscl = Nothing
- End Sub
- Public Function makeCurve() As SoSeparator
- 'Create the nodes needed for the B-Spline curve.
- Dim curveSep As SoSeparator
- Set curveSep = New SoSeparator
- 'Set the draw style of the curve.
- Dim drawStyle As SoDrawStyle
- Set drawStyle = New SoDrawStyle
- Call drawStyle.lineWidth.setValue(4)
- Call curveSep.addChild(drawStyle)
- 'Define the NURBS curve including the control points
- 'and a complexity.
- Dim complexity As SoComplexity
- Set complexity = New SoComplexity
- Dim controlPts As SoCoordinate3
- Set controlPts = New SoCoordinate3
- Dim curve As SoNurbsCurve
- Set curve = New SoNurbsCurve
- Call complexity.Value.setValue(0.8)
- '0 { 4.0, -6.0, 6.0},
- Call controlPts.Point.set1Value(0, 4#, -6#, 6#)
- '1 {-4.0, 1.0, 0.0},
- Call controlPts.Point.set1Value(1, -4#, 1#, 0#)
- '2 {-1.5, 5.0, -6.0},
- Call controlPts.Point.set1Value(2, -1.5, 5#, -6#)
- '3 { 0.0, 2.0, -2.0},
- Call controlPts.Point.set1Value(3, 0#, 2#, -2#)
- '4 { 1.5, 5.0, -6.0},
- Call controlPts.Point.set1Value(4, 1.5, 5#, -6#)
- '5 { 4.0, 1.0, 0.0},
- Call controlPts.Point.set1Value(5, 4#, 1#, 0#)
- '6 {-4.0, -6.0, 6.0}};
- Call controlPts.Point.set1Value(6, -4#, -6#, 6#)
- Call curve.numControlPoints.setValue(7)
- 'The knot vector
- 'float knots[10] = {1, 2, 3, 4, 5, 5, 6, 7, 8, 9};
- Call curve.knotVector.set1Value(0, 1)
- Call curve.knotVector.set1Value(1, 1)
- Call curve.knotVector.set1Value(2, 2)
- Call curve.knotVector.set1Value(3, 3)
- Call curve.knotVector.set1Value(4, 4)
- Call curve.knotVector.set1Value(5, 5)
- Call curve.knotVector.set1Value(6, 6)
- Call curve.knotVector.set1Value(7, 7)
- Call curve.knotVector.set1Value(8, 8)
- Call curve.knotVector.set1Value(9, 9)
- Call curveSep.addChild(complexity)
- Call curveSep.addChild(controlPts)
- Call curveSep.addChild(curve)
- Set makeCurve = curveSep
- Set curveSep = Nothing
- Set drawStyle = Nothing
- Set complexity = Nothing
- Set controlPts = Nothing
- Set curve = Nothing
- End Function
-