Пример #1
0
 public Background(GameController game)
 {
     this.game = game;
     this.name = "BG6";
     this.transformation = Matrix.Identity * Constants.BGinitTransform;
     this.size = new Vector3(Constants.screenHeight * 20, Constants.screenHeight * 20, Constants.screenHeight * 20);
     this.model = game.assets.CreateModelFromFile("sphere.x", name, size, Constants.noColor, true);
 }
Пример #2
0
 public Model GetModel(String modelName, Model modelMaker)
 {
     if (!modelDict.ContainsKey(modelName))
     {
         modelDict[modelName] = modelMaker;
     }
     return modelDict[modelName];
 }
Пример #3
0
        /*
        public Model CreateModelFromFile(String filename, String textureName, Vector3 size, Vector4 color, bool inverted)
        {
            Style style = styleDict[StyleType.Colored];

            // get base array
            var shapeArray = GetShapeArray(filename, color, inverted);

             // Scale all the vertices by the size.
             for (int i = 0; i < shapeArray.Length; i += style.floatsPerVertex)
             {
                 shapeArray[i + 0] *= size.X / 2;
                 shapeArray[i + 1] *= size.Y / 2;
                 shapeArray[i + 2] *= size.Z / 2;
             }

            // Make new model
            Model model = new Model
            {
                shapeList = new Shape[]{
                createShape(shapeArray, PrimitiveTopology.TriangleList, textureName, style),
            }
            };

             // revert scale
             for (int i = 0; i < shapeArray.Length; i += style.floatsPerVertex)
             {
                 shapeArray[i + 0] /= (size.X / 2);
                 shapeArray[i + 1] /= (size.Y / 2);
                 shapeArray[i + 2] /= (size.Z / 2);
             }

             return model;

        }
        */
        public Model CreateModelFromFile(String filename, String textureName, Vector3 size, Vector4 color, bool inverted)
        {
            Style style = styleDict[StyleType.Colored];

            // get base array
            var baseShapeArray = GetShapeArray(filename, color, inverted);

             // copy to new array
            var array = new float[baseShapeArray.Length];
            for (int i = 0; i < array.Length; i++)
             {
                 array[i] = baseShapeArray[i];
             }

             // Scale all the vertices by the size.
            for (int i = 0; i < array.Length; i += style.floatsPerVertex)
             {
                 array[i + 0] *= size.X / 2;
                 array[i + 1] *= size.Y / 2;
                 array[i + 2] *= size.Z / 2;
             }

              // Return the model with all six sides.
              Model model = new Model
              {
                  shapeList = new Shape[]{
                  createShape(array, PrimitiveTopology.TriangleList, textureName, style),
              }
              };

              toRemove.Push(array);

              return model;
        }