public SimplexTerrainComponent(PhysicsWorld physicsWorld)
            : base(physicsWorld)
        {
            rHeights = new float[4];
            int numberOfOctaves = 8;
            octaves = new OpenSimplexNoise[numberOfOctaves];
            frequencys = new double[numberOfOctaves];
            amplitudes = new double[numberOfOctaves];
            for (int i = 0; i < 8; i++)
                tmpVec[i] = new Vector2f();

            for (int i = 0; i < numberOfOctaves; i++)
            {
                octaves[i] = new OpenSimplexNoise(666);
                frequencys[i] = (float)System.Math.Pow(2, i);
                amplitudes[i] = (float)System.Math.Pow(0.5f, octaves.Length - i);
            }

            //Texture splat = AssetManager.LoadTexture("C:\\Users\\User\\Desktop\\test_0_1.png");
            ///terrainMaterial.SetValue(TerrainMaterial.TEXTURE_SPLAT, splat);

            //terrainMaterial.SetValue(Material.COLOR_DIFFUSE, new Vector4f(0.2f, 0.7f, 0.2f, 1.0f));
            Texture grass = AssetManager.LoadTexture(Assets.AssetManager.GetAppPath() + "\\textures\\grass4.jpg");
            Texture grass_nrm = AssetManager.LoadTexture(Assets.AssetManager.GetAppPath() + "\\textures\\grass_NRM.jpg");
            Texture dirt = AssetManager.LoadTexture(Assets.AssetManager.GetAppPath() + "\\textures\\dirt.jpg");
            Texture dirt_nrm = AssetManager.LoadTexture(Assets.AssetManager.GetAppPath() + "\\textures\\dirt_NRM.jpg");
            terrainMaterial.SetValue(TerrainMaterial.TEXTURE_DIFFUSE0, grass);
            terrainMaterial.SetValue(TerrainMaterial.TEXTURE_NORMAL0, grass_nrm);
            terrainMaterial.SetValue(TerrainMaterial.TEXTURE_DIFFUSE_SLOPE, dirt);
            terrainMaterial.SetValue(TerrainMaterial.TEXTURE_NORMAL_SLOPE, dirt_nrm);
            terrainMaterial.SetValue(Material.MATERIAL_CASTSHADOWS, false);
            terrainMaterial.SetValue(Material.SHININESS, 0.1f);
            terrainMaterial.SetValue(Material.ROUGHNESS, 0.08f);
        }
Exemple #2
0
 public Game(Renderer renderer)
 {
     cam = new DefaultCamera(inputManager, 55);
     renderManager = new RenderManager(renderer, cam, new Action(() => { Render(); }));
     renderManager.SpriteRenderer = new SpriteRenderer(this);
     physicsWorld = new PhysicsWorld(new PhysicsDebugDraw(cam));
 }
 public TerrainChunkNode(PhysicsWorld physicsWorld, TerrainComponent parentT, int x, int z, Vector3f scale, int chunkSize, TerrainChunkNode[] neighbors)
     : base("TerrainChunkNode")
 {
     this.physicsWorld = physicsWorld;
     this.x = x;
     this.z = z;
     this.neighbors = neighbors;
     this.scale = scale;
     this.chunkSize = chunkSize;
     this.parentT = parentT;
 }
 public override TerrainChunkNode CreateNewChunk(PhysicsWorld physicsWorld, TerrainComponent parentT, int x, int z, Vector3f scale, int chunkSize, TerrainChunkNode[] neighbors)
 {
     string assetLoc = directory + "\\" + defaultName + "_" + x.ToString() + "_" + z.ToString() + defaultExt;
     GameObject loadedObj = null;
     if (System.IO.File.Exists(assetLoc))
     {
         loadedObj = Assets.AssetManager.LoadModel(assetLoc);
     }
     else
     {
         assetLoc = directory + "\\" + defaultName + "_0_0" + defaultExt;
         if (System.IO.File.Exists(assetLoc))
         {
             loadedObj = Assets.AssetManager.LoadModel(assetLoc);
         }
     }
     return new ModelTerrainChunkNode(loadedObj, physicsWorld, (ModelTerrainComponent)parentT, x, z, scale, chunkSize, (ModelTerrainChunkNode[])neighbors);
 }
 public override TerrainChunkNode CreateNewChunk(PhysicsWorld physicsWorld, TerrainComponent parentT, int x, int z, Vector3f scale, int chunkSize, TerrainChunkNode[] neighbors)
 {
     return new SimplexTerrainChunkNode(physicsWorld, (SimplexTerrainComponent)parentT, x, z, scale, chunkSize, (SimplexTerrainChunkNode[])neighbors, biomesEnabled);
 }
 public RigidBodyControl(float mass, PhysicsWorld.PhysicsShape physicsShape)
 {
     this.mass = mass;
     this.physicsShape = physicsShape;
 }
 public ModelTerrainChunkNode(GameObject objToAdd, PhysicsWorld physicsWorld, ModelTerrainComponent parentT, int x, int z, Vector3f scale, int chunkSize, ModelTerrainChunkNode[] neighbors)
     : base(physicsWorld, parentT, x, z, scale, chunkSize, neighbors)
 {
     this.objToAdd = objToAdd;
 }
 public GrassPopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, true)
 {
     this.physicsWorld = physicsWorld;
 }
 public RockPopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, true, 0.42f)
 {
     this.physicsWorld = physicsWorld;
 }
 public abstract TerrainChunkNode CreateNewChunk(PhysicsWorld physicsWorld, TerrainComponent parentT, int x, int z, Vector3f scale, int chunkSize, TerrainChunkNode[] neighbors);
 public TerrainComponent(PhysicsWorld physicsWorld)
 {
     this.physicsWorld = physicsWorld;
     heightmaps = new List<HeightInfo>();
 }
 public TerrainComponent(PhysicsWorld physicsWorld)
     : this()
 {
     this.physicsWorld = physicsWorld;
 }
 public TreePopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, false, 0.4f)
 {
     this.physicsWorld = physicsWorld;
 }