public Terrain(ParagliderSimulator game, GraphicsDevice device, float terrainScale, float fogStart, float fogEnd, Texture2D heightmap, Texture2D grassTexture, Texture2D sandTexture, Texture2D rockTexture, Texture2D snowTexture, Texture2D treeMap, Texture2D grassMap, Texture2D treeTexture, ContentManager Content, Texture2D updraftMap, Texture2D dirtTexture, Texture2D fieldTextureMap) { this.game = game; this.device = device; this.heightmap = heightmap; this.grassTexture = grassTexture; this.sandTexture = sandTexture; this.rockTexture = rockTexture; this.snowTexture = snowTexture; this.terrainScale = terrainScale; this.fogStart = fogStart; this.fogEnd = fogEnd; this.treeTexture = treeTexture; this.dirtTexture = dirtTexture; LoadHeightData(heightmap); LoadUpdraftData(updraftMap); LoadFieldTextureData(fieldTextureMap); SetUpVertices(); SetUpIndices(); CalculateNormals(); CopyToBuffers(); wind = new WindStrengthSin(); animator = new TreeWindAnimator(wind); LoadTreeGenerators(Content); NewTree(); List <Vector3> treeList = GenerateTreePositions(treeMap, vertices); CreateBillboardVerticesFromList(treeList); //List<Vector3> grassList = GenerateTreePositions(grassMap, vertices); bbEffect = Content.Load <Effect>(@"Shader/bbEffect"); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); camerafps = new FPSCameraController(camera, GraphicsDevice); grid = new Grid(GraphicsDevice); LoadTreeGenerators(); NewTree(); font = Content.Load <SpriteFont>("Fonts/Font"); // Create a wind animation. The WindStrengthSin class is a rather crude but simple wind generator wind = new WindStrengthSin(); animator = new TreeWindAnimator(wind); }
protected override void Initialize() { content = new ContentManager(Services, "Content"); // Load all trees in the Content/Trees folder string[] files = Directory.GetFiles("Content/Trees", "*.xnb", SearchOption.TopDirectoryOnly); foreach (string filename in files) { string assetName = filename.Substring("Content/".Length, filename.Length - "Content/.xnb".Length); Profiles.Add(content.Load <TreeProfile>(assetName)); ProfileNames.Add(Path.GetFileName(assetName)); } profileIndex = 0; // Create the wind animator wind = new WindStrengthSin(); animator = new TreeWindAnimator(wind); // Create the ground plane and an effect for it groundPlane = new Quad(GraphicsDevice, 10000, 10000); groundEffect = new BasicEffect(GraphicsDevice, new EffectPool()); groundEffect.Texture = content.Load <Texture2D>("Textures/Grass"); groundEffect.TextureEnabled = true; // Create a camera Camera = new Camera(); Camera.Position = new Vector3(4000, 4000, 4000); Camera.Target = new Vector3(0, 2000, 0); Camera.AspectRatio = GraphicsDevice.Viewport.Width / (float)GraphicsDevice.Viewport.Height; CameraOrbitAngle = 0.0f; CameraPitchAngle = -10.0f; CameraDistance = 5000.0f; // Enable mipmaps GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Linear; // Store the initial renderstate block = new StateBlock(GraphicsDevice); block.Capture(); Initialized = true; UpdateTree(); Application.Idle += new EventHandler(Application_Idle); }
public override void Initialize() { _treeProfile = Content.Load <TreeProfile>("Trees/Graywood"); _tree = new SunlitSimpleTree(_treeProfile.GenerateSimpleTree()); _tree.Lighting = _sky; // Scale tree down to a desired height const int desiredHeight = 6; float treeModelHeight = _tree.TrunkMesh.BoundingSphere.Radius * 2; _scale = Matrix.CreateScale(desiredHeight / treeModelHeight); Position = _position; _wind = new WindStrengthSin(); _animator = new TreeWindAnimator(_wind); base.Initialize(); }