public override void Do(IDemoChartControl chartControl) { // Create mesh for rendering. We need a cube. Mesh cubeMesh = CubeMeshFactory.GenerateCube(); // Generates cube transformation matrixes and it's colors. Matrix4F[] transformations = new Matrix4F[TotalBarCount]; Color4[] colors = new Color4[TotalBarCount]; int index = 0; for (int x = 0; x < GridSize; x++) { for (int y = 0; y < GridSize; y++) { // Randomize block height. float height = (float)random.NextDouble() * MaxHeight; // Compute current bar transformation matrix. // Scaling matrix is used for size scaling. Translation matrix is used for positioning. transformations[index] = Matrix4F.Scaling(BlockSize, BlockSize, height) * Matrix4F.Translation(GridStep * x, GridStep * y, height / 2); // Randomize color. colors[index] = DemoHelper.RandomizeColor(); index++; } } // Create presentation object. var primitiveCollection = new MultiColorPrimitiveCollection { // Set mesh. Mesh = cubeMesh, // Set name. Name = "Bars", // Set custom material. Material = new RenderMaterial(0.35f, 0.5f, 0.6f, 0.0f, 0.0f) }; // Set transforms. primitiveCollection.SetTransformsAndColor(transformations, colors); // Set chart options. chartControl.Axes.IsAxes3DVisible = true; // Set data source. chartControl.DataSource = primitiveCollection; }
public override void Do(IDemoChartControl chartControl) { chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = new RenderData[] { new Tetrahedron { Color = Colors.Cyan, //Relative to item center position Position = new Vector3F(0, 0, 0.5f), //Item direction Direction = Vector3F.UnitZ, Name = "Tetrahedron" }, //Pyramid with height = 0.5 and orientation via axis Z. This primitive is fully defined via transformation matrices new Pyramid { Color = Colors.Blue, Transform = Matrix4F.Scaling(0.5f, 0.5f, 1f) * Matrix4F.RotationFromDirection(-Vector3F.UnitZ), Name = "Pyramid" } }; }
public override void Do(IDemoChartControl chartControl) { chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = new RenderData[] { new Sphere { //Resolution for radial part of item. Means number of generated points. For sphere it is approximate number due to mesh generation algorithm. Resolution = 100, Color = Colors.DarkBlue, //Item radius Radius = 0.5f, //Item position relative to center Position = new Vector3F(), Name = "Sphere 1" }, new Sphere { //Resolution for radial part of item. Means number of generated points. For sphere it is approximate number due to mesh generation algorithm. Resolution = 100, Color = Colors.Cyan, //Item radius Radius = 0.5f, //Ietm position relative to center Position = new Vector3F(0.5f), //We can create ellipse using transform matrices Transform = Matrix4F.Scaling(1f, 0.5f, 0.5f), Name = "Sphere 2" }, new Sphere { //Resolution for radial part of item. Means number of generated points. For sphere it is approximate number due to mesh generation algorithm. Resolution = 100, Color = Colors.Blue, //Item radius Radius = 0.5f, //Item position relative to center Position = new Vector3F(0.5f, -0.5f, 0.5f), //We can create ellipse using transform matrices Transform = Matrix4F.Scaling(1f, 1f, 0.5f) * Matrix4F.RotationAxis(Vector3F.UnitX, Math.PI / 4), Name = "Sphere 3" }, new SemiSphere { //Resolution for radial part of item. Means number of generated points. For sphere it is approximate number due to mesh generation algorithm. Resolution = 100, Color = Colors.DarkCyan, //Item radius Radius = 0.55f, //Item position relative to center Position = new Vector3F(), //For semi sphere direction can be defined Direction = -Vector3F.UnitX, //Define if semi sphere base is required DrawBottomBase = false, //Item presentation type PresentationType = PrimitivePresentationType.Wireframe, Name = "Sphere 4" }, }; }