This is the discussion forum for Helix Toolkit.
For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
+1

Help required in opennig a 3D model (.ply) using FileModelVisual3D in WPF

Anonymous 12 years ago 0
This discussion was imported from CodePlex

pyrrhicpk wrote at 2012-09-24 03:38:

Hi,

I have just started using HelixToolkit and trying to load a 3D model (.ply) in my WPF application using FileModelVisual3D with the following code:

 

FileModelVisual3D scan = new FileModelVisual3D();
scan.Source = "C:\\box.3ds";
       
myview.Children.Add(scan); //myview is my HelixViewport3D
this.Content = myview;

Running the above code does not show the model. Any suggestions?

Thanks

+1

MVVM with background work

Anonymous 12 years ago 0
This discussion was imported from CodePlex

g_todeschini wrote at 2013-08-13 17:41:

I'm trying to create a WPF application using the MVVM pattern.
In my view (UserControl class derived) I've placed the HelixViewport3D control and I've assigned an instance of my ViewModel to the DataContext property

<h:HelixViewport3D RotateGesture="Alt+RightClick" PanGesture="RightClick">
<h:HelixViewport3D.Camera>
<OrthographicCamera Position="80.22,0,0" LookDirection="-80.22,0,0" UpDirection="0,0,1" Width="56"/>
</h:HelixViewport3D.Camera>
<h:SunLight />
<ModelVisual3D Content="{Binding Model3D}" />
</h:HelixViewport3D>

The ModelVisual3D content property is binded with the Model3D propery of my ViewModel.

All works fine but I would like to create the model in a function that works in background. I've tried to do this using both the BackgroundWorker class that the Task.Factory.StartNew but I've always get the message that the object is property of another thread.

One of my attempt is the following

public class MyViewModel : BaseViewModel
{
private MyData _model; // the data on which to generate my 3d model
private Model3DGroup _model3d;
private CancellationTokenSource _source;

public Model3DGroup Model3D
{
    get { return _model3d; }
    set
    {
        if (_model3d != value)
        {
            _model3d = value;
             RaisePropertyChanged(() => Model3D);
        }
    }
}

private void CreateModel3D(object dispatcherObject)
{
    Dispatcher dispatcher = (Dispatcher)dispatcherObject;

    Material nodesMaterial = MaterialHelper.CreateMaterial(Colors.Green);
    double size = Math.Max(_model.Limits.Width, _model.Limits.Height);
    double dn = size / 100;
    double db = size / 120;
    int thetaDiv = 10;

    foreach (Strauss.Node node in _model.Nodes)
    {
         MeshBuilder meshBuilder = new MeshBuilder(false, false);
         meshBuilder.AddSphere(new Point3D(node.X, node.Y, node.Z), dn, thetaDiv, thetaDiv / 2);
         MeshGeometry3D mesh = meshBuilder.ToMesh(true);
         dispatcher.Invoke((Action)(() => _model3d.Children.Add(new GeometryModel3D { Geometry = mesh, Material = nodesMaterial, BackMaterial = nodesMaterial })));
    }
}

private void ModelLoaded(object sender, EventArgs args)
{
    System.Windows.Window win = App.Current.Windows[0];
    DocManagerViewModel docManager = win.DataContext as DocManagerViewModel;
    _source = new CancellationTokenSource();
    Task task = Task.Factory.StartNew(CreateModel3D, _model3d.Dispatcher, _source.Token);
}
}

The process starts from the ModelLoaded event handler.

Can anyone please help me?
Thanks in advance.

RobPerkins wrote at 2013-08-14 18:02:

1 -- Use Task.Factory.StartNew(). BackgroundWorker is prone to a race condition.
2 -- All WPF objects, including GeometryModel3D and MeshGeometry3D, have to be "Frozen" to be passed between threads. See "Freezable" in the MSDN documentation.

Change the code in CreateModel3D from what you have to something like:
var gm3d = new GeometryModel3D { Geometry = mesh, Material = nodesMaterial, BackMaterial = nodesMaterial };
dispatcher.Invoke((Action)(() => _model3d.Children.Add(gm3d.GetAsFrozen())));
+1

HelixViewport3d::SphereVisual3D - How to add children via XAML (and a back end binding)?

Anonymous 12 years ago updated by anonymous 6 years ago 0
This discussion was imported from CodePlex

BogusException wrote at 2014-07-18 19:15:

Experts,

I have the back end down. Right now, the XAML is the pain.

Given the following working XAML, how should I implement the backend collection of "Conns" (Connections, or Flights) in the Current Flight Demo code (which this came from)?

Below in the abbreviated XAML, this section toward the bottom is the one in question:
   <ItemsControl ItemsSource="{Binding Conns}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                    <Viewport3D /> <--- ??? or...?
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>
I'm 100% on the backend. I just can't figure out how to make the XAML under Helix3D ready to bind to/show the collection...

Any help at all REALLY appreciated!!!

pat
:)
<Window x:Class="TheEarthWindow"
    x:Name="TheGlobe"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:t="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf" 
    Title="TheEarthWindow" Height="800" Width="800">
    <Grid>
        <Grid.Resources>
        [...]
        </Grid.Resources>
        <Grid.Triggers>
        [...]
        </Grid.Triggers>
        <t:HelixViewport3D x:Name="view1" 
                           Background="Black" 
                           CameraRotationMode="Turnball"
                           ClipToBounds="False"
                           Grid.Column="0" 
                           IsHeadLightEnabled="True" 
                           IsHitTestVisible="True"
                           IsPanEnabled="False"
                           IsZoomEnabled="True"
                           MouseDown="OnMouseDown" 
                           MouseMove="OnMouseMove" 
                           ShowCameraInfo="False"
                           ShowCameraTarget="False"
                           ShowCoordinateSystem="False"
                           ShowFieldOfView="False"
                           ShowFrameRate="True"
                           ShowTriangleCountInfo="False"
                           ShowViewCube="True"
                           SubTitle="vASA Global Monitor"
                           SubTitleSize="40"
                           Title="vASA"
                           ZoomExtentsWhenLoaded="True" >
            <t:HelixViewport3D.Camera>
                <PerspectiveCamera Position="600,27400,0" 
                                   LookDirection="0,1,0" 
                                   UpDirection="0,0,1" 
                                   NearPlaneDistance="0.01" 
                                   FarPlaneDistance="Infinity" 
                                   FieldOfView="40">
                    <PerspectiveCamera.Transform>
                    <Transform3DGroup>
                        <RotateTransform3D>
                            <RotateTransform3D.Rotation>
                                <AxisAngleRotation3D Axis="0,0,1" Angle="0" x:Name="camRotation" />
                            </RotateTransform3D.Rotation>
                        </RotateTransform3D>
                    </Transform3DGroup>
                    </PerspectiveCamera.Transform>
                </PerspectiveCamera>
            </t:HelixViewport3D.Camera>
            <t:SunLight />
            <t:SphereVisual3D x:Name="TheEarthSphere" 
                              Material="{StaticResource EarthJPG}"
                              Radius="1" 
                              ThetaDiv="25" 
                              PhiDiv="25" >
<!-- WHAT GOES HERE FOR TUBES? -->
        <ItemsControl ItemsSource="{Binding Conns}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                        <Viewport3D /> <--- ??? or...?
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
<!-- IS THE ABOVE EVEN IN THE RIGHT PART OF THE TREE? -->
            </t:SphereVisual3D>
        </t:HelixViewport3D>
    </Grid>
</Window>
+1

Event that fires when the camera stops moving

Anonymous 12 years ago 0
This discussion was imported from CodePlex

everytimer wrote at 2014-07-31 21:24:

I need to perform an operation right after the user has stopped moving the camera (everytime he does it).

I'm doing it now by subscribing to every MouseEvent that allows interaction with the camera (specifically ButtonUp). The problem is that when the user has zoomed I don't have a way to know when he has stopped zooming. Other issue of capturing mouse events is that when the camera change has been generated programatically (set some saved view, etc) and there is some animation I can't do it either.

I would like to know if there is some event that I can subscribe to know when the Camera is "done", when it has stopped moving.

If such event doesn't exist I would like to know if it is possible to create one without modifying the source code of HelixToolKit and how it could be done.

Thank you very much.
0

Tekkentag

wafi Ahmad 3 weeks ago 0

The Tekken Tag game is a popular fighting Bets game that introduces a new style of gameplay. Instead of using one fighter, you control two characters and switch between them. This makes the game more exciting and gives more chances to win.Many players enjoy the Tekken Tag Tournament because it mixes action with smart thinking. Whether you are new or already a fan, this guide will help you better understand the game.

0

Lunabet Game Download Real Earning App In Pakistan

wafi Ahmad 1 month ago updated by purecokesupply 1 month ago 1

The Lunabet game Download is a simple mobile platform where players enjoy fun games in a quick and easy way. Many users choose the Lunabet game because it works smoothly on phones and does not require complex steps. The design of the Lunabet game is clean, so even new players feel comfortable from the start.Today, people want games that are fast and easy to use. The Lunabet game meets this need by giving quick access and simple controls. This guide will help you understand the Lunabet game, its features, and how to use it in a safe and smart way.

0

Tekken Tag Game Tournament APK Download for Android

wafi Ahmad 1 month ago updated 1 month ago 0

The Tekken Tag game is a popular fighting Bets game that introduces a new style of gameplay. Instead of using one fighter, you control two characters and switch between them. This makes the game more exciting and gives more chances to win. Many players enjoy the Tekken Tag Tournament because it mixes action with smart thinking. Whether you are new or already a fan, this guide will help you better understand the game.

0

kuwinzhzcom

kuwinzhzcom 8 months ago updated by purecokesupply 4 months ago 8

Kuwin mang đến không gian giải trí trực tuyến hiện đại, nơi người chơi có thể trải nghiệm cá cược thể thao, casino, game bài và slot đa dạng trong môi trường an toàn, minh bạch. Giao diện tối ưu, tốc độ truy cập nhanh cùng dịch vụ chăm sóc khách hàng tận tâm giúp Kuwin trở thành lựa chọn hàng đầu của cộng đồng yêu thích cá cược trực tuyến.

Website: https://kuwinzhz.com/

0

RR88

rr88institute1 11 months ago updated by purecokesupply 4 months ago 2

RR88 là nền tảng cá cược trực tuyến uy tín, hoạt động hợp pháp với đầy đủ giấy phép và cam kết mang đến cho người chơi tại Việt Nam môi trường giải trí an toàn, minh bạch. Tại RR88, người dùng có thể trải nghiệm hệ sinh thái game phong phú gồm casino, cá cược thể thao, xổ số, bắn cá… tất cả được tích hợp trong một giao diện hiện đại, dễ sử dụng. Điểm nổi bật của RR88 là tốc độ giao dịch nạp – rút siêu nhanh, loạt chương trình khuyến mãi hấp dẫn mỗi ngày cùng đội ngũ chăm sóc khách hàng chuyên nghiệp, luôn sẵn sàng hỗ trợ 24/7.

Website: https://rr88.institute/

0

Kuwin

kuwin68town 12 months ago 0

Kuwin là thương hiệu cá cược trực tuyến hàng đầu, nổi bật với độ uy tín, minh bạch và dịch vụ chuẩn quốc tế. Với giao diện hiện đại, thân thiện và tốc độ truy cập mượt mà, Kuwin mang đến cho người chơi những trải nghiệm giải trí đỉnh cao, từ cá cược thể thao, casino trực tuyến, game bài đổi thưởng cho đến bắn cá, nổ hũ…

Website: https://kuwin68.town/