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.

Load and unload Model3DGroup dynamically?

See original GitHub issue

I have a changing list, from which I am reading data. (position values, and an ID for each entry). What i am trying to do, is load and unload Models into a helix Viewport as the list updates. I have approached this by loading 50 (the max possible number of list entries) into a vector, and then adding and removing them from the Model3DGroup that is set as the content for the ModelVisual3D. This works, but causes a lot of flickering. Is there a more sensible way to approach this?

Right now I have:

        //marker model
        public Model3DGroup modelMarker;

        //parent group
        public Model3DGroup rootGrp;

       //list of all objects
        public List<Model3DGroup> markerModels = new List<Model3DGroup>();

         //importer
           ModelImporter import = new ModelImporter();
            modelMarker = import.Load("data\\assets\\Marker.obj"); // load object

            rootGrp = new Model3DGroup();

            //load 50 markers into list
                for (int i=0;i< 50;i++)
               {
                    var markerTmp = new Model3DGroup();
                    markerTmp = modelMarker;
                    markerModels.Add(markerTmp);
                }

            model.Content = rootGrp; //model is the ModelVisual3D, set parent node as content

And (On a dispatcher timer):

      tmpList = Dense.pullData(); // fills list
                    if (tmpList.Count != 0) // if list is not empty
                    {
                        rootGrp.Children.Clear(); // clear the parent group

                        for (int i = 0; i < tmpList.Count; i++) // for each list entry
                        {
                            int index = Convert.ToInt32(tmpList[i].id); // the ID of each object
                            transMarker.X = tmpList[i].position[0];  // the positional data
                            transMarker.Y = tmpList[i].position[1] ;
                            transMarker.Z = tmpList[i].position[2];

                            quatMarker.X = tmpList[i].rotationQuats[0]; // the rotation data
                            quatMarker.Y = tmpList[i].rotationQuats[1];
                            quatMarker.Z = tmpList[i].rotationQuats[2] ;
                            quatMarker.W = tmpList[i].rotationQuats[3];

                            var matrixMarker = new Matrix3D(); // create a new Matrix3d
                            matrixMarker.Rotate(quatMarker);
                            matrixMarker.Translate(transMarker);
                    
                          rootGrp.Children.Add(markerModels[index]);  // add to the parent group

                             //transform the object
                            markerModels[index].Transform = new MatrixTransform3D(matrixMarker);
                        }

This works, but the objects flicker on and off, and are never all displayed at the same time. Is there a smarter way to do this?

thank you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
holancecommented, Sep 19, 2017

You can download the source code, or use myget link from the home page of this project. The lastest build is the unstable version

1reaction
holancecommented, Sep 19, 2017

I would suggest to change to use sharpdx version. There is an instancing demo, which is doing exactly what you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to dynamically load and unload (reload) a .dll assembly
I'm developing a module for an external application, which is a dll that is loaded. However in order to develop, you have to...
Read more >
How to dynamically load a lot of LOD-ed models?
Lets say I have a big scene with a lot of objects (each made up of LOD group). How do I efficiently load...
Read more >
Adding models/content to the HelixViewport3D in Helix 3D ...
ObjReader CurrentHelixObjReader = new ObjReader(); Model3DGroup MyModel ... How to dynamically load and unload an F# dll into an C# project?
Read more >
Dynamically loading and Unloading Assemblies in C# ...
If you have a need to be able to dynamically load an unload assemblies, you need to work with the AppDomain class.
Read more >
Framework for creating user interfaces containing ...
An arrangement for creating a fully interactive and dynamic UI containing 3-D ... The Loaded and Unloaded events correspond respectively to nodes being ......
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