public void Draw(GraphicsDevice graphicsDevice, Camera camera) { if (this.isWater) { this.top.Draw(graphicsDevice, camera); this.right.Draw(graphicsDevice, camera); this.front.Draw(graphicsDevice, camera); this.left.Draw(graphicsDevice, camera); this.back.Draw(graphicsDevice, camera); this.bottom.Draw(graphicsDevice, camera); } if (!this.isWater) { //if (leftBlock.depth == 0) // leftBlock.Draw(View, Projection, graphicsDevice); //else { topBlock.Draw(graphicsDevice, camera); leftBlock.Draw(graphicsDevice, camera); rightBlock.Draw(graphicsDevice, camera); frontBlock.Draw(graphicsDevice, camera); backBlock.Draw(graphicsDevice, camera); bottomBlock.Draw(graphicsDevice, camera); } } if (water != null) this.water.Draw(graphicsDevice, camera); }
public void Draw(GraphicsDevice graphicsDevice, Camera camera) { for (int x = 0; x < BlockRes; x++) for (int y = 0; y < BlockRes; y++) if (children[x, y] != null) children[x, y].Draw(graphicsDevice, camera); else if (terrain[x, y] != null) terrain[x, y].Draw(graphicsDevice, camera); }
public void Draw(GraphicsDevice graphicsDevice, Camera camera) { BoundingFrustum Frustum = (new BoundingFrustum(camera.View * camera.Projection)); if (Frustum.Contains(this.boundingBox) == ContainmentType.Disjoint && !Frustum.Intersects(this.boundingBox)) return; else if (type == Type.CubeFace && waterSphere.Contains(this.boundingBox) == ContainmentType.Contains) return; PersistantRot = Matrix.Identity; PersistantRot *= Matrix.CreateFromAxisAngle(Matrix.Identity.Right, MathHelper.ToRadians(GlobalRot.X)); PersistantRot *= Matrix.CreateFromAxisAngle(Matrix.Identity.Up, MathHelper.ToRadians(GlobalRot.Y)); PersistantRot *= Matrix.CreateFromAxisAngle(Matrix.Identity.Backward, MathHelper.ToRadians(GlobalRot.Z)); PersistantRot *= Matrix.CreateFromAxisAngle(Matrix.Identity.Up, MathHelper.ToRadians(GlobalRot.W)); Matrix baseWorld = Matrix.CreateScale(1.0f); baseWorld *= PersistantRot; baseWorld *= Matrix.CreateTranslation(Position); if (type == Type.CubeFace) { Vector3 a = this.vertices[nVertices / 2].Position; a = Vector3.Transform(a, baseWorld); Vector3 b = (camera is ArcBallCamera) ? (camera as ArcBallCamera).Position : (camera as ChaseCamera).FollowTargetPosition; float angle = (float)GetAngle(a, b); if (angle > 90) return; } //effect.Parameters["BaseTexture"].SetValue(baseTexture); //effect.Parameters["RTexture"].SetValue(redTexture); //effect.Parameters["GTexture"].SetValue(greenTexture); //effect.Parameters["WeightMap"].SetValue(weightTexture); //effect.Parameters["TextureTiling"].SetValue(textureTiling); //effect.Parameters["LightPosition"].SetValue(LightPosition); //if (effect.Parameters["BasicTexture"] != null) // effect.Parameters["BasicTexture"].SetValue(baseTexture); effect.Parameters["World"].SetValue(baseWorld); effect.Parameters["View"].SetValue(camera.View); effect.Parameters["Projection"].SetValue(camera.Projection); //effect.Parameters["BasicTexture"].SetValue(baseTexture); //effect.Parameters["TextureEnabled"].SetValue(true); /*if (vertexBuffer == null) { vertexBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionNormalTexture), nVertices, BufferUsage.WriteOnly); vertexBuffer.SetData<VertexPositionNormalTexture>(vertices); } if (indexBuffer == null) { indexBuffer = new IndexBuffer(graphicsDevice, IndexElementSize.ThirtyTwoBits, nIndices, BufferUsage.WriteOnly); indexBuffer.SetData<int>(indices); }*/ foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, nVertices, indices, 0, nIndices / 3); } }