Pre loader

Tag: codebehind

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
2k views

I had great success using ObjectModel3D objects in my XAML file. However, I would like to dynamically add and remove objects based on user input. For this reason, I’ve switched to using codebehind.

private void PopulateScene()
      {
          List<Uri> bitmapImages = DataProcessor.bitmapImages();
          Uri textureSource = new Uri(@"C:\Users\Will\Desktop\lemon_yellow__85006.webp");
  
          var rotation = new Rotation3D()
          {
              Angle = 45,
              Axis = SciChart.Charting3D.Axis.Axis3D.YAxis
          };
  
          foreach(Uri bitmapImage in bitmapImages)
          {
              ObjectModel3D objectModel = new ObjectModel3D()
              {
                  TextureSource = new TextureSource(textureSource),
                  Source = new ObjectModelSource(new Uri(@"C:\Users\Will\Desktop\EarthTile.obj")),
                  Position = new Vector3(1, 0, 1),
                  CoordinateMode = ObjectCoordinateMode.Relative,
                  Scale = new Vector3(2, 1, 1),
                  Rotation = rotation
              };
  
              using (sciChart.SuspendUpdates())
              {
                  sciChart.SceneObjects.Add(objectModel);
              }
          }
      }
  

I get the correct model with the correct texture. However, setting the position, scale or rotation doesn’t seem to work. All objects are in the same place ((0, 0, 0), no matter the coordinate mode), at the same (1, ,1 ,1) scale, and facing the same direction. How

I also have this function;

private void ClearScene()
{
using (sciChart.SuspendUpdates())
{
sciChart.SceneObjects.Clear();
}
}

Even after the object is cleared from SceneObjects, it persists in the chart.

This leads me to my 2 questions;

  1. How do I get the objects I add to the chart to observe the
    transformational parameters I give it? I don’t need to change the
    parameters of objects after they’ve been added to the scene, just
    before.
  2. How do I remove objects from a scene?
Showing 1 result

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies