question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manually animating an object, wpf/SharpDX

See original GitHub issue

I have an obj model that I load, like this:

public HelixToolkit.Wpf.SharpDX.MeshGeometry3D ModelCamera { private set; get; }

var m1 = Load3ds("data\\assets\\CameraMesh.obj");
this.ModelCamera = m1[0].Geometry as HelixToolkit.Wpf.SharpDX.MeshGeometry3D;

I link a transform in the xaml:

 <hx:MeshGeometryModel3D
                x:Name="model1"
                Geometry="{Binding ModelCamera}"
                Material="{Binding MaterialCamera}"
                Transform="{Binding CameraTransform}" />

In the constructer, i can move the object, like this:

var matrixZero = new Matrix3D();
            var transZ = new Vector3D(0, 10, 0);
            var quatZ = new System.Windows.Media.Media3D.Quaternion(0, 0, 0, 1);
            matrixZero.Rotate(quatZ);
            matrixZero.Translate(transZ);
            this.CameraTransform = new System.Windows.Media.Media3D.MatrixTransform3D(matrixZero);

However, when i run this function later on:

       public void SetTransform(double val)
        {

            var matrixZero = new Matrix3D();
            var transZ = new Vector3D(val, 0, 0);
            var quatZ = new System.Windows.Media.Media3D.Quaternion(0, 0.707, 0, 1);
            matrixZero.Rotate(quatZ);
            matrixZero.Translate(transZ);
            this.CameraTransform = new System.Windows.Media.Media3D.MatrixTransform3D(matrixZero);
          
        }

It doesn’t do anything. What am i missing here to move an object from code-behind?

Thanks!

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
holancecommented, Nov 30, 2022

Yes, InstanceParam is optional

1reaction
holancecommented, Nov 29, 2022

You are binding to CameraTransform property, but you are implementing notification on _CameraTransform.

    private System.Windows.Media.Media3D.MatrixTransform3D _CameraTransform;

    public System.Windows.Media.Media3D.MatrixTransform3D CameraTransform
    {
        get { return _CameraTransform; }
        set
        {
           if(_CameraTransform != value) {
              _CameraTransform= value;
              OnPropertyChanged(nameof(CameraTransform));
           }
        }
    }

Or you can simply inherit a base class for your view model like this: ObservableObject, then

    private System.Windows.Media.Media3D.MatrixTransform3D _CameraTransform;
    public System.Windows.Media.Media3D.MatrixTransform3D CameraTransform
    {
        get { return _CameraTransform; }
        set
        {
            SetValue(ref _CameraTransform, value);
        }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jerky animation when scrolling image in WPF using SharpDX
I am trying to smoothly scroll some images across a window using DirectX11 via SharpDX in a WPF application. A bit of background:....
Read more >
Animation Overview - WPF .NET Framework
This overview provides an introduction to the WPF animation and timing ... It focuses on the animation of WPF objects by using storyboards....
Read more >
helix-toolkit/CHANGELOG.md at develop
(WPF.SharpDX/UWP/WinUI); Improve node animation to avoid accumulated time ... Adds function to invalidate bone matrices/morph target weights manually (WPF.
Read more >
Announcements · Helix Toolkit
Fixed · OrthoCam width getting clipped on zooming #1164 (WPF.SharpDX/UWP/Core) · Fix panning speed too huge causes object flying too far. Ref #1161...
Read more >
helix-toolkit
HelixToolkit.SharpDX.WPF: Custom 3D Engine and XAML/MVVM compatible Scene Graphs based on SharpDX(DirectX 11) for high performance usage. HelixToolkit.UWP ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found