示例#1
0
        private void CreateTestScene()
        {
            var boxMesh    = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 0, 0), new Size3D(1, 1, 1), 1, 1, 1).Geometry;
            var sphereMesh = new Ab3d.Meshes.SphereMesh3D(new Point3D(0, 0, 0), 0.7, 30).Geometry;

            int modelsXCount = 10;
            int modelsYCount = 1;
            int modelsZCount = 10;

            _objectsModel3DGroup = new Model3DGroup();

            AddModels(_objectsModel3DGroup, boxMesh, new Point3D(0, 5, 0), new Size3D(500, modelsYCount * 10, 500), 10, modelsXCount, modelsYCount, modelsZCount);
            AddModels(_objectsModel3DGroup, sphereMesh, new Point3D(25, 5, 25), new Size3D(500, modelsYCount * 10, 500), 10, modelsXCount, modelsYCount, modelsZCount);

            MainViewport.Children.Add(_objectsModel3DGroup.CreateContentVisual3D());

            // It would be optimal to use WireGridVisual3D to create a wire grid.
            // But because WireGridVisual3D creates a MultiLineVisual3D behind the scene, all the lines can have only a single color.
            // Therefore we create multiple lines for this sample so we can easily change color of individual lines.
            // And what is more, this way the object id map can get us the hit 3D lines (otherwise the whole MultiLineVisual3D would be hit)
            // <visuals:WireGridVisual3D CenterPosition="0 0 0" Size="500 500" WidthCellsCount="20" HeightCellsCount="20" LineColor="#555555" LineThickness="5"/>

            var contentVisual3D = CreateWireGridLines(new Point3D(0, 0, 0), new Size(500, 500), 20, 20, new Vector3D(1, 0, 0), new Vector3D(0, 0, 1), Colors.Gray, 5);

            MainViewport.Children.Add(contentVisual3D);
        }