Esempio n. 1
0
        public SimpleTerrain(ContentRegister content, Vector3 position, string modelDataName)
        {
            this.modelDataName = modelDataName;

            //Matrix.CreateTranslation(ref position, out this.worldMatrix);
            this.worldMatrix = Matrix.CreateTranslation(position);// *Matrix.CreateScale(2.0f); // needed for physics

            //A ModelInstance can be created without any content...
            //However it cannot be used until the content is set
            this.model = new ModelInstance();

            this.terrainShader = new Shaders.SimpleTerrain();

            PickingDrawer = new LightSourceDrawer(Vector3.Zero, new Xen.Ex.Geometry.Sphere(new Vector3(3), 8, true, false, false), Color.Red);

            //add to the content register and load textures/etc
            content.Add(this);
        }
Esempio n. 2
0
        //constructor, including shaders
        //This constructor is called from the LoadContent method, the ContentManager is passed in.
        public SimpleTerrainShaderProvider(Shaders.SimpleTerrain shader, Xen.Ex.Graphics.Content.ModelData model, ContentManager manager, string assetLocation)
        {
            //Generate a list of SOF textures for this model
            List<Texture2D> textures = new List<Texture2D>();

            assetLocation = assetLocation ?? "";
            if (assetLocation.Length > 0)
                assetLocation += "/";

            //loop through all the geometries in the model
            foreach (Xen.Ex.Graphics.Content.MeshData mesh in model.Meshes)
            {
                foreach (Xen.Ex.Graphics.Content.GeometryData geom in mesh.Geometry)
                {
                    //take the existing texture file name and add 'SOF' on the end, to find the skin/occlusion/face+skin texture

                    //Normally, XNA would add '_0' to the end of every texture asset, so each model has a unique copy of the
                    //asset (incase a model sets up different processing options for the asset).

                    //Xen supports the ability to set 'Manual Texture Import' property to true.
                    //When this is set to true, the model will not directly process the textures, it
                    //will simply assume they are processed. This requires each texture is manually added to the project.
                    //When this is true, the textures are not renamed.

                    //Try and load a texture with 'SOF' on the end.
                    Texture2D texture = manager.Load<Texture2D>(assetLocation + geom.MaterialData.TextureFileName + "SOF");
                    textures.Add(texture);
                }
            }

            //store the textures
            this.SofTextures = textures.ToArray();

            this.shader = shader;
        }