0

3d cube with colored cells

TheInevitable360 11 months ago updated by emunum numba 4 weeks ago 2

I am working on a code to build a 3D cube that has mesh/cell in each direction and each cell has its own color. now i sue this method which produces exactly what i want:

private void BuildCustomCube22(int x, int y, int z)
{
    double cubeSize = 1.0; // Size of each cube cell

    Random random = new Random();

    var modelGroup = new Model3DGroup();

    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            for (int k = 0; k < z; k++)
            {
                var position = new Point3D(
                    i * cubeSize + cubeSize / 2,
                    j * cubeSize + cubeSize / 2,
                   k * cubeSize + cubeSize / 2);

               // Generate a random color for each cube
               Color color = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256),
               (byte)random.Next(256));

               var cube = new BoxVisual3D
               {
                   Center = position,
                   Width = cubeSize,
                   Height = cubeSize,
                   Length = cubeSize,
                  Material = MaterialHelper.CreateMaterial(color),

                };

               // Add the cube to the model group
               modelGroup.Children.Add(cube.Model);
           }
       }
   }

    // Add the model group to the viewport
    viewport.Children.Add(new ModelVisual3D { Content = modelGroup });
}

and the result is:

Image 195

The issue is when i increase mesh like 100*100*100, i get very poor performance like not being able to easily zoom in/out or move object around. I wonder how can i achieve the result i want event with high number of cells with no lag.

P.S: somebody told me: You are making way too many models. You can try to use Helix toolkit sharpdx version with instancing rendering capability

but i don't know if it can solve my issue and i don't know how to implement it. 

-1

I have a WPF application in which i want to show a cube which has colored cells. so i used the Helix Toolkit with following code:Colored hexagons stock photo containing Slope unblocked 3d and abstract. This 4500 x 3000 px photos misc stock photo features cell, color, and concept.The 3D cube represents the 3D color space perceived by a normal trichromat. Left to right: We show the 2D plane of perceivable colors for Protanopes, ...... cube into two-dimensional space. Parallel projection envelopes of the tesseract (each cell is drawn with different color faces, inverted cells are undrawn).


I can't help but express how truly captivating your writing is. Every sentence feels like it's infused with purpose and thought, reaching out to readers in a way that feels both genuine and profound. The topics you explore and the reflections you offer make your work feel like a conversation with an old friend—familiar, engaging, and always insightful. It's rare to find a voice like yours, one that resonates long after reading. Each piece you share brings a fresh perspective, and I find myself eagerly awaiting the next. Your work reminds me of another site I recently discovered, where ideas are explored with a similar depth and authenticity. Please keep sharing your words; the world is richer with them in it. 98TOTO