public TreeTemplate(
                int sliceCount,
                int stackDivision,
                int coneCount,
                float height,
                float radius,
                float radAdd
                )
            {
                var          attributePosition = new Attribute(VertexUsage.Position, VertexAttribPointerType.Float, 0, 3);
                var          attributeNormal   = new Attribute(VertexUsage.Normal, VertexAttribPointerType.Float, 0, 3); /*  content normals     */
                VertexFormat vertexFormat      = new VertexFormat();

                vertexFormat.Add(attributePosition);
                vertexFormat.Add(attributeNormal);

                this.sliceCount    = sliceCount;
                this.stackDivision = stackDivision;
                this.coneCount     = coneCount;
                this.height        = height;
                this.radius        = radius;
                this.radAdd        = radAdd;
                float   coneHeight = height / (float)coneCount;
                Matrix4 rotZ       = Matrix4.CreateRotation(
                    RenderStack.Math.Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    );
                float    cylHeight        = coneHeight;
                float    cylRadius        = height / 20.0f;
                Geometry cylinderGeometry = new RenderStack.Geometry.Shapes.Cylinder(-cylHeight, cylHeight, cylRadius, sliceCount);

                cylinderGeometry.Transform(rotZ);
                GeometryMesh cylinderMesh  = new GeometryMesh(cylinderGeometry, NormalStyle.CornerNormals, vertexFormat);
                Shape        cylinderShape = new CylinderShape(cylHeight, cylRadius);

                cylinderMesh.GetMesh.Name = "cylinder";
                meshes.Add(cylinderMesh);
                shapes.Add(cylinderShape);
                for (int c = 0; c < coneCount; c++)
                {
                    float    topRadius      = (coneCount - 1 - c) * radius / (float)coneCount;
                    float    bottomRadius   = topRadius + radAdd;
                    float    R              = bottomRadius;
                    float    r              = topRadius;
                    float    fullConeHeight = (R * coneHeight) / (R - r);
                    float    minX           = -fullConeHeight / 3.0f;
                    float    maxX           = 2.0f * fullConeHeight / 3.0f;
                    float    offset         = -minX;
                    Geometry coneGeometry   = new RenderStack.Geometry.Shapes.Cone(minX, maxX, bottomRadius, 0.0f, true, true, sliceCount, stackDivision);
                    coneGeometry.Transform(rotZ);
                    GeometryMesh coneMesh  = new GeometryMesh(coneGeometry, NormalStyle.CornerNormals, vertexFormat);
                    Shape        coneShape = new ConeShape(fullConeHeight, R);
                    coneMesh.GetMesh.Name = "cone" + c.ToString();
                    meshes.Add(coneMesh);
                    shapes.Add(coneShape);
                }
            }
        public void AddSimpleScene()
        {
            //  Shapes here have local 0,0,0 at center of mass
            Geometry     cubeGeometry = new RenderStack.Geometry.Shapes.Cube(1.0f, 1.0f, 1.0f);
            GeometryMesh cubeMesh     = new GeometryMesh(cubeGeometry, NormalStyle.PolygonNormals);

            GeometryMesh sphereMesh = new GeometryMesh(
                new RenderStack.Geometry.Shapes.Sphere(0.75, 20, 12),
                NormalStyle.CornerNormals
                );
            Geometry cylinderGeometry = new RenderStack.Geometry.Shapes.Cylinder(-0.5f, 0.5f, 0.5f, 24);

            cylinderGeometry.Transform(
                Matrix4.CreateRotation(
                    Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    )
                );
            GeometryMesh cylinderMesh = new GeometryMesh(cylinderGeometry, NormalStyle.CornerNormals);
            Geometry     coneGeometry = new RenderStack.Geometry.Shapes.Cone(-1.0f / 3.0f, 2.0f / 3.0f, 0.75f, 0.0f, true, false, 24, 10);

            coneGeometry.Transform(
                Matrix4.CreateRotation(
                    Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    )
                );
            GeometryMesh coneMesh = new GeometryMesh(coneGeometry, NormalStyle.CornerNormals);

            /*  Models  */
            float    gap     = 2.5f;
            Material pearl   = materialManager["pearl"];
            Material gold    = materialManager["gold"];
            Material red     = materialManager["red"];
            Material green   = materialManager["green"];
            Material cyan    = materialManager["cyan"];
            Material blue    = materialManager["blue"];
            Material magenta = materialManager["magenta"];
            Material pink    = materialManager["pink"];

            AddModel(new Model("cube", cubeMesh, pearl, -3.5f * gap, 0.5f, 0.0f));
            AddModel(new Model("box", cubeMesh, gold, -2.5f * gap, 0.5f, 0.0f));
            AddModel(new Model("sphere", sphereMesh, red, -1.5f * gap, 0.75f, 0.0f));
            AddModel(new Model("sphere", sphereMesh, green, -0.5f * gap, 0.75f, 0.0f));
            AddModel(new Model("cylinder", cylinderMesh, cyan, 0.5f * gap, 0.5f, 0.0f));
            AddModel(new Model("cylinder", cylinderMesh, blue, 1.5f * gap, 0.5f, 0.0f));
            AddModel(new Model("cone", coneMesh, magenta, 2.5f * gap, 1.0f / 3.0f, 0.0f));
            AddModel(new Model("cone", coneMesh, pink, 3.5f * gap, 1.0f / 3.0f, 0.0f));
        }
        public void MakeNoiseScene()
        {
            Reset();

            float scale = 1.0f;

            AddFloor(30.0f * scale, 5, -0.5f);

            int      subdiv       = 3;
            Geometry coneGeometry = new RenderStack.Geometry.Shapes.Cone(
                -1.0f / 3.0f, 2.0f / 3.0f, 0.75f, 0.0f, true, false, 24 * subdiv, 10 * subdiv
                );

            coneGeometry.Transform(
                Matrix4.CreateRotation(
                    RenderStack.Math.Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    )
                );
            //coneGeometry = Mush(0.08f, coneGeometry);
            var coneMesh  = new GeometryMesh(coneGeometry, NormalStyle.CornerNormals);
            var coneShape = new ConeShape(1.0f, 0.75f);
            var gold      = materialManager["noisy"];
            var magenta   = materialManager["magenta"];

            userInterfaceManager.CurrentMaterial = "noisy";

            Geometry ellipsoidGeometry = new RenderStack.Geometry.Shapes.Ellipsoid(
                new Vector3(0.5f, 1.0f, 1.5f), 20, 12
                );

            var ellipsoidMesh  = new GeometryMesh(ellipsoidGeometry, NormalStyle.PointNormals);
            var ellipsoidShape = new EllipsoidShape(0.5f, 1.0f, 1.5f);

            for (float x = -4.0f; x <= 4.0f; x += 8.0f)
            {
                for (float z = -4.0f; z <= 4.0f; z += 8.0f)
                {
                    AddModel(new Model("cone", coneMesh, gold, x, 1.0f / 3.0f, z), coneShape).RigidBody.IsActive            = false;
                    AddModel(new Model("ellipsoid", ellipsoidMesh, magenta, x, 2.0f, z), ellipsoidShape).RigidBody.IsActive = false;
                }
            }

            AddCameras();
            AddCameraUserControls();
        }
        public void MakeSimpleScene()
        {
            System.Console.WriteLine("MakeSimpleScene");
            int subdiv = 1;

            Reset();

            float scale = 1.0f;

            //sceneManager.AddFloor(22.0f * scale, 0, -1.0f);
            AddFloor(22.0f * scale, 5, -0.5f);

            /*  Renderable meshes  */
            Geometry cubeGeometry = new RenderStack.Geometry.Shapes.Cube(1.0f, 1.0f, 1.0f);

            //Geometry cubeGeometry = new RenderStack.Geometry.Shapes.Cube(Vector3.One, new IVector3(20, 20, 20), 1.0f);
            cubeGeometry = Mush(0.04f, cubeGeometry);

            /*cubeGeometry.BuildEdges();
            *  cubeGeometry = new SubdivideGeometryOperation(cubeGeometry).Destination;
            *  cubeGeometry = new SubdivideGeometryOperation(cubeGeometry).Destination;
            *  cubeGeometry = new SubdivideGeometryOperation(cubeGeometry).Destination;
            *  cubeGeometry = new CatmullClarkGeometryOperation(cubeGeometry).Destination;
            *  cubeGeometry.ComputePolygonCentroids();
            *  cubeGeometry.ComputePolygonNormals();
            *  cubeGeometry.ComputeCornerNormals(0.0f);
            *  cubeGeometry.BuildEdges();*/
            GeometryMesh cubeMesh = new GeometryMesh(cubeGeometry, NormalStyle.PolygonNormals);

#if OPENRL
            Geometry geodesatedBoxGeometry = new RenderStack.Geometry.Shapes.Cube(
                new Vector3(1.0f, 1.0f, 1.0f), new IVector3(2, 2, 2)
                );
#else
            Geometry geodesatedBoxGeometry = new RenderStack.Geometry.Shapes.Cube(
                new Vector3(1.0f, 1.0f, 1.0f), new IVector3(6, 6, 6)
                );
#endif
            geodesatedBoxGeometry.Geodesate(0.75f);

            //  This is the best geo shape but somewhat slow to create
#if false
            Geometry subdividedIcosahedron = new RenderStack.Geometry.Shapes.Icosahedron(1.00);
            //subdividedIcosahedron = Sqrt3(subdividedIcosahedron);
            //subdividedIcosahedron = Mush(0.01f, subdividedIcosahedron);
            GeometryMesh sphereMesh2 = new GeometryMesh(
                subdividedIcosahedron,
                NormalStyle.PolygonNormals
                );
#endif

#if false
            GeometryMesh discMesh = new GeometryMesh(
                new RenderStack.Geometry.Shapes.Disc(1.0, 0.8, 32, 2),
                NormalStyle.PolygonNormals
                );
            GeometryMesh triangleMesh = new GeometryMesh(
                new RenderStack.Geometry.Shapes.Triangle(0.8f / 0.57735027f),
                NormalStyle.PolygonNormals
                );
#endif


            GeometryMesh sphereMesh = new GeometryMesh(
                //new RenderStack.Geometry.Shapes.Sphere(0.75, 24, 14),
                geodesatedBoxGeometry,
                NormalStyle.CornerNormals
                );
#if false
#endif
            //Geometry cylinderGeometry = new RenderStack.Geometry.Shapes.Cylinder(-0.5f, 0.5f, 0.5f, 24);
#if OPENRL
            Geometry cylinderGeometry = new RenderStack.Geometry.Shapes.Cone(-0.5f, 0.5f, 0.5f, 0.5f, true, true, 5, 1);
#else
            Geometry cylinderGeometry = new RenderStack.Geometry.Shapes.Cone(-0.5f, 0.5f, 0.5f, 0.5f, true, true, 24, 1);
#endif
            cylinderGeometry.Transform(
                Matrix4.CreateRotation(
                    RenderStack.Math.Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    )
                );
            //cylinderGeometry = Mush(0.08f, cylinderGeometry);

            GeometryMesh cylinderMesh = new GeometryMesh(cylinderGeometry, NormalStyle.CornerNormals);
#if OPENRL
            Geometry coneGeometry = new RenderStack.Geometry.Shapes.Cone(-1.0f / 3.0f, 2.0f / 3.0f, 0.75f, 0.0f, true, false, 5, 5);
#else
            Geometry coneGeometry = new RenderStack.Geometry.Shapes.Cone(-1.0f / 3.0f, 2.0f / 3.0f, 0.75f, 0.0f, true, false, 24 * subdiv, 10 * subdiv);
#endif
            coneGeometry.Transform(
                Matrix4.CreateRotation(
                    RenderStack.Math.Conversions.DegreesToRadians(90.0f),
                    Vector3.UnitZ
                    )
                );
            //coneGeometry = Mush(0.08f, coneGeometry);
            GeometryMesh coneMesh = new GeometryMesh(coneGeometry, NormalStyle.CornerNormals);

            /*  Physics shapes  */
            Shape cubeShape     = new BoxShape(1.0f, 1.0f, 1.0f);
            Shape sphereShape   = new SphereShape(0.75f);
            Shape cylinderShape = new CylinderShape(1.0f, 0.5f);
            Shape coneShape     = new ConeShape(1.0f, 0.75f);

            /*  Models  */
            float gap = 2.5f;

            //var defaultPng = materialManager.Texture("res/images/default.png", true);

            Material pearl = materialManager["pearl"];
            Material gold  = materialManager["gold"];
            //Material red        = materialManager.MakeTextured("red", defaultPng);
            Material red = materialManager["red"];
            //Material green      = materialManager["green"]  ;
            Material transparent = materialManager["transparent"];
            Material cyan        = materialManager["cyan"];
            Material blue        = materialManager["blue"];
            Material magenta     = materialManager["magenta"];
            Material pink        = materialManager["pink"];
            Material hsv         = materialManager["HSVColorFill"];
            Material hsv2        = materialManager["HSVColorFill2"];
            for (int z = 0; z < 1; ++z)
            {
                float Z = (float)(1 - z) * gap;
                AddModel(new Model("cube", cubeMesh, z == 0 ? pearl   : pearl, -2.5f * gap, 0.5f, Z), cubeShape);
                AddModel(new Model("box", cubeMesh, z == 0 ? gold    : pearl, -1.5f * gap, 0.5f, Z), cubeShape);
                AddModel(new Model("sphere", sphereMesh, z == 0 ? red     : pearl, -0.5f * gap, 0.75f, Z), sphereShape);
                AddModel(new Model("cylinder", cylinderMesh, z == 0 ? cyan    : pearl, 0.5f * gap, 0.5f, Z), cylinderShape);
                AddModel(new Model("cylinder", cylinderMesh, z == 0 ? blue    : pearl, 1.5f * gap, 0.5f, Z), cylinderShape);
                AddModel(new Model("cone", coneMesh, z == 0 ? magenta : pearl, 2.5f * gap, 1.0f / 3.0f, Z), coneShape);
                AddModel(new Model("cone", coneMesh, z == 0 ? pink    : pearl, 3.5f * gap, 1.0f / 3.0f, Z), coneShape);
                //AddModel(new Model("disc",     discMesh,     hsv,      4.5f * gap, 2.0f, Z), null);
                //AddModel(new Model("triangle", triangleMesh, hsv2,     4.5f * gap, 2.0f, Z), null);
                //AddModel(new Model("sphere",   sphereMesh2,  gold,    -0.5f * gap, 0.75f, Z), sphereShape);
                //AddModel(new Model("sphere",   sphereMesh,   transparent,   -0.5f * gap, 0.75f, Z), sphereShape);
            }

            AddCameras();
            AddCameraUserControls();

#if false
            if (RenderStack.Graphics.Configuration.useOpenRL)
            {
                var rl = Services.Get <OpenRLRenderer>();
                rl.BuildScene(renderGroup);
            }
#endif
        }