/// <summary> /// Constructor. /// </summary> /// <param name="document">Scene document.</param> public SceneDocumentProxy(SceneDocument document) : base(document, null) { base.name = defaultName; this.document = document; this.environment = document.EditorScene.Environment; }
/// <summary> /// Creates a new Camera instance /// </summary> /// <param name = "aspectRatio">The viewport aspect ratio</param> protected Camera2D(float aspectRatio) { AspectRatio = aspectRatio; Distance = 1.0f; SceneState = new SceneState(); SceneEnvironment = new SceneEnvironment(); }
/// <summary> /// Creates a new Camera instance /// </summary> /// <param name = "aspectRatio">The viewport aspect ratio</param> /// <param name = "fieldOfView">The _instances of view expressed in radians</param> /// <param name = "nearPlaneDistance">The nearest point in projected space of the camera</param> /// <param name = "farPlaneDistance">The farest point in projected space of the camera</param> protected Camera3D(float aspectRatio, float fieldOfView, float nearPlaneDistance, float farPlaneDistance) { _aspectRatio = aspectRatio; _fieldOfView = fieldOfView; _nearPlaneDistance = nearPlaneDistance; _farPlaneDistance = farPlaneDistance; _isProjectionDirty = true; SceneState = new SceneState(); SceneEnvironment = new SceneEnvironment(); }
/// <summary> /// Creates a new Camera instance /// </summary> /// <param name = "aspectRatio">The viewport aspect ratio</param> /// <param name = "fieldOfView">The _instances of view expressed in radians</param> /// <param name = "nearPlaneDistance">The nearest point in projected space of the camera</param> /// <param name = "farPlaneDistance">The farest point in projected space of the camera</param> protected Camera3D(float aspectRatio, float fieldOfView, float nearPlaneDistance, float farPlaneDistance) { _aspectRatio = aspectRatio; _fieldOfView = fieldOfView; _nearPlaneDistance = nearPlaneDistance; _farPlaneDistance = farPlaneDistance; _isProjectionDirty = true; SceneState = new SceneState(); SceneEnvironment = new SceneEnvironment(); Application.Graphics.DeviceReset += (sender, args) => { _isProjectionDirty = true; }; }
/// <summary> /// Draws a dynamically generated skydome based on scene environment settings. /// </summary> private void DrawSkyDome() { // Get environment from scene SceneEnvironment environment = core.ActiveScene.Environment; // Get current cloud texture Texture2D cloudMap = cloudFactory.GetClouds(environment.CloudTime, environment.CloudBrightness); // Clear device to match bottom colour of sky dome graphicsDevice.Clear(environment.SkyGradientBottom); // Set render states //core.GraphicsDevice.DepthStencilState = DepthStencilState.None; // Draw sky dome mesh Matrix worldMatrix = Matrix.CreateTranslation(0, -0.2f, 0) * Matrix.CreateScale(10) * Matrix.CreateTranslation(core.ActiveScene.Camera.Position); foreach (ModelMesh mesh in skyDomeModel.Meshes) { foreach (Effect currentEffect in mesh.Effects) { currentEffect.CurrentTechnique = currentEffect.Techniques["SkyDome"]; currentEffect.Parameters["World"].SetValue(worldMatrix); currentEffect.Parameters["View"].SetValue(core.ActiveScene.Camera.ViewMatrix); currentEffect.Parameters["Projection"].SetValue(core.ActiveScene.Camera.ProjectionMatrix); currentEffect.Parameters["CloudTexture"].SetValue(cloudMap); currentEffect.Parameters["TopColor"].SetValue(environment.SkyGradientTop.ToVector4()); currentEffect.Parameters["BottomColor"].SetValue(environment.SkyGradientBottom.ToVector4()); //if (environment.SkyDomeStarsVisible) // currentEffect.Parameters["StarTexture"].SetValue(starFactory.StarMap); } mesh.Draw(); } // Reset render states //core.GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
/// <summary> /// /// </summary> protected override void UnloadContent() { mSceneInterface.Unload(); mLightingSystemManager.Unload(); mEnvironment = null; }
/// <summary> /// /// </summary> protected Game_cl() : base() { mGraphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Required for lighting system. Components.Add(new SplashScreenGameComponent(this, mGraphics)); // Create the lighting system. mLightingSystemManager = new LightingSystemManager(Services, Content); mSceneState = new SceneState(); mEnvironment = new SceneEnvironment(); mSceneInterface = new SceneInterface(mGraphics); mSceneInterface.CreateDefaultManagers(false); mSceneInterface.AddManager(new ObjectManager_cl()); // Create the sprite manager used to create and organize sprite containers for 2D rendering. mSpriteManager = new SpriteManager(mGraphics); mSceneInterface.AddManager(mSpriteManager); mFrameBuffers = new FrameBuffers(mGraphics, DetailPreference.Low, DetailPreference.Low); mSceneInterface.ResourceManager.AssignOwnership(mFrameBuffers); mStaticSceneEffects = new List<SceneEffect>(); //mView = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward, Vector3.Up); //mProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, GraphicsDevice.Viewport.AspectRatio, 0.1f, 1000f); mCameraEntity = new Entity_cl(); #if WORLD_EDITOR mWorldEditor = new WorldEditor_cl(); #endif mManagers = new List<BaseManager_cl>(); mRandom = new Random(); mTimer = new FNA.Core.Timer_cl(); mBaseInstance = this; mIsPlayingGame = true; }
/// <summary> /// Called when the program switches away from this screen /// and is where screen resources are disposed. /// </summary> public override void UnloadContent() { sceneInterface.Unload(); environment = null; contentRepository = null; }
/// <summary> /// Called when the program switches to the screen. This is /// where screen assets are loaded and resources are created. /// </summary> public override void LoadContent() { // Load the content repository, which stores all assets imported via the editor. // This must be loaded before any other assets. contentRepository = BaseGameProgram.Instance.ContentDatabase.Load<ContentRepository>("ContentRepository"); // Load the scene and add it to the managers. Scene scene = BaseGameProgram.Instance.ContentDatabase.Load<Scene>("Scene"); sceneInterface.Submit(scene); // Load the scene settings. environment = BaseGameProgram.Instance.ContentDatabase.Load<SceneEnvironment>("SceneEnvironment"); // Apply the user preferences (example - not required). sceneInterface.ApplyPreferences(BaseGameProgram.Instance.GetSystemPreferences()); }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here sceneInterface.Unload(); lightingSystemManager.Unload(); environment = null; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here // Add objects and lights to the ObjectManager and LightManager // respectively. The ObjectManager accepts objects in several forms: // // -As SceneObjects, which can be dynamic (movable) or static and are // created from XNA Models or custom vertex / index buffer. // // -As XNA Models, which can only be static. // voxelManager.AddVoxelType("Models/cobblestone", 10000); voxelManager.FinishInit(Content, GraphicsDevice, sceneInterface); //Window.Title = Window.Title + " - Instanced Object Count: " + (instancesPerContainerObject * containerObjects.Length); // LightRigs contain many lights and light groups. LightRig rig = new LightRig(); // Ambient lights uniformly illuminate the scene. AmbientLight ambientlight = new AmbientLight(); ambientlight.Enabled = true; ambientlight.DiffuseColor = new Vector3(0.8f, 0.98f, 0.99f); ambientlight.Intensity = 0.5f; // Directional lights illuminate the scene from a specific direction, similar to sunlight. DirectionalLight sunlight = new DirectionalLight(); sunlight.Enabled = true; sunlight.DiffuseColor = new Vector3(1.0f, 0.97f, 0.77f); sunlight.Intensity = 2.6f; sunlight.Direction = new Vector3(-0.60f, -0.73f, -0.32f); sunlight.ShadowType = ShadowType.AllObjects; sunlight.ShadowQuality = 1.0f; sunlight.ShadowPrimaryBias = 1.0f; sunlight.ShadowSecondaryBias = 0.04f; DirectionalLight sunlightB = new DirectionalLight(); sunlightB.Enabled = true; sunlightB.DiffuseColor = new Vector3(0.0f, 0.97f, 0.77f); sunlightB.Intensity = 2.6f; sunlightB.Direction = new Vector3(0.60f, -0.73f, -0.32f); sunlightB.ShadowType = ShadowType.AllObjects; sunlightB.ShadowQuality = 1.0f; sunlightB.ShadowPrimaryBias = 1.0f; sunlightB.ShadowSecondaryBias = 0.04f; // Add the lights to a group. LightGroup group = new LightGroup(); group.Add(ambientlight); group.Add(sunlight); group.Add(sunlightB); // Add the group to the light rig and commit the changes. rig.LightGroups.Add(group); rig.CommitChanges(); // Submit the light rig to the light manager. sceneInterface.LightManager.Submit(rig); // Setup the scene settings. environment = new SceneEnvironment(); environment.VisibleDistance = 250; environment.FogEnabled = true; environment.FogColor = new Vector3(0.5f, 0.5f, 0.5f); environment.FogStartDistance = 200; environment.FogEndDistance = 250; environment.ShadowFadeStartDistance = 200; environment.ShadowFadeEndDistance = 250; environment.ShadowCasterDistance = 250; // Apply the user preferences (example - not required). sceneInterface.ApplyPreferences(preferences); }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here // Cleanup any used resources. SceneInterface.Unload(); sunBurnCoreSystem.Unload(); environment = null; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); world = new WorldGeometry( new Rectangle( 0, 0, GraphicsDevice.Viewport.Width, 1)); collisionManager.RegisterCollisionBody(world); // Load the content repository, which stores all assets imported via the editor. // This must be loaded before any other assets. contentRepository = Content.Load<ContentRepository>("Content"); // Add objects and lights to the ObjectManager and LightManager. They accept // objects and lights in several forms: // // -As scenes containing both dynamic (movable) and static objects and lights. // // -As SceneObjects and lights, which can be dynamic or static, and // (in the case of objects) are created from XNA Models or custom vertex / index buffers. // // -As XNA Models, which can only be static. // // Load the scene and add it to the managers. Scene scene = Content.Load<Scene>("Scenes/Scene"); SceneInterface.Submit(scene); // Load the scene environment settings. environment = Content.Load<SceneEnvironment>("Environment/Environment"); // TODO: use this.Content to load your game content here character.Load(Content, SpriteManager, SceneInterface); world.Load(Content, SpriteManager, SceneInterface); }