//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Engine.GameObjects { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using System.Xml; #endregion using DarkWynter.Engine.Globals; using DarkWynter.Engine.ObjectLib; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.Init; using DarkWynter.Stream; /// /// Large sphere surrounding the game world. /// Like a sky-box, except spherical to simulate true atmospheric visibility. /// public class SkySphere : GameObject { private string skyTexture; private string skyTextureBump; private float rotationScale = 10.0f; private float[] materialDiffuse = { 0.7f, 0.7f, 0.7f, 1.0f }; // Specular factor private float[] materialSpecular = { 0.0f, 0.0f, 0.0f, 1.0f }; /// /// Skysphere contrustor. /// public SkySphere(Load gameObjectLoader) : base(gameObjectLoader) { mass.gameObjectPointer = this; mass.objectType = Enums_Engine.ObjectType.SKYSPHERE; draw = new Draw(Enums_Stream.DrawMethod.BasicGameObject_Draw, "BasicLightingShaderMain"); } /// /// Override loading configurations for skysphere. /// /// Contains skyphere data /// The object library /// True if load was successful public override bool Load(ObjectLibrary objectLibrary) { //if (!base.load()) // return false; this.name = load.node.Attributes["name"].Value; try { skyTexture = load.node.Attributes["texture"].Value; skyTextureBump = load.node.Attributes["bumpTexture"].Value; } catch { System.Diagnostics.Debug.WriteLine("Error reading sky texture filename"); return false; } draw.textureList.Clear(); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load(skyTexture)); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load(skyTextureBump)); draw.model = Statics_Engine.SystemSettings.content.Load("Content/_models/skySphere"); // Apply our own advanced Effect to the Model foreach (ModelMesh mesh in draw.model.Meshes) { for (int i = 0; i < mesh.MeshParts.Count; i++) { // Add effect to mesh mesh.MeshParts[i].Effect = ShaderParameters.DrawFX.effect; } } mass.SetPosition(new Vector3(Statics_Engine.TerrainSettings.collisionMapSize / 2, 500, Statics_Engine.TerrainSettings.collisionMapSize / 2), new Vector3(Statics_Engine.TerrainSettings.collisionMapSize / 2, 500, Statics_Engine.TerrainSettings.collisionMapSize / 2 + 1)); mass.scale = new Vector3(1200); // mass.scale = new Vector3(2500); return true; } /// /// Update rotation on the skysphere. /// /// The object library public override void Update(ref ObjectLibrary objectLibrary) { Random rand = new Random(); //// Increment Rotation With dt mass.Rotate(0.00f, 0.01f); mass.SetPosition( Statics_Engine.PlayerSettings.playerPosition, Statics_Engine.PlayerSettings.playerPosition + Vector3.Forward); mass.scale = new Vector3(2000); } /// /// Override draw for skysphere. /// public override Draw Draw() { draw.matrix = Matrix.CreateScale(mass.scale) * Matrix.CreateFromQuaternion(mass.currentRotation) * Matrix.CreateTranslation(mass.currentPosition); return draw; } } }