Exemple #1
0
        private void LoadPlayer(Loader loader, List <Entity> entities)
        {
            ModelTexture personTexture = new ModelTexture(loader.LoadTexture("playerTexture"));

            personTexture.ShineDamper  = 30f;
            personTexture.Reflectivity = 0.3f;
            TextureModel personModel = new TextureModel(OBJLoader.LoadObjModel("person", loader), personTexture);

            this.player = new Player(personModel, new Vertex3f(0, 5, 0), 0, 100, 0, 0.6f);
            entities.Add(this.player);
        }
        private void PrepareTextureModel(TextureModel model)
        {
            RawModel rawModel = model.RawModel;

            Gl.BindVertexArray(rawModel.VaoID);
            Gl.EnableVertexAttribArray(0); // Position
            Gl.EnableVertexAttribArray(1); // UV 매핑 데이터 Slot 활성
            Gl.EnableVertexAttribArray(2); // Normal

            ModelTexture texture = model.Texture;

            if (texture.HasTransparency)
            {
                MasterRenderer.DisableCulling();
            }

            this.shader.LoadFakeLighting(texture.UseFakeLigihting);
            this.shader.LoadShineVariables(texture.ShineDamper, texture.Reflectivity);
            Gl.ActiveTexture(TextureUnit.Texture0);
            Gl.BindTexture(TextureTarget.Texture2d, texture.TextureID);
        }
Exemple #3
0
        private void LoadEntities(Terrain terrain, List <Entity> entities, Loader loader)
        {
            //Tree
            ModelTexture lowPolyTree = new ModelTexture(loader.LoadTexture("bobbleTree"));

            lowPolyTree.ShineDamper  = 30f;
            lowPolyTree.Reflectivity = 0.3f;
            TextureModel lowPolyTreeModel = new TextureModel(OBJLoader.LoadObjModel("bobbleTree", loader), lowPolyTree);

            //Tree
            ModelTexture treeTexture = new ModelTexture(loader.LoadTexture("pine"));

            treeTexture.ShineDamper  = 30f;
            treeTexture.Reflectivity = 0.3f;
            TextureModel treeModel = new TextureModel(OBJLoader.LoadObjModel("pine", loader), treeTexture);

            //Grass
            ModelTexture grassTexture = new ModelTexture(loader.LoadTexture("grassTexture"));

            grassTexture.HasTransparency  = true;
            grassTexture.UseFakeLigihting = true;
            TextureModel grassModel = new TextureModel(OBJLoader.LoadObjModel("grassModel", loader), grassTexture);


            ModelTexture flowerTexture = new ModelTexture(loader.LoadTexture("flower"));

            flowerTexture.HasTransparency  = true;
            flowerTexture.UseFakeLigihting = true;
            TextureModel flowerModel = new TextureModel(OBJLoader.LoadObjModel("grassModel", loader), flowerTexture);

            //Fern
            ModelTexture fernTextureAltas = new ModelTexture(loader.LoadTexture("fernAtlas"));

            fernTextureAltas.NumberOfRows = 2;
            TextureModel fernModel = new TextureModel(OBJLoader.LoadObjModel("fern", loader), fernTextureAltas);

            //Lemp
            ModelTexture lampTexture = new ModelTexture(loader.LoadTexture("lamp"));

            lampTexture.UseFakeLigihting = true;
            lampTexture.Reflectivity     = 0.3f;
            lampTexture.ShineDamper      = 30f;

            TextureModel lampModel = new TextureModel(OBJLoader.LoadObjModel("lamp", loader), lampTexture);

            entities.Add(new Entity(lampModel, GetHeightPosition(terrain, 185, 0f, -293), 0, 0, 0, 1));
            entities.Add(new Entity(lampModel, GetHeightPosition(terrain, 370, 0f, -300), 0, 0, 0, 1));
            entities.Add(new Entity(lampModel, GetHeightPosition(terrain, 293, 0f, -305), 0, 0, 0, 1));

            float x = 100f;
            float z = -50f;
            float y = terrain.GetHeightOfTerrain(x, z);

            entities.Add(new Entity(treeModel, new Vertex3f(x, y, z), 0, 0, 0, 1f));

            x = 100f;
            z = -130f;
            y = terrain.GetHeightOfTerrain(x, z);
            entities.Add(new Entity(treeModel, new Vertex3f(x, y, z), 0, 0, 0, 1.5f));

            x = 50f;
            z = -105f;
            y = terrain.GetHeightOfTerrain(x, z);
            entities.Add(new Entity(treeModel, new Vertex3f(x, y, z), 0, 0, 0, 1.3f));

            x = 70f;
            z = -130f;
            y = terrain.GetHeightOfTerrain(x, z);
            entities.Add(new Entity(treeModel, new Vertex3f(x, y, z), 0, 0, 0, 1f));

            Random random = new Random();

            for (int i = 0; i < 10; i++)
            {
                if (i % 2 == 0)
                {
                    entities.Add(new Entity(fernModel, random.Next(0, 3), GetRadomPosition(terrain, random, Terrain.SIZE, -Terrain.SIZE), 0, 0, 0, 0.6f));
                }

                if (i % 5 == 0)
                {
                    entities.Add(new Entity(lowPolyTreeModel, GetRadomPosition(terrain, random, Terrain.SIZE, -Terrain.SIZE), 0, 0, 0, 1f));
                }

                entities.Add(new Entity(treeModel, GetRadomPosition(terrain, random, Terrain.SIZE, -Terrain.SIZE), 0, 0, 0, 1f));
                entities.Add(new Entity(grassModel, GetRadomPosition(terrain, random, Terrain.SIZE, -Terrain.SIZE), 0, 0, 0, 1));
                entities.Add(new Entity(flowerModel, GetRadomPosition(terrain, random, Terrain.SIZE, -Terrain.SIZE), 0, 0, 0, 1));
            }
        }