Pre loader

Tag: SceneObject

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0 votes
3k views

I created an ObjectModel3D object in ViewModel and bound it to View, but the Scale and Position values are not applicable.
What’s wrong with my code?

View:

<UserControl x:Class="Example.TestChart.Views.TestChartView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:Example.TestChart.Views"
         xmlns:locals="clr-namespace:Example.TestChart.ViewModels"
         xmlns:s3D="http://schemas.abtsoftware.co.uk/scichart3D"
         mc:Ignorable="d" 
         xmlns:prism="http://prismlibrary.com/"
         prism:ViewModelLocator.AutoWireViewModel="True"
         xmlns:object="clr-namespace:SciChart.Charting3D.Visuals.Object;assembly=SciChart.Charting3D"
         d:DesignHeight="300"
         d:DesignWidth="300">


<Grid>
    <s3D:SciChart3DSurface x:Name="SciChart"
                   Grid.Column="1"
                   BorderThickness="0"
                   WorldDimensions="1000,500,500"
                   RenderableSeries="{s3D:SeriesBinding RenderableSeriesCollenction}"
                   SceneObjects="{Binding SceneEntity3Ds}"
                   Grid.Row="1"
                   >

        <s3D:SciChart3DSurface.Camera>
            <s3D:Camera3D 
                          Position="30,400,-1250"
                          Target="40,200,500"
                          />
        </s3D:SciChart3DSurface.Camera>

        <s3D:SciChart3DSurface.XAxis>
            <s3D:NumericAxis3D  AxisTitle ="X" 
                        TextFormatting ="n2" 
                        AutoRange = "Never" 
                        VisibleRange ="0,100" 
                        GrowBy =" 10, 10" 
                        FlipCoordinates="True"
                        TickLabelAlignment ="Camera" 
                        />

        </s3D:SciChart3DSurface.XAxis>
        <s3D:SciChart3DSurface.YAxis>
            <s3D:NumericAxis3D  AxisTitle ="Y" 
                        TextFormatting ="n2" 
                        AutoRange = "Never" 
                        VisibleRange ="0,100" 
                        GrowBy =" 10, 10" 
                        TickLabelAlignment ="Camera" />
        </s3D:SciChart3DSurface.YAxis>
        <s3D:SciChart3DSurface.ZAxis>
            <s3D:NumericAxis3D  AxisTitle ="Z" 
                        TextFormatting ="n2" 
                        AutoRange = "Never" 
                        VisibleRange ="0,100"
                        GrowBy ="10,10" 
                        TickLabelAlignment ="Camera" />

        </s3D:SciChart3DSurface.ZAxis>

        <s3D:SciChart3DSurface.ChartModifier>
            <s3D:ModifierGroup3D>
                <s3D:OrbitModifier3D ExecuteOn="MouseLeftButton"/>
                <s3D:MouseWheelZoomModifier3D />
                <s3D:ZoomExtentsModifier3D AnimateDurationMs="500" ResetPosition="-10,400,-850" ResetTarget="0,200,500"/>
            </s3D:ModifierGroup3D>
        </s3D:SciChart3DSurface.ChartModifier>

    </s3D:SciChart3DSurface>
</Grid>

ViewModel:

    namespace Example.TestChart.ViewModels
{
    using SciChart.Charting3D.Visuals.RenderableSeries;
    using System;
    using System.Collections.ObjectModel;
    using System.Windows.Media;
    using Example.BaseClass;
    using SciChart.Charting3D.Visuals.Object;
    using System.Reflection;
    using System.IO;
    using SciChart.Charting3D;


public class TestChartViewModel : ViewModelBase
{
    public TestChartViewModel() 
    {

        RenderableSeriesCollenction = new ObservableCollection<IRenderableSeries3DViewModel>();
        SceneEntity3Ds = new ObservableCollection<ObjectModel3D>();
        addr();
    }

    public void addr()
    {
        string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Objects\\Pawn_Low.obj");
        var obj = new ObjectModel3D(new Uri(filePath), Color.FromRgb(Convert.ToByte(255), Convert.ToByte(255), Convert.ToByte(0)))
        {
            Position = new Vector3(0.5f, 1f, 0.8f),
            CoordinateMode = ObjectCoordinateMode.Relative
        };
        obj.Scale = new Vector3(0.2f, 0.2f, 0.2f);
        SceneEntity3Ds.Add(obj);

    }

    private ObservableCollection<IRenderableSeries3DViewModel> _renderableSeriesCollenction;
    public ObservableCollection<IRenderableSeries3DViewModel> RenderableSeriesCollenction
    {
        get { return _renderableSeriesCollenction; }
        set { _renderableSeriesCollenction = value; }
    }

    private ObservableCollection<ObjectModel3D> _sceneEntity3Ds;
    public ObservableCollection<ObjectModel3D> SceneEntity3Ds
    {
        get { return _sceneEntity3Ds; }
        set { _sceneEntity3Ds = value; }
    }

}

}

Showing 1 result