
hi everyone i want to create cubes that represented as point3D(x,y,z) and the value is represented as color..
I have tried to create some cubes with height=21cube width = 21 cube and length 21 cube, but the result is not quite good
because when I navigate the cubes, the motion of the cubes is so lag, (the code is shown below).
public MainWindow()
{
InitializeComponent();
// Upper
for (double i = 10; i <= 12; i = i + 1.1)
{
for (double j = 10; j <= 12; j = j + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = j, Z = 12 }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
//Bottom
for (double i = 10; i <= 12; i = i + 1.1)
{
for (double j = 10; j <= 12; j = j + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = j, Z = 10 }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
//Right
for (double i = 10; i <= 12; i = i + 1.1)
{
for (double k = 8.9; k <= 12; k = k + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = 12, Z = k }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
//Left
for (double i = 10; i <= 12; i = i + 1.1)
{
for (double k = 8.9; k <= 10.9; k = k + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = 10, Z = k }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
//Front
for (double j = 8.9; j <= 10.9; j = j + 1.1)
{
for (double k = 8.9; k <= 12; k = k + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = 12, Y = j, Z = k }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
//Behind
for (double j = 8.9; j <= 10.9; j = j + 1.1)
{
for (double k = 8.9; k <= 12; k = k + 1.1)
{
BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = 10, Y = j, Z = k }, Fill = Brushes.DarkKhaki };
view3DHelix.Children.Add(box);
}
}
}
anyone have any idea for a better result?






Something just came to my mind.
What if I add cubes (by add rectangular mesh or other method) to one MeshBuilder, add a linear gradient brush based material to the model and assign texture coordinates to every single cube in a way to apply the color I need?
It all would then count as one mesh, but "separate" cubes could have different colors.
I wonder if that would work?



Yes, this works and I think performance should be much better. I have not tested if there is a performance hit related to assigning texture coordinates or not and gradient brush vs. solid color brush  that would be interesting to know!



If it really works nice, maybe adding single texture coordinate to all convenience calls as optional parameter would be a nice way to assign different colors to elements belonging to the same mesh?
Then we would have calls like MeshBuilder.AddTube( {point1, point2}, width, segments, cap, uniformTextureCoordForTheWholeTubeMesh) , what do you think?



Yes, I think this is a good idea. Can you add an issue on this?



Sure, will do.

