コード例 #1
0
 /**
  * Initializes all the important values that will be used to generate the terrain.
  */
 private void Initialize()
 {
     Debug.Log("Initializing terrain.");
     seed = Utilities.GetTimeBasedSeed(8);
     // Grab references to components.
     meshFilter       = GetComponent <MeshFilter>();
     terrainColorizer = GetComponent <TerrainColor>();
 }
コード例 #2
0
        private void SetupEffect()
        {
            Effect.Parameters["World"].SetValue(World);
            Effect.Parameters["WorldViewProjection"].SetValue(World * View * Projection);
            Effect.Parameters["CameraPosition"].SetValue(CameraPosition);
            Effect.Parameters["Size"].SetValue(Size);
            Effect.Parameters["TerrainColor"].SetValue(TerrainColor.ToVector4());
            Effect.Parameters["Normalmap"].SetValue(NormalMap);
            Effect.Parameters["Bumpiness"].SetValue(Bumpiness);

            Effect.Parameters["HeightmapEnabled"].SetValue(HeightmapEnabled && Heightmap != null);
            Effect.Parameters["TextureEnabled"].SetValue(TextureEnabled && Texture != null);
            Effect.Parameters["LightingEnabled"].SetValue(LightEnabled);
            Effect.Parameters["GeomorphEnabled"].SetValue(GeomorphEnabled);
            Effect.Parameters["BruteForceEnabled"].SetValue(BruteForceEnabled);

            if (Texture != null && TextureEnabled)
            {
                Effect.Parameters["Texture"].SetValue(Texture);
                Effect.Parameters["TextureRepeat"].SetValue(TextureResolution * (Size - 1) / Texture.Width);
            }

            if (Heightmap != null && HeightmapEnabled)
            {
                Effect.Parameters["Heightmap"].SetValue(Heightmap);
                Effect.Parameters["HeightOffset"].SetValue(HeightOffset);
            }

            if (LightEnabled)
            {
                Effect.Parameters["LightDirection"].SetValue(LightDirection);
                Effect.Parameters["LightDiffuse"].SetValue(LightDiffuse);
                Effect.Parameters["LightAmbient"].SetValue(LightAmbient);
                Effect.Parameters["LightSpecular"].SetValue(LightSpecular);
                Effect.Parameters["LightShininess"].SetValue(LightShininess);
            }
        }