Example #1
0
        static Predator()
        {
            var egg = new MeshBuilder();
            egg.AddPyramid(new Point3D(0, 0, 0), 0.2, 0.4);
            eggGeometry = egg.ToMesh();

            var child = new MeshBuilder();
            child.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
            child.AddSphere(new Point3D(0.2, 0.2, 1), 0.2, 12, 24);
            child.AddSphere(new Point3D(0.2, -0.2, 1), 0.2, 12, 24);
            childGeometry = child.ToMesh();

            var creature = new MeshBuilder();
            creature.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
            creature.AddCone(new Point3D(0.2, 0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12);
            creature.AddCone(new Point3D(0.2, -0.2, 1), new Vector3D(0, 0, 1), 0.16, 0.04, 0.3, false, true, 12);
            creatureGeometry = creature.ToMesh();

            var coffin = new MeshBuilder();
            coffin.AddCylinder(new Point3D(0, 0, 0), new Point3D(0, 0, 0.25), 1, 12);
            deadGeometry = coffin.ToMesh();

            maleMaterial = MaterialHelper.CreateMaterial(Brushes.Navy);
            femaleMaterial = MaterialHelper.CreateMaterial(Brushes.Violet);
            eggMaterial = MaterialHelper.CreateMaterial(Brushes.AntiqueWhite);
            deadMaterial = MaterialHelper.CreateMaterial(Brushes.Black);

        }
        GeometryModel3D AddGeometry(IEnumerable<Point3D> centers, double l)
        {

            var builder = new MeshBuilder();

            foreach (var center in centers)
            {
                builder.AddPyramid(center, l, l);
            }

            var mv = new GeometryModel3D
                             {
                                 Geometry = builder.ToMesh(true),
                                 Material = MaterialHelper.CreateMaterial(Brushes.Gold)
                             };

            TriangleCount = builder.TriangleIndices.Count / 3;

            return mv;
        }