本文整理汇总了C#中System.Windows.Controls.Viewport3D类的典型用法代码示例。如果您正苦于以下问题:C# Viewport3D类的具体用法?C# Viewport3D怎么用?C# Viewport3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Viewport3D类属于System.Windows.Controls命名空间,在下文中一共展示了Viewport3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create3DViewPort
private void Create3DViewPort()
{
var hvp3d = new HelixViewport3D();
Viewport3D vp3d = new Viewport3D();
var lights = new DefaultLights();
var tp = new Teapot();
hvp3d.Children.Add(lights);
hvp3d.Children.Add(tp);
vp3d = hvp3d.Viewport;
tata.Children.Add(vp3d); // comenter ca pour test
/* MEGA TEST DE L'ESPACE SUBSAHARIEN */
RenderTargetBitmap bmp = new RenderTargetBitmap(800, 800, 96, 96, PixelFormats.Pbgra32);
var rect = new Rect(0, 0, 800, 800);
vp3d.Measure(new Size(800, 800));
vp3d.Arrange(rect);
vp3d.InvalidateVisual();
bmp.Render(vp3d);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(bmp));
String filepath = "C:\\Users\\Remi\\Desktop\\canardmasque.png";
using (Stream stm = File.Create(filepath))
{
png.Save(stm);
}
}
示例2: AddVehiclePoints
private ScreenSpaceLines3D AddVehiclePoints(Viewport3D mainViewport, Point3D[] pointsArray)
{
ScreenSpaceLines3D wireVehicle=new ScreenSpaceLines3D();
Color color = Colors.Red;
const int width = 1;
wireVehicle.Thickness = width;
wireVehicle.Color = color;
wireVehicle.Points.Add(pointsArray[0]);
wireVehicle.Points.Add(pointsArray[1]);
wireVehicle.Points.Add(pointsArray[1]);
wireVehicle.Points.Add(pointsArray[2]);
wireVehicle.Points.Add(pointsArray[2]);
wireVehicle.Points.Add(pointsArray[3]);
wireVehicle.Points.Add(pointsArray[3]);
wireVehicle.Points.Add(pointsArray[0]);
wireVehicle.Points.Add(pointsArray[4]);
wireVehicle.Points.Add(pointsArray[5]);
wireVehicle.Points.Add(pointsArray[5]);
wireVehicle.Points.Add(pointsArray[6]);
wireVehicle.Points.Add(pointsArray[6]);
wireVehicle.Points.Add(pointsArray[7]);
wireVehicle.Points.Add(pointsArray[7]);
wireVehicle.Points.Add(pointsArray[4]);
wireVehicle.Points.Add(pointsArray[0]);
wireVehicle.Points.Add(pointsArray[4]);
wireVehicle.Points.Add(pointsArray[1]);
wireVehicle.Points.Add(pointsArray[5]);
wireVehicle.Points.Add(pointsArray[2]);
wireVehicle.Points.Add(pointsArray[6]);
wireVehicle.Points.Add(pointsArray[3]);
wireVehicle.Points.Add(pointsArray[7]);
return wireVehicle;
}
示例3: 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;
}
示例4: JuegoPiano
public JuegoPiano(Viewport3D viewport3D)
{
Jugadores = new Dictionary<int,Jugador>();
//Se inicializa el teclado con el número de octavas
Teclado = new Teclado(2);
Teclado.Draw3D(viewport3D);
this.Viewport3D = viewport3D;
//init WS
pianoWSDuplexClient = new PianoWSDuplexClient();
pianoWSDuplexClient.SetEjecutarNotaAction(delegate(string nota) {
Tecla tecla = Teclado.Teclas[nota];
tecla.UpdatePosition(new Point3D(0, - tecla.Dimensiones.Alto, 0));
tecla.Sonar();
//Timer para regresar la tecla a su lugar original
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler((Action<object, EventArgs>)delegate(object sender, EventArgs e)
{
tecla.UpdatePosition(new Point3D(0, 0, 0));
(sender as DispatcherTimer).Stop();
});
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
dispatcherTimer.Start();
});
}
示例5: PointVisualizer
// These are used by the 2 constructor overloads that don't take int
//private ModelVisual3D _dotModel = null;
//private ModelVisual3D _velocityModel = null;
//private ModelVisual3D _accelerationModel = null;
#endregion
#region Constructor
public PointVisualizer(Viewport3D viewport, SharedVisuals sharedVisuals)
{
_viewport = viewport;
_sharedVisuals = sharedVisuals;
_items = new ItemProperties[3];
// Position
_items[INDEX_POSITION] = new ItemProperties();
_items[INDEX_POSITION].IsPoint = true;
_items[INDEX_POSITION].Color = Colors.Magenta;
_items[INDEX_POSITION].SizeMultiplier = 1d;
// Velocity
_items[INDEX_VELOCITY] = new ItemProperties();
_items[INDEX_VELOCITY].IsPoint = false;
_items[INDEX_VELOCITY].Color = Colors.Chartreuse;
_items[INDEX_VELOCITY].SizeMultiplier = 1d;
// Acceleration
_items[INDEX_ACCELERATION] = new ItemProperties();
_items[INDEX_ACCELERATION].IsPoint = false;
_items[INDEX_ACCELERATION].Color = Colors.Gold;
_items[INDEX_ACCELERATION].SizeMultiplier = 1d;
}
示例6: Export_SimpleModel_ValidOutput
public void Export_SimpleModel_ValidOutput()
{
string path = "temp.x3d";
var runner = new CrossThreadTestRunner();
runner.RunInSTA(
delegate
{
Console.WriteLine(Thread.CurrentThread.GetApartmentState());
var vp = new Viewport3D();
vp.Camera = CameraHelper.CreateDefaultCamera();
vp.Width = 1280;
vp.Height = 720;
vp.Children.Add(new DefaultLightsVisual3D());
var box = new BoxVisual3D();
box.UpdateModel();
vp.Children.Add(box);
using (var e = new X3DExporter(path))
{
e.Export(vp);
}
});
var result = Validate(path);
Assert.IsNull(result, result);
}
示例7: Point3DtoPoint2D
/// <summary>
/// Code adapted from HelixToolkit.Wpf.Viewport3DHelper.Point3DtoPoint2D obtained from http://github.com/helix-toolkit/helix-toolkit
/// License: helix-toolkit.LICENSE.txt
/// </summary>
/// <param name="viewport"></param>
/// <param name="point"></param>
/// <returns></returns>
public static Point Point3DtoPoint2D(Viewport3D viewport, Point3D point)
{
var matrix = GetTotalTransform(viewport);
var pointTransformed = matrix.Transform(point);
var pt = new Point(pointTransformed.X, pointTransformed.Y);
return pt;
}
示例8: FlipTransition
public FlipTransition()
{
_viewport = TransitionResources["3DCube"] as Viewport3D;
_rootModel = (_viewport.Children[0] as ModelVisual3D).Content as Model3DGroup;
_cubeModelContainer = _rootModel.Children[1] as Model3DGroup;
}
示例9: StereoControl
public StereoControl()
{
viewport = new Viewport3D();
Camera = CameraHelper.CreateDefaultCamera();
Camera.Changed += Camera_Changed;
Children = new ObservableCollection<Visual3D>();
}
示例10: Export
/// <summary>
/// Exports the specified viewport.
/// </summary>
/// <param name="viewport">
/// The viewport.
/// </param>
public void Export(Viewport3D viewport)
{
int m = this.OversamplingMultiplier;
var background = this.Background;
if (background == null)
{
background = Brushes.Transparent;
}
var bmp = Viewport3DHelper.RenderBitmap(viewport, background, m);
BitmapEncoder encoder;
string ext = Path.GetExtension(this.FileName);
switch (ext.ToLower())
{
case ".jpg":
var jpg = new JpegBitmapEncoder();
jpg.Frames.Add(BitmapFrame.Create(bmp));
encoder = jpg;
break;
case ".png":
var png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(bmp));
encoder = png;
break;
default:
throw new InvalidOperationException("Not supported file format.");
}
using (Stream stm = File.Create(this.FileName))
{
encoder.Save(stm);
}
}
示例11: drawTor
public static void drawTor(Point3D center, double R, double r, int N, int n, Color color, Viewport3D mainViewport)
{
if (n < 2 || N < 2)
{
return;
}
Model3DGroup tor = new Model3DGroup();
Point3D[,] points = new Point3D[N, n];
for (int i = 0; i < N; i++)
{
for (int j = 0; j < n; j++)
{
points[i, j] = getPositionTor(R, r, i * 360 / (N - 1), j * 360 / (n - 1));
points[i, j] += (Vector3D)center;
}
}
Point3D[] p = new Point3D[4];
for (int i = 0; i < N - 1; i++)
{
for (int j = 0; j < n - 1; j++)
{
p[0] = points[i, j];
p[1] = points[i + 1, j];
p[2] = points[i + 1, j + 1];
p[3] = points[i, j + 1];
drawTriangle(p[0], p[1], p[2], color, mainViewport);
drawTriangle(p[2], p[3], p[0], color, mainViewport);
}
}
}
示例12: ExplosionWithVisual
public ExplosionWithVisual(Point3D centerPoint, double waveSpeed, double forceAtCenter, double maxRadius, Viewport3D viewport, double visualStartRadius)
: base(centerPoint, waveSpeed, forceAtCenter, maxRadius)
{
_viewport = viewport;
_visualStartRadius = visualStartRadius;
CreateVisual();
}
示例13: ItemSelectDragLogic
public ItemSelectDragLogic(Map map, PerspectiveCamera camera, Viewport3D viewport, UIElement visual)
{
_map = map;
_camera = camera;
_viewport = viewport;
_visual = visual;
}
示例14: Draw
public void Draw(Viewport3D mainViewport)
{
foreach (PianoKey pk in _PianoKeys)
{
pk.Draw(mainViewport);
}
}
示例15: ExportSimpleModel
/// <summary>
/// Exports a simple model in a STA.
/// </summary>
/// <param name="e">The exporter.</param>
/// <param name="stream">The stream.</param>
protected void ExportSimpleModel(IExporter e, Stream stream)
{
Exception exception = null;
CrossThreadTestRunner.RunInSTA(
() =>
{
var vp = new Viewport3D { Camera = CameraHelper.CreateDefaultCamera(), Width = 1280, Height = 720 };
vp.Children.Add(new DefaultLights());
var box = new BoxVisual3D();
box.UpdateModel();
vp.Children.Add(box);
try
{
e.Export(vp, stream);
}
catch (Exception ex)
{
exception = ex;
}
});
if (exception != null)
{
throw exception;
}
}