本文整理汇总了C#中System.Windows.Media.Media3D.ModelVisual3D类的典型用法代码示例。如果您正苦于以下问题:C# ModelVisual3D类的具体用法?C# ModelVisual3D怎么用?C# ModelVisual3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelVisual3D类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了ModelVisual3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: render
public GeometryModel3D[] render()
{
Model3DGroup modelGroup = new Model3DGroup();
Viewport3D visualisation = new Viewport3D();
ModelVisual3D modelsVisual = new ModelVisual3D();
int depthPoint = 0;
//Setup viewport environment
init = new ViewportCalibrator(this.cp);
visualisation = init.setupViewport(init.setupCamera(), this.cp.ActualHeight, this.cp.ActualWidth);
//Create triangle mesh
for (int y = 0; y < 480; y += pos)
{
for (int x = 0; x < 640; x += pos)
{
pts[depthPoint] = Triangle(x, y, pos);
pts[depthPoint].Transform = new TranslateTransform3D(0, 0, 0);
modelGroup.Children.Add(pts[depthPoint]);
depthPoint++;
}
}
//Add mesh to visualisation and viewport/canvas
modelGroup.Children.Add(init.setupDirectionalLights(Colors.White));
modelsVisual.Content = modelGroup;
visualisation.Children.Add(modelsVisual);
cp.Children.Add(visualisation);
Canvas.SetTop(visualisation, 0);
Canvas.SetLeft(visualisation, 0);
return pts;
}
示例2: Neuron
public Neuron(Point3D position, ModelVisual3D visual, DiffuseMaterial material)
{
_position = position;
this.Visual = visual;
this.Material = material;
this.Value = 0d;
}
示例3: Load
public static ModelVisual3D Load(string path)
{
if (path == null)
{
return null;
}
ModelVisual3D model= new ModelVisual3D();
string ext = Path.GetExtension(path).ToLower();
switch (ext)
{
case ".obj":
{
var r = new SmileObjReader();
model = r.Read(path);
break;
}
case ".objz":
{
var r = new SmileObjReader();
model = r.ReadZ(path);
break;
}
default:
throw new InvalidOperationException("File format not supported.");
}
return model;
}
示例4: simpleButtonClick
private void simpleButtonClick(object sender, RoutedEventArgs e)
{
MeshGeometry3D triagleMesh = new MeshGeometry3D();
Point3D p0 = new Point3D(0, 0, 0);
Point3D p1 = new Point3D(5, 0, 0);
Point3D p2 = new Point3D(0, 0, 5);
triagleMesh.Positions.Add(p0);
triagleMesh.Positions.Add(p1);
triagleMesh.Positions.Add(p2);
triagleMesh.TriangleIndices.Add(0);
triagleMesh.TriangleIndices.Add(2);
triagleMesh.TriangleIndices.Add(1);
Vector3D normal = new Vector3D(0, 1, 0);
triagleMesh.Normals.Add(normal);
triagleMesh.Normals.Add(normal);
triagleMesh.Normals.Add(normal);
Material material = new DiffuseMaterial(new SolidColorBrush(Colors.LawnGreen));
GeometryModel3D triangleModel = new GeometryModel3D(triagleMesh, material);
ModelVisual3D model = new ModelVisual3D();
model.Content = triangleModel;
this.mainViewport.Children.Add(model);
}
示例5: WindowLoaded
private void WindowLoaded(object sender, EventArgs e)
{
//Set camera viewpoint and properties.
myPCamera.FarPlaneDistance = 20;
myPCamera.NearPlaneDistance = 1;
myPCamera.FieldOfView = 45;
myPCamera.Position = new Point3D(-5, 2, 3);
myPCamera.LookDirection = new Vector3D(5, -2, -3);
myPCamera.UpDirection = new Vector3D(0, 1, 0);
//Add light sources to the scene.
myDirLight.Color = Colors.White;
myDirLight.Direction = new Vector3D(-3, -4, -5);
teapotModel.Geometry = (MeshGeometry3D)Application.Current.Resources["myTeapot"];
//Define material and apply to the mesh geometries.
DiffuseMaterial teapotMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Blue));
teapotModel.Material = teapotMaterial;
//Add 3D model and lights to the collection; add the collection to the visual.
modelGroup.Children.Add(teapotModel);
modelGroup.Children.Add(myDirLight);
ModelVisual3D modelsVisual = new ModelVisual3D();
modelsVisual.Content = modelGroup;
//Add the visual and camera to the Viewport3D.
myViewport.Camera = myPCamera;
myViewport.Children.Add(modelsVisual);
mainWindow.Content = myViewport;
}
示例6: TerrianCollisionMask3D
public TerrianCollisionMask3D(World world, ModelVisual3D visual)
{
if (visual == null) throw new ArgumentNullException("visual");
_visual = visual;
Initialise(world);
}
示例7: Visual3DBodyBase
public Visual3DBodyBase(World world, ModelVisual3D visual)
{
if (visual == null) throw new ArgumentNullException("visual");
_visual = visual;
Initialise(world);
}
示例8: Cell
public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager)
{
this.neuron = neuron;
this.mophology = mophology;
this.imager = imager;
neuron.Updated += OnUpdated;
neuron.Hillock.Spike += OnSpike;
IsPushing = true;
var transforms = new Transform3DGroup();
Rotate = new RotateTransform3D(new QuaternionRotation3D());
Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z);
Scale = new ScaleTransform3D();
transforms.Children.Add(Rotate);
transforms.Children.Add(Translate);
transforms.Children.Add(Scale);
Mophology.Transform = transforms;
var binding = new Binding()
{
Source = neuron,
Path = new PropertyPath("Position"),
Mode = BindingMode.OneWay
};
BindingOperations.SetBinding(this, Cell.PositionProperty, binding);
}
示例9: BlenderModel
/// <summary>
/// Loads a model from a (WPF-) ResourceDictionary
/// </summary>
/// <param name="resourceDictionary">A (WPF-) ResourceDictionary to load the model from</param>
/// <param name="index">the name/key/index of the model to load</param>
public BlenderModel(ResourceDictionary resourceDictionary, String index)
{
model3DGroup = resourceDictionary[index] as Model3DGroup;
modelVisual3D = new ModelVisual3D();
modelVisual3D.Content = model3DGroup;
this.index = index;
}
示例10: dibujaCubo
public ModelVisual3D dibujaCubo(Point3D[] puntos)
{
if (puntos.Length == 8)
{
Model3DGroup cube = new Model3DGroup();
cube.Children.Add(CreateTriangleModel(puntos[3], puntos[2], puntos[6]));
cube.Children.Add(CreateTriangleModel(puntos[3], puntos[6], puntos[7]));
cube.Children.Add(CreateTriangleModel(puntos[2], puntos[1], puntos[5]));
cube.Children.Add(CreateTriangleModel(puntos[2], puntos[5], puntos[6]));
cube.Children.Add(CreateTriangleModel(puntos[1], puntos[0], puntos[4]));
cube.Children.Add(CreateTriangleModel(puntos[1], puntos[4], puntos[5]));
cube.Children.Add(CreateTriangleModel(puntos[0], puntos[3], puntos[7]));
cube.Children.Add(CreateTriangleModel(puntos[0], puntos[7], puntos[4]));
cube.Children.Add(CreateTriangleModel(puntos[7], puntos[6], puntos[5]));
cube.Children.Add(CreateTriangleModel(puntos[7], puntos[5], puntos[4]));
cube.Children.Add(CreateTriangleModel(puntos[2], puntos[3], puntos[0]));
cube.Children.Add(CreateTriangleModel(puntos[2], puntos[0], puntos[1]));
ModelVisual3D modelo = new ModelVisual3D();
modelo.Content = cube;
return modelo;
}
return null;
}
示例11: CellNet
public CellNet(INetwork network, ModelVisual3D mophology, Dictionary<Guid, ICell> cells, Dictionary<Guid, ICellNet> childcellnet)
{
this.network = network;
this.mophology = mophology;
this.cells = cells;
this.childcellnet = childcellnet;
IsPushing = true;
var transforms = new Transform3DGroup();
Rotate = new RotateTransform3D(new QuaternionRotation3D());
Translate = new TranslateTransform3D(network.Position.X, network.Position.Y, network.Position.Z);
Scale = new ScaleTransform3D();
transforms.Children.Add(Rotate);
transforms.Children.Add(Translate);
transforms.Children.Add(Scale);
Mophology.Transform = transforms;
var binding = new Binding()
{
Source = network,
Path = new PropertyPath("Position"),
Mode = BindingMode.OneWay
};
BindingOperations.SetBinding(this, CellNet.PositionProperty, binding);
}
示例12: NodesVisual
public NodesVisual()
{
InitializeComponent();
// Make IMU model here
Model3DGroup items = new Model3DGroup();
GeometryModel3D model = new GeometryModel3D();
MeshGeometry3D geom = new MeshGeometry3D();
DiffuseMaterial paint = new DiffuseMaterial(new SolidColorBrush(Colors.Red));
double xPos, yPos, zPos;
for(int z = 0; z < 2; z++)
for (int y = 0; y < 2; y++)
for (int x = 0; x < 2; x++)
{
xPos = x * CUBE_SIZE - CUBE_SIZE / 2;
yPos = y * CUBE_SIZE - CUBE_SIZE / 2;
zPos = z * CUBE_SIZE - CUBE_SIZE / 2;
geom.Positions.Add(new Point3D(xPos, yPos, zPos));
Debug.Print("(" + x + "," + y + "," + z + ")");
}
// TriangleIndices = "2 3 1 2 1 0 7 1 3 7 5 1 6 5 7 6 4 5 6 2 0 6 0 4 2 7 3 2 6 7 0 1 5 0 5 4" >
geom.TriangleIndices.Add(2); geom.TriangleIndices.Add(3); geom.TriangleIndices.Add(1);
geom.TriangleIndices.Add(2); geom.TriangleIndices.Add(1); geom.TriangleIndices.Add(0);
geom.TriangleIndices.Add(7); geom.TriangleIndices.Add(1); geom.TriangleIndices.Add(3);
geom.TriangleIndices.Add(7); geom.TriangleIndices.Add(5); geom.TriangleIndices.Add(1);
geom.TriangleIndices.Add(6); geom.TriangleIndices.Add(5); geom.TriangleIndices.Add(7);
geom.TriangleIndices.Add(6); geom.TriangleIndices.Add(4); geom.TriangleIndices.Add(5);
geom.TriangleIndices.Add(6); geom.TriangleIndices.Add(2); geom.TriangleIndices.Add(0);
geom.TriangleIndices.Add(6); geom.TriangleIndices.Add(0); geom.TriangleIndices.Add(4);
geom.TriangleIndices.Add(2); geom.TriangleIndices.Add(7); geom.TriangleIndices.Add(3);
geom.TriangleIndices.Add(2); geom.TriangleIndices.Add(6); geom.TriangleIndices.Add(7);
geom.TriangleIndices.Add(0); geom.TriangleIndices.Add(1); geom.TriangleIndices.Add(5);
geom.TriangleIndices.Add(0); geom.TriangleIndices.Add(5); geom.TriangleIndices.Add(4);
model.Material = paint;
model.Geometry = geom;
items.Children.Add(model);
imu = new ModelVisual3D();
imu.Content = items;
viewportIMU.Children.Add(imu);
combobox_nodeSelect.Items.Clear();
Nodes.UpdateAvailableSensors();
foreach (string sensor in Nodes.COM_Ports)
combobox_nodeSelect.Items.Add(sensor);
if (!combobox_nodeSelect.Items.IsEmpty)
combobox_nodeSelect.SelectedIndex = 0;
}
示例13: VisualisationWindow
public VisualisationWindow(Interferometry.math_classes.ZArrayDescriptor array)
{
InitializeComponent();
// prepare points
Point3D[,] points = new Point3D[array.width, array.height];
for (int i = 0; i < array.width; ++i)
for (int j = 0; j < array.height; ++j)
points[i, j] = new Point3D(i, array.array[i][j], j);
// build model
Model3DGroup surface = new Model3DGroup();
for (int i = 0; i < array.width - 1; ++i)
{
for (int j = 0; j < array.height - 1; ++j)
{
surface.Children.Add(createTriangle(points[i, j], points[i + 1, j], points[i, j + 1]));
surface.Children.Add(createTriangle(points[i, j + 1], points[i + 1, j], points[i, j]));
surface.Children.Add(createTriangle(points[i, j + 1], points[i + 1, j], points[i + 1, j + 1]));
surface.Children.Add(createTriangle(points[i + 1, j + 1], points[i + 1, j], points[i, j + 1]));
}
System.Console.WriteLine("buidling on row: " + i + "/" + array.width);
}
System.Console.WriteLine("model building done");
ModelVisual3D model = new ModelVisual3D();
model.Content = surface;
this.mainViewport.Children.Add(model);
}
示例14: VisualTree3DView
public VisualTree3DView(Visual visual)
{
DirectionalLight directionalLight1 = new DirectionalLight(Colors.White, new Vector3D(0, 0, 1));
DirectionalLight directionalLight2 = new DirectionalLight(Colors.White, new Vector3D(0, 0, -1));
double z = 0;
Model3D model = this.ConvertVisualToModel3D(visual, ref z);
Model3DGroup group = new Model3DGroup();
group.Children.Add(directionalLight1);
group.Children.Add(directionalLight2);
group.Children.Add(model);
this.zScaleTransform = new ScaleTransform3D();
group.Transform = this.zScaleTransform;
ModelVisual3D modelVisual = new ModelVisual3D();
modelVisual.Content = group;
Rect3D bounds = model.Bounds;
double fieldOfView = 45;
Point3D lookAtPoint = new Point3D(bounds.X + bounds.SizeX / 2, bounds.Y + bounds.SizeY / 2, bounds.Z + bounds.SizeZ / 2);
double cameraDistance = 0.5 * bounds.SizeX / Math.Tan(0.5 * fieldOfView * Math.PI / 180);
Point3D position = lookAtPoint - new Vector3D(0, 0, cameraDistance);
Camera camera = new PerspectiveCamera(position, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), fieldOfView);
this.zScaleTransform.CenterZ = lookAtPoint.Z;
this.Children.Add(modelVisual);
this.Camera = camera;
this.ClipToBounds = false;
this.Width = 500;
this.Height = 500;
this.trackballBehavior = new TrackballBehavior(this, lookAtPoint);
}
示例15: ConvexBody3D
public ConvexBody3D(World world, ModelVisual3D model, CollisionShape collisionShape, double radius, double height)
: base(world, model)
{
// Validate
switch (collisionShape)
{
case CollisionShape.Capsule:
case CollisionShape.ChamferCylinder:
case CollisionShape.Cone:
case CollisionShape.Cylinder:
break;
default:
throw new ArgumentException("This constructor overload only supports collision shapes of cone, cylinder, capsule, chamfer cylinder");
}
// Store the definition of the collision shape
_collisionShape = collisionShape;
_collisionShapeRatio1 = radius;
_collisionShapeRatio2 = height;
_collisionShapeRatio3 = -1d;
// Calculate the collision mask
RecalculateCollisionMask();
}