/// <summary> /// Create terrain at <paramref name="position"/> /// </summary> /// <param name="position"></param> /// <param name="textures"></param> /// <param name="device"></param> /// <param name="scale"></param> /// <param name="Content"></param> /// <param name="camera"></param> public QuadTree(Vector3 position, List<Texture2D> textures, GraphicsDevice device, int scale, ContentManager Content, GameCamera.FreeCamera camera) { shadow = new LightsAndShadows.Shadow(); light = new LightsAndShadows.Light(0.7f, 0.4f, new Vector3(513, 100, 513)); ViewFrustrum = new BoundingFrustum(camera.View * camera.Projection); // Model model = Content.Load<Model>("Models/stone2"); // this.model = new LoadModel(model, Vector3.One, Vector3.Up, new Vector3(1), device); this.textures = textures; effect = Content.Load<Effect>("Effects/MultiTextured"); effect2 = Content.Load<Effect>("Effects/Shadows"); Device = device; _position = position; _topNodeSize = textures[4].Width - 1; _vertices = new MapRender(textures[4],scale); _buffers = new BufferManager(_vertices.Vertices, device); _rootNode = new QuadNode(NodeType.FullNode, _topNodeSize, 1, null, this, 0); //Construct an array large enough to hold all of the indices we'll need. Indices = _vertices.indices; envBilbList.Add(new EnvBilb(textures[6], textures[5], device, Content, scale)); foreach (EnvBilb pass in envBilbList) { pass.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData); pass.CreateBillboardVerticesFromList(); } /* envModelList.Add(new EnvModel(textures[6], model, device, Content, scale)); foreach (EnvModel pass1 in envModelList) { pass1.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData); pass1.CreateModelFromList(); } * */ effect.Parameters["xTexture0"].SetValue(textures[1]); effect.Parameters["xTexture1"].SetValue(textures[0]); effect.Parameters["xTexture2"].SetValue(textures[2]); effect.Parameters["xTexture3"].SetValue(textures[3]); effect.Parameters["xTexture5"].SetValue(textures[7]); Matrix worldMatrix = Matrix.Identity; effect.Parameters["xWorld"].SetValue(worldMatrix); effect.Parameters["xEnableLighting"].SetValue(true); effect.Parameters["xAmbient"].SetValue(light.Ambient); effect.Parameters["xLightPower"].SetValue(light.LightPower); effect.Parameters["Ground"].SetValue(textures[7]); effect.Parameters["GroundText0"].SetValue(textures[8]); effect.Parameters["GroundText1"].SetValue(textures[9]); effect.Parameters["GroundText2"].SetValue(textures[10]); _rootNode.EnforceMinimumDepth(); }
/// <summary> /// Create terrain at <paramref name="position"/> /// </summary> /// <param name="position"></param> /// <param name="textures"></param> /// <param name="device"></param> /// <param name="scale"></param> /// <param name="Content"></param> /// <param name="camera"></param> public QuadTree(Vector2 position, List<Texture2D> textures, GraphicsDevice device, int scale, ContentManager Content, GameCamera.FreeCamera camera) { light = new LightsAndShadows.Light(0.7f, 0.4f, new Vector3(513, 100, 513)); ViewFrustrum = new BoundingFrustum(camera.View * camera.Projection); this.textures = textures; effect = Content.Load<Effect>("Effects/MultiTextured"); Device = device; _topNodeSize = textures[15].Width - 1; _vertices = new MapRender(textures[15], scale, position); _buffers = new BufferManager(_vertices.Vertices, device); _rootNode = new QuadNode(NodeType.FullNode, _topNodeSize, 1, null, this, 0); //Construct an array large enough to hold all of the indices we'll need. Indices = _vertices.indices; envBilbList.Add(new EnvBilb(textures[19], textures[20], device, Content, scale)); envBilbList.Add(new EnvBilb(textures[17], textures[18], device, Content, scale)); foreach (EnvBilb pass in envBilbList) { pass.GenerateObjPositions(_vertices.TerrainLength2, _vertices.TerrainWidth2, _vertices.heightDataToControl); pass.CreateBillboardVerticesFromList(); } Matrix worldMatrix = Matrix.Identity; effect.Parameters["xWorld"].SetValue(worldMatrix); effect.Parameters["xEnableLighting"].SetValue(true); effect.Parameters["xAmbient"].SetValue(light.Ambient); effect.Parameters["xLightPower"].SetValue(light.LightPower); #region tekstury Alphy effect.Parameters["xTexture0"].SetValue(textures[0]); effect.Parameters["xTexture1"].SetValue(textures[1]); effect.Parameters["xTexture2"].SetValue(textures[2]); effect.Parameters["xTexture3"].SetValue(textures[3]); effect.Parameters["xTexture4"].SetValue(textures[4]); effect.Parameters["xTexture5"].SetValue(textures[5]); effect.Parameters["xTexture6"].SetValue(textures[6]); #endregion #region Tekstury Terenu effect.Parameters["xTexture7"].SetValue(textures[7]); effect.Parameters["xTexture8"].SetValue(textures[8]); effect.Parameters["xTexture9"].SetValue(textures[9]); effect.Parameters["xTexture10"].SetValue(textures[10]); effect.Parameters["xTexture11"].SetValue(textures[11]); effect.Parameters["xTexture12"].SetValue(textures[12]); effect.Parameters["xTexture13"].SetValue(textures[13]); effect.Parameters["xTexture14"].SetValue(textures[14]); #endregion #region Proj // effect.Parameters["xTexture14"].SetValue(textures[26]); #endregion MinimumDepth = 9; _rootNode.EnforceMinimumDepth(); MinimumDepth = 7; QuadNodeController.ustawione = true; _rootNode.EnforceMinimumDepth(); }