public void LoadTextureSet(FileLocation configLoc)
        {
            Configuration config = ConfigurationManager.Instance.CreateInstance(configLoc);

            ConfigurationSection sect = config["MaterialList"];

            ConfigurationSection.ValueCollection entries = sect.Values;

            foreach (string s in entries)
            {
                Entry entry;
                ConfigurationSection matSect = config[s];

                string       fileName = matSect["DiffuseMap"];
                FileLocation fl       = FileSystem.Instance.Locate(fileName, GameFileLocs.TerrainTexture);

                ResourceHandle <TerrainTexture> texture = TerrainTextureManager.Instance.CreateInstance(renderSystem, fl);
                texture.Touch();

                entry.Map = texture;
                float[] v = matSect.GetSingleArray("DiffuseMapColor");
                entry.Color = new Color4F((int)v[0], (int)v[1], (int)v[2]);

                v             = matSect.GetSingleArray("Ambient");
                entry.Ambient = new Color4F(v[0], v[1], v[2], v[3]);

                v             = matSect.GetSingleArray("Diffuse");
                entry.Diffuse = new Color4F(v[0], v[1], v[2], v[3]);

                v = matSect.GetSingleArray("Specular");
                entry.Specular = new Color4F(v[0], v[1], v[2], v[3]);

                entry.Name = s;

                detailedMaps.Add(s, entry);
            }

            FileLocation fl2 = FileSystem.Instance.Locate("index.tex", GameFileLocs.TerrainTexture);

            GlobalIndexTexture = TextureManager.Instance.CreateInstance(fl2);

            fl2 = FileSystem.Instance.Locate("normal.tex", GameFileLocs.TerrainTexture);
            GlobalNormalTexture = TextureManager.Instance.CreateInstance(fl2);


            fl2 = FileSystem.Instance.Locate("LevelTwo.tex", GameFileLocs.TerrainTexture);
            GlobalBakedNormalTexture = TextureManager.Instance.CreateInstance(fl2);



            string msg = "细节纹理库初始化完毕。加载了{0}种纹理。";

            EngineConsole.Instance.Write(string.Format(msg, detailedMaps.Count.ToString()), ConsoleMessageType.Information);

            fl2    = FileSystem.Instance.Locate("hatch1-3RGB.tex", GameFileLocs.Texture);
            Hatch0 = TextureManager.Instance.CreateInstance(fl2);

            fl2    = FileSystem.Instance.Locate("hatch4-6RGB.tex", GameFileLocs.Texture);
            Hatch1 = TextureManager.Instance.CreateInstance(fl2);
        }
Exemple #2
0
        public override void InitalizeGraphics(RenderSystem rs)
        {
            ForestInfo info;

            info.Latitude  = Latitude;
            info.Longitude = Longitude;
            info.Radius    = Radius;

            info.Amount = CurrentAmount;

            //info.Plants = TreeModelLibrary.Instance.Get(0);

            model = TreeBatchModelManager.Instance.CreateInstance(rs, info);

            model.Touch();

            Transformation = model.GetWeakResource().Transformation;
            BoundingSphere = model.GetWeakResource().BoundingVolume;

            sound          = SoundManager.Instance.MakeSoundObjcet("forest", null, BoundingSphere.Radius);
            sound.Position = BoundingSphere.Center;

            {
                float radLng = MathEx.Degree2Radian(Longitude);
                float radLat = MathEx.Degree2Radian(Latitude);

                float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

                stdPosition = PlanetEarth.GetPosition(radLng, radLat, alt * TerrainMeshManager.PostHeightScale + PlanetEarth.PlanetRadius);

                stdTransform = PlanetEarth.GetOrientation(radLng, radLat);
                stdTransform.TranslationValue = stdPosition;


                selectionSphere.Center = stdPosition;
                selectionSphere.Radius = 200;
            }

            FileLocation fl = FileSystem.Instance.Locate("wooden_board_green.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(0, 0, 25) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));
        }
Exemple #3
0
        public TerrainTile(RenderSystem rs, int col, int lat)
            : base(true)
        {
            terrain0 = TerrainMeshManager.Instance.CreateInstance(rs, col, lat, 17);
            terrain0.Touch();
            //terrain1 = TerrainMeshManager.Instance.CreateInstance(rs, col, lat, 17);
            //terrain1.Touch();
            Transformation = terrain0.GetWeakResource().Transformation;
            BoundingSphere = terrain0.GetWeakResource().BoundingSphere;

            //Transformation = terrain0.GetWeakResource().Transformation;
            //BoundingSphere = terrain0.GetWeakResource().BoundingSphere;

            //terrain0.GetWeakResource().ObjectSpaceChanged += TerrainMesh_ObjectSpaceChanged;
            //terrain1.GetWeakResource().ObjectSpaceChanged += TerrainMesh_ObjectSpaceChanged;
        }
Exemple #4
0
        public TerrainTile(RenderSystem rs, int col, int lat)
            : base(true)
        {
            terrain0 = TerrainMeshManager.Instance.CreateInstance(rs, col, lat, 17);
            terrain0.Touch();
            //terrain1 = TerrainMeshManager.Instance.CreateInstance(rs, col, lat, 17);
            //terrain1.Touch();
            Transformation = terrain0.GetWeakResource().Transformation;
            BoundingSphere = terrain0.GetWeakResource().BoundingSphere;

            //Transformation = terrain0.GetWeakResource().Transformation;
            //BoundingSphere = terrain0.GetWeakResource().BoundingSphere;

            //terrain0.GetWeakResource().ObjectSpaceChanged += TerrainMesh_ObjectSpaceChanged;
            //terrain1.GetWeakResource().ObjectSpaceChanged += TerrainMesh_ObjectSpaceChanged;
        }
Exemple #5
0
        public override void PrepareVisibleObjects(ICamera cam, int level)
        {
            //if (level > 0)
            //{
            //    if (terrain1.State == ResourceState.Loaded)
            //    {
            //        ActiveTerrain = terrain1;
            //    }
            //    else
            //    {
            //        terrain1.Touch();
            //    }

            //    if (ActiveTerrain != null)
            //    {
            //        TerrainMesh tm = ActiveTerrain.Resource;

            //        tm.PrepareVisibleObjects(cam, level);
            //    }
            //}
            //else
            {
                if (terrain0.State == ResourceState.Loaded)
                {
                    ActiveTerrain = terrain0;
                }
                else
                {
                    terrain0.Touch();
                }

                if (ActiveTerrain != null)
                {
                    TerrainMesh tm = ActiveTerrain.Resource;

                    tm.PrepareVisibleObjects(cam, level);
                }
            }
        }
Exemple #6
0
        public static void Cache(RenderSystem rs)
        {
            string[] files = FileSystem.Instance.SearchFile("texture\\*.tex");

            for (int i = 0; i < files.Length; i++)
            {
                ResourceHandle <Texture> tex = TextureManager.Instance.CreateInstance(new FileLocation(files[i]));
                textureBuffer.Add(tex);
            }
            files = FileSystem.Instance.SearchFile("model\\*.mesh");

            for (int i = 0; i < files.Length; i++)
            {
                ResourceHandle <ModelData> mdl = ModelManager.Instance.CreateInstance(rs, new FileLocation(files[i]));
                modelBuffer.Add(mdl);
            }
            for (int i = 0; i < textureBuffer.Count; i++)
            {
                textureBuffer[i].Touch();
            }
            for (int i = 0; i < modelBuffer.Count; i++)
            {
                modelBuffer[i].Touch();
            }

            for (int i = 1; i < PlanetEarth.ColTileCount * 2; i += 2)
            {
                for (int j = 1; j < PlanetEarth.LatTileCount * 2; j += 2)
                {
                    //ResourceHandle<TerrainMesh> mesh0 = TerrainMeshManager.Instance.CreateInstance(rs, i, j + PlanetEarth.LatTileStart, 33);
                    //mesh0.Touch();
                    //terrainMesh0.Add(mesh0);

                    ResourceHandle <TerrainMesh> mesh1 = TerrainMeshManager.Instance.CreateInstance(rs, i, j + PlanetEarth.LatTileStart, 17);
                    mesh1.Touch();
                    terrainMesh1.Add(mesh1);
                }
            }
        }
Exemple #7
0
        public override void InitalizeGraphics(RenderSystem rs)
        {

            ForestInfo info;
            info.Latitude = Latitude;
            info.Longitude = Longitude;
            info.Radius = Radius;

            info.Amount = CurrentAmount;

            //info.Plants = TreeModelLibrary.Instance.Get(0);

            model = TreeBatchModelManager.Instance.CreateInstance(rs, info);

            model.Touch();

            Transformation = model.GetWeakResource().Transformation;
            BoundingSphere = model.GetWeakResource().BoundingVolume;

            sound = SoundManager.Instance.MakeSoundObjcet("forest", null, BoundingSphere.Radius);
            sound.Position = BoundingSphere.Center;

            {
                float radLng = MathEx.Degree2Radian(Longitude);
                float radLat = MathEx.Degree2Radian(Latitude);

                float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

                stdPosition = PlanetEarth.GetPosition(radLng, radLat, alt * TerrainMeshManager.PostHeightScale + PlanetEarth.PlanetRadius);

                stdTransform = PlanetEarth.GetOrientation(radLng, radLat);
                stdTransform.TranslationValue = stdPosition;


                selectionSphere.Center = stdPosition;
                selectionSphere.Radius = 200;
            }

            FileLocation fl = FileSystem.Instance.Locate("wooden_board_green.mesh", GameFileLocs.Model);

            board = new Model(ModelManager.Instance.CreateInstance(rs, fl));
            board.CurrentAnimation.Clear();
            board.CurrentAnimation.Add(
                new NoAnimaionPlayer(
                    Matrix.Translation(0, 0, 25) *
                    Matrix.Scaling(2.7f, 2.7f, 2.7f) *
                    Matrix.RotationX(-MathEx.PiOver2) *
                    Matrix.RotationY((-MathEx.PIf * 7.0f) / 8.0f)
                    ));

        }