Пример #1
0
        public Model3D(Stage theStage, string label, string fileOfModel) : base(theStage)
        {
            name     = label;
            stage    = theStage;
            instance = new List <Object3D>();
            model    = stage.Content.Load <Model>(fileOfModel);
            // compute the translation to the model's bounding sphere
            // center and radius;
            float minX, minY, minZ, maxX, maxY, maxZ;

            minX = minY = minZ = Int32.MaxValue;
            maxX = maxY = maxZ = Int32.MinValue;
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                // See if this mesh extends the bounding sphere.
                BoundingSphere aBoundingSphere = model.Meshes[i].BoundingSphere;
                boundingSphereRadius = aBoundingSphere.Radius;
                // minimum value
                if ((aBoundingSphere.Center.X - aBoundingSphere.Radius) < minX)
                {
                    minX = aBoundingSphere.Center.X - aBoundingSphere.Radius;
                }
                if ((aBoundingSphere.Center.Y - aBoundingSphere.Radius) < minY)
                {
                    minY = aBoundingSphere.Center.Y - aBoundingSphere.Radius;
                }
                if ((aBoundingSphere.Center.Z - aBoundingSphere.Radius) < minZ)
                {
                    minZ = aBoundingSphere.Center.Z - aBoundingSphere.Radius;
                }
                // maximum value
                if ((aBoundingSphere.Center.X + aBoundingSphere.Radius) > maxX)
                {
                    maxX = aBoundingSphere.Center.X + aBoundingSphere.Radius;
                }
                if ((aBoundingSphere.Center.Y + aBoundingSphere.Radius) > maxY)
                {
                    maxY = aBoundingSphere.Center.Y + aBoundingSphere.Radius;
                }
                if ((aBoundingSphere.Center.Z + aBoundingSphere.Radius) > maxZ)
                {
                    maxZ = aBoundingSphere.Center.Z + aBoundingSphere.Radius;
                }
            }
            // get the diameter of model's bounding sphere
            // radius temporarily holds the largest diameter
            if ((maxX - minX) > boundingSphereRadius)
            {
                boundingSphereRadius = maxX - minX;
            }
            // Since a bounding cylinder is used for collision height values not needed
            // if ((maxY - minY) > boundingSphereRadius) boundingSphereRadius = maxY - minY;
            if ((maxZ - minZ) > boundingSphereRadius)
            {
                boundingSphereRadius = maxZ - minZ;
            }
            // set boundingSphereRadius
            boundingSphereRadius = boundingSphereRadius * 1.05f / 2.0f;      // set the radius from largest diameter
            // set the center of model's bounding sphere
            boundingSphereCenter =
                // new Vector3(minX + boundingSphereRadius, minY + boundingSphereRadius, minZ + boundingSphereRadius);
                new Vector3(minX + boundingSphereRadius, minY + boundingSphereRadius, minZ + boundingSphereRadius);
            // need to scale boundingSphereRadius for each object instances in Object3D
        }
Пример #2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Stage stage = new Stage()) {
         stage.Run();
     }
 }
Пример #3
0
 public Wall(Stage theStage, string label, string meshFile, int xOffset, int zOffset)
     : base(theStage, label, meshFile)
 {
     initWall(xOffset, zOffset);
 }
Пример #4
0
 public Wall(Stage theStage, string label, string meshFile)  : base(theStage, label, meshFile)
 {
     initWall(450, 460);      // origin of wall on terrain
 }
Пример #5
0
 /// <summary>
 /// Constructor is a "pass-through" for arguments to Model3D's constructor
 /// </summary>
 /// <param name="theStage"></param>
 /// <param name="label"></param>
 /// <param name="meshFile"></param>
 public MovableModel3D(Stage theStage, string label, string meshFile)
     : base(theStage, label, meshFile)
 {
 }
Пример #6
0
        protected int[] indices;  // indexes for IndexBuffer -- define face vertice indexes clockwise

        public IndexVertexBuffers(Stage theStage, string label) : base(theStage)
        {
            stage = theStage;
            name  = label;
        }