[IronPython] WPF 3D: Missing Viewport3D when importing

walgri walgri at gmail.com
Wed Aug 15 16:00:43 CEST 2007


Sorry, please replace the previous script with the following one.
Running this script as standalone actually shows what I meant and
hangs. But I guess this is unrelated to the Viewport3D issue.
#############################
import clr

from avalon import *

clr.AddReferenceByPartialName("PresentationCore")
clr.AddReferenceByPartialName("PresentationFramework")


from System.Windows import *
from System.Windows.Media import *
from System.Windows.Media.Media3D import *
#from System.Windows.Media.Media3D import Viewport3D


w=Window()
v=Viewport3D()

cam = PerspectiveCamera()
cam.FarPlaneDistance = 100
cam.LookDirection = Vector3D(-11,-10,-9)
cam.UpDirection = Vector3D(0,0,1)
cam.NearPlaneDistance = 1
cam.Position = Point3D(11,10,9)
cam.FieldOfView = 70
v.Camera = cam

triangleMesh = MeshGeometry3D()
point0 = Point3D(0, 0, 0)
point1 = Point3D(5, 0, 0)
point2 = Point3D(0, 0, 5)
triangleMesh.Positions.Add(point0)
triangleMesh.Positions.Add(point1)
triangleMesh.Positions.Add(point2)
triangleMesh.TriangleIndices.Add(0)
triangleMesh.TriangleIndices.Add(2)
triangleMesh.TriangleIndices.Add(1)
normal = Vector3D(0, 1, 0)
triangleMesh.Normals.Add(normal)
triangleMesh.Normals.Add(normal)
triangleMesh.Normals.Add(normal)
material = DiffuseMaterial(SolidColorBrush(Colors.Lime))
triangleModel = GeometryModel3D(triangleMesh, material)
model = ModelVisual3D()
model.Content = triangleModel
v.Children.Add(model)

#aggiungo una luce
lightmodel = ModelVisual3D()
light = DirectionalLight()
light.Color=Colors.White
light.Direction=Vector3D(-2,-3,-1)
lightmodel.Content = light
v.Children.Add(lightmodel)

#visualizza:
w.Content=v
w.Show()
#############################

Best regards,
Walgri




More information about the Ironpython-users mailing list