GithubHelp home page GithubHelp logo

Comments (12)

holance avatar holance commented on June 19, 2024 1

https://github.com/helix-toolkit/helix-toolkit/tree/develop/Source/Examples/WPF.SharpDX/FileLoadDemo. If you don't use wpf binding, you can just do Viewport3DX.Items.Add(groupModel).

from helix-toolkit.

holance avatar holance commented on June 19, 2024

Not sure what you mean by blocking the entire window.

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

Hi , sorry if my question is not clear.
I use a panel form in Rhino3d software.
This is the code i used but the viewport always black and if i click on it the entire window of Rhino freeze.

............
private System.Windows.Controls.Viewbox viewbox;
private HelixToolkit.Wpf.SharpDX.Viewport3DX viewport3d;

this.elementHost2 = new System.Windows.Forms.Integration.ElementHost();
this.viewbox = new System.Windows.Controls.Viewbox();
.....
this.elementHost2.Child = this.viewbox;
..............
 public RHViewerUserControl()
 {
     InitializeComponent();
     this.Load += MainForm_Load;

     AmbientLight3D ambientLight = new AmbientLight3D();
     viewport3d = new Viewport3DX();
     viewport3d.Name = "view";
     viewport3d.Width = 400;
     viewport3d.Height = 400;
     viewport3d.ZoomExtentsWhenLoaded = true;
     viewport3d.BackgroundColor = System.Windows.Media.Color.FromRgb(200, 200, 200);
     viewport3d.ShowViewCube = true;
     viewport3d.Orthographic = false;
     /*/
     viewport3d.Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera
     {
         Position = new Point3D(0.0, 0.0, 5.0),
         LookDirection = new System.Windows.Media.Media3D.Vector3D(0.0, 0.0, -5.0),
         UpDirection = new System.Windows.Media.Media3D.Vector3D(0.0, 1.0, 0.0),
         NearPlaneDistance = 0.5,
         FarPlaneDistance = 150.0
     };
     /*/
     viewport3d.Visibility = Visibility.Visible;
     viewbox.Child = viewport3d;
     ......
     }
private string OpenFileFilter = $"{HelixToolkit.Wpf.SharpDX.Assimp.Importer.SupportedFormatsString}";
SceneNodeGroupModel3D groupModel = new SceneNodeGroupModel3D();
private void button4_Click(object sender, EventArgs e)
{
    string filePath = OpenFileDialog(OpenFileFilter);
    var loader = new HelixToolkit.Wpf.SharpDX.Assimp.Importer();
    var scene = loader.Load(filePath);
    groupModel.Clear();
    /*/
    foreach (var node in scene.Root.Traverse().ToList())
    {
        node.RemoveSelf(); // remove from scene to be able to add to group
        groupModel.AddNode(node);
    }
    /*/
    scene.Root.Attach(viewport3d.EffectsManager); // Pre attach scene graph
    scene.Root.UpdateAllTransformMatrix();

    groupModel.AddNode(scene.Root);
}

private string OpenFileDialog(string filter)
{
    var d = new Microsoft.Win32.OpenFileDialog();
    d.CustomPlaces.Clear();

    d.Filter = filter;

    if (!d.ShowDialog().Value)
    {
        return null;
    }

    return d.FileName;
}

image

from helix-toolkit.

holance avatar holance commented on June 19, 2024

Are you able to upload a sample project? I am not familiar with the rhino3D.

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

It's just windows form with c# code, i want know how it work in c# and windows form.
The example available use wpf and i try to implant the code in my form without success, or if there is an example using windows form this will be very helpful

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

HelixViewport3D works fine , but i prefer SharpDX.Viewport3DX to load more object with assimp

Recording.2024-05-11.171017.mp4

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

I add this to solve the problem of black background
assimpviewport3d.EffectsManager = new DefaultEffectsManager();
image
But i still to find a way how to import objects with assimp

private string OpenFileFilter = $"{HelixToolkit.Wpf.SharpDX.Assimp.Importer.SupportedFormatsString}";
SceneNodeGroupModel3D groupModel = new SceneNodeGroupModel3D();

private string OpenFileDialog(string filter)
{
    var d = new Microsoft.Win32.OpenFileDialog();
    d.CustomPlaces.Clear();

    d.Filter = filter;

    if (!d.ShowDialog().Value)
    {
        return null;
    }

    return d.FileName;
}

private void assimpLoadButton_Click(object sender, EventArgs e)
{
    string filePath = OpenFileDialog(OpenFileFilter);
    var loader = new HelixToolkit.Wpf.SharpDX.Assimp.Importer();
    var scene = loader.Load(filePath);
    groupModel.Clear();

    foreach (var node in scene.Root.Traverse().ToList())
    {
        node.RemoveSelf(); // remove from scene to be able to add to group
        groupModel.AddNode(node);
    }

    scene.Root.Attach(assimpviewport3d.EffectsManager); // Pre attach scene graph
    scene.Root.UpdateAllTransformMatrix();

    groupModel.AddNode(scene.Root);
}

from helix-toolkit.

holance avatar holance commented on June 19, 2024

Did you bind your groupModel in the viewport?

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

That's the problem
i don't know how to add the model to the viewport, i search a lot and don't find any example in c#

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

Thank you Finally it work
Is fbx animation loaded automatically or it need complex steps?

from helix-toolkit.

holance avatar holance commented on June 19, 2024

It loads automatically.

from helix-toolkit.

seghier avatar seghier commented on June 19, 2024

Nice
Thank you i will try how to make it work

from helix-toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.