Reputation: 49
I need to draw a 3d pipe like image using wpf application and embed the same into a custom control in wpf ..i tried using the.xaml file and drawn a pipe like thing but am not able to get a full sized correct image ..could some one help me how to do it ..with graphics..
Upvotes: 0
Views: 5550
Reputation: 3840
xaml:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ht:HelixViewport3D x:Name="MainViewPort">
<ht:SunLight />
<ht:GridLinesVisual3D/>
</ht:HelixViewport3D>
</Grid>
</Window>
code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HelixToolkit.Wpf;
using System.Windows.Media.Media3D;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
DrawMeshes();
}
private void DrawMeshes()
{
int tubeDiameter = 15;
TubeVisual3D tube1 = new TubeVisual3D();
tube1.Path = new Point3DCollection();
tube1.Path.Add(new Point3D(-15, 0, 0));
tube1.Path.Add(new Point3D(15, 0, 0));
tube1.Diameter = tubeDiameter;
tube1.Fill = Brushes.Red;
tube1.IsPathClosed = false;
MainViewPort.Children.Add(tube1);
}
}
}
Upvotes: 4
Reputation: 2941
Have a look at the Helix Toolkit. it has some good controls for wpf 3D, including a pipe example.
Upvotes: 0