Exemplo n.º 1
0
		public override void CreateViewports()
		{
			base.CreateViewports();

			viewport2 = window.AddViewport( camera2, 0.6f, 0, 0.4f, 0.4f, 102 );
			viewport2.ShowOverlays = false;
			viewport2.BackgroundColor = ColorEx.Blue;
		}
        /// <summary>
        ///		Adds an object to the collection.
        /// </summary>
        /// <param name="item"></param>
        public void Add(T item)
        {
            Debug.Assert(!objectList.ContainsKey(item.ZOrder), "A viewport with the specified ZOrder " + item.ZOrder + " already exists.");

            // assign this viewport to the parent RenderTarget
            item.Target = (P)parent;

            // add the viewport
            base.Add(item.ZOrder, item);
        }
Exemplo n.º 3
0
		public void OnLoad()
		{
			//ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true);

			_root.SceneManager = _sceneManager = _root.CreateSceneManager(SceneType.ExteriorClose);
			_sceneManager.ClearScene();

			_camera = _sceneManager.CreateCamera("MainCamera");

			_camera.Position = new Vector3(0, 0, 500);
			_camera.LookAt(new Vector3(0, 0, -300));
			_camera.Near = 5;
			_camera.AutoAspectRatio = true;
			_camera.FieldOfView = 0.70f;
			_viewport = _renderWindow.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100);
			_viewport.BackgroundColor = ColorEx.Black; ;

			_light = _sceneManager.CreateLight("light1");
			_light.Type = LightType.Directional;
			_light.Position = new Vector3(0, 150, 300);
			_light.Diffuse = ColorEx.Blue;
			_light.Specular = ColorEx.Blue;
			//_light.Direction = new Vector3(0, 0, -300);
			_sceneManager.AmbientLight = ColorEx.White;// new ColorEx(0.2f, 0.2f, 0.2f);

			ResourceGroupManager.Instance.InitializeAllResourceGroups();


			_inputReader = PlatformManager.Instance.CreateInputReader();
			_inputReader.Initialize(_renderWindow, true, true, false, false);

			_inputReader.UseKeyboardEvents = true;
			_inputReader.UseMouseEvents = false;

			//_renderItems.Add(new BasicCube());
			_renderItems.Add(new CubeBrowser());
			foreach (var i in _renderItems)
			{
				i.Initialise(_root);
			}
		}
Exemplo n.º 4
0
 protected virtual void FireViewportPreUpdate(Viewport viewport)
 {
     if (BeforeViewportUpdate != null)
     {
         BeforeViewportUpdate(new RenderTargetViewportEventArgs(this, viewport));
     }
 }
Exemplo n.º 5
0
 public RenderTargetViewportEventArgs(RenderTarget source, Viewport viewport)
     : base(source)
 {
     this.viewport = viewport;
 }
Exemplo n.º 6
0
        public virtual void UpdateViewport(Viewport viewport, bool updateStatistics)
        {
            Debug.Assert(viewport.Target == this,
                          "RenderTarget::_updateViewport the requested viewport is not bound to the rendertarget!");

            FireViewportPreUpdate(viewport);
            viewport.Update();
            if (updateStatistics)
            {
                stats.TriangleCount += viewport.RenderedFaceCount;
                stats.BatchCount += viewport.RenderedBatchCount;
            }
            FireViewportPostUpdate(viewport);
        }
Exemplo n.º 7
0
		public void ManualRender( RenderOperation op,
								  Pass pass,
								  Viewport vp,
								  Matrix4 worldMatrix,
								  Matrix4 viewMatrix,
								  Matrix4 projMatrix )
		{
			this.ManualRender( op, pass, vp, worldMatrix, viewMatrix, projMatrix, false );
		}
Exemplo n.º 8
0
		//---------------------------------------------------------------------
		protected override void PrepareShadowTextures( Camera cam, Viewport vp )
		{
			if ( ( (PCZSceneNode)cam.ParentSceneNode ) != null )
			{
				this.activeCameraZone = ( (PCZSceneNode)cam.ParentSceneNode ).HomeZone;
			}
			base.PrepareShadowTextures( cam, vp );
		}
Exemplo n.º 9
0
        public virtual Viewport AddViewport(Camera camera, float left, float top, float nwidth, float nheight, int zOrder)
        {
            if (ViewportList.ContainsKey(zOrder))
                throw new AxiomException("Can't create another viewport for {0} with Z-Order {1} because a viewport exists with this Z-Order already.", name, zOrder);

            // create a new camera and add it to our internal collection
            var viewport = new Viewport(camera, this, left, top, nwidth, nheight, zOrder);
            ViewportList.Add(viewport);

            FireViewportAdded(viewport);

            return viewport;
        }
Exemplo n.º 10
0
		public void NotifyViewport( Viewport viewport )
		{
			Viewport = viewport;
		}
 ///<summary>
 ///    Restore a viewport, the camera and the scene after a rendering operation
 ///</summary>
 protected void PostTargetOperation(CompositorTargetOperation op, Viewport vp, Camera cam)
 {
     SceneManager sm = cam.SceneManager;
     /// Unregister our listener
     sm.QueueStarted -= listener.OnRenderQueueStarted;
     sm.QueueEnded -= listener.OnRenderQueueEnded;
     /// Flush remaing operations
     listener.FlushUpTo(RenderQueueGroupID.Count);
     /// Restore default scene and camera settings
     sm.VisibilityMask = oldVisibilityMask;
     sm.FindVisibleObjectsBool = oldFindVisibleObjects;
     cam.LodBias = oldLodBias;
     vp.MaterialScheme = oldMaterialScheme;
 }
 ///<summary>
 ///    Prepare a viewport, the camera and the scene for a rendering operation
 ///</summary>
 protected void PreTargetOperation(CompositorTargetOperation op, Viewport vp, Camera cam)
 {
     SceneManager sm = cam.SceneManager;
     /// Set up render target listener
     listener.SetOperation(op, sm, sm.TargetRenderSystem);
     listener.NotifyViewport(vp);
     /// Register it
     sm.QueueStarted += listener.OnRenderQueueStarted;
     sm.QueueEnded += listener.OnRenderQueueEnded;
     /// Set visiblity mask
     oldVisibilityMask = sm.VisibilityMask;
     sm.VisibilityMask = op.VisibilityMask;
     /// Set whether we find visibles
     oldFindVisibleObjects = sm.FindVisibleObjectsBool;
     sm.FindVisibleObjectsBool = op.FindVisibleObjects;
     /// Set LOD bias level
     oldLodBias = cam.LodBias;
     cam.LodBias = cam.LodBias * op.LodBias;
     /// Set material scheme
     oldMaterialScheme = vp.MaterialScheme;
     vp.MaterialScheme = op.MaterialScheme;
     /// XXX TODO
     //vp->setClearEveryFrame( true );
     //vp->setOverlaysEnabled( false );
     //vp->setBackgroundColour( op.clearColour );
 }
 public CompositorChain(Viewport vp)
 {
     this.viewport = vp;
     originalScene = null;
     instances = new List<CompositorInstance>();
     dirty = true;
     anyCompositorsEnabled = false;
     compiledState = new List<CompositorTargetOperation>();
     outputOperation = null;
     oldClearEveryFrameBuffers = viewport.ClearBuffers;
     renderSystemOperations = new List<CompositorRenderSystemOperation>();
     listener = new RQListener();
     Debug.Assert(viewport != null);
 }
        ///<summary>
        ///    destroy internal resources
        ///</summary>
        protected void DestroyResources()
        {
            ClearCompiledState();

            if (viewport != null) {
                RemoveAllCompositors();
                viewport.Target.BeforeUpdate -= BeforeRenderTargetUpdate;
                // viewport.Target.AfterUpdate -= AfterRenderTargetUpdate;
                viewport.Target.BeforeViewportUpdate -= BeforeViewportUpdate;
                viewport.Target.AfterViewportUpdate -= AfterViewportUpdate;
                /// Destroy "original scene" compositor instance
                originalScene.Technique.DestroyInstance(originalScene);
                viewport = null;
            }
        }
 protected virtual void OnBeforeViewportUpdate(Viewport viewport)
 {
     if(BeforeViewportUpdate != null) {
         ViewportUpdateEventArgs e = new ViewportUpdateEventArgs();
         e.viewport = viewport;
         BeforeViewportUpdate(this, e);
     }
 }
        /// <summary>
        ///		Internal method for queueing the visible overlays for rendering.
        /// </summary>
        /// <param name="camera"></param>
        /// <param name="queue"></param>
        /// <param name="viewport"></param>
        internal void QueueOverlaysForRendering(Camera camera, RenderQueue queue, Viewport viewport)
        {
            // Flag for update pixel-based OverlayElements if viewport has changed dimensions
            if(lastViewportWidth != viewport.ActualWidth ||
                lastViewportHeight != viewport.ActualHeight) {

                viewportDimensionsChanged = true;
                lastViewportWidth = viewport.ActualWidth;
                lastViewportHeight = viewport.ActualHeight;
            }
            else {
                viewportDimensionsChanged = false;
            }

            // TODO: optimize this resource list to avoid the foreach
            foreach(Overlay overlay in resourceList.Values) {
                overlay.FindVisibleObjects(camera, queue);
            }
        }
Exemplo n.º 17
0
		// Overridden from SceneManager
		public new void RenderScene( Camera cam, Viewport vp, bool includeOverlays )
		{
			// notify all the zones that a scene render is starting
			foreach ( PCZone zone in this.zones )
			{
				zone.NotifyBeginRenderScene();
			}

			// do the regular _renderScene
			base.RenderScene( cam, vp, includeOverlays );
		}
Exemplo n.º 18
0
 protected virtual void FireViewportPostUpdate(Viewport viewport)
 {
     if (AfterViewportUpdate != null)
     {
         AfterViewportUpdate(new RenderTargetViewportEventArgs(this, viewport));
     }
 }
 ///<summary>
 ///    Notify current destination viewport
 ///</summary>
 public void NotifyViewport(Viewport vp)
 {
     viewport = vp;
 }
Exemplo n.º 20
0
 protected virtual void FireViewportRemoved(Viewport viewport)
 {
     if (ViewportRemoved != null)
     {
         ViewportRemoved(new RenderTargetViewportEventArgs(this, viewport));
     }
 }
Exemplo n.º 21
0
		/// <summary>
		///		Prompts the class to send its contents to the renderer.
		/// </summary>
		/// <remarks>
		///		This method prompts the scene manager to send the
		///		contents of the scene it manages to the rendering
		///		pipeline, possibly preceded by some sorting, culling
		///		or other scene management tasks. Note that this method is not normally called
		///		directly by the user application; it is called automatically
		///		by the engine's rendering loop.
		/// </remarks>
		/// <param name="camera">Pointer to a camera from whose viewpoint the scene is to be rendered.</param>
		/// <param name="viewport">The target viewport</param>
		/// <param name="showOverlays">Whether or not any overlay objects should be rendered</param>
		protected internal void RenderScene( Camera camera, Viewport viewport, bool showOverlays )
		{
			// let the engine know this is the current scene manager
			Root.Instance.SceneManager = this;

			if ( this.IsShadowTechniqueInUse )
			{
				// initialize shadow volume materials
				this.InitShadowVolumeMaterials();
			}

			// Perform a quick pre-check to see whether we should override far distance
			// When using stencil volumes we have to use infinite far distance
			// to prevent dark caps getting clipped
			if ( this.IsShadowTechniqueStencilBased &&
				 camera.Far != 0 &&
				 this.targetRenderSystem.Capabilities.HasCapability( Capabilities.InfiniteFarPlane ) &&
				 this.shadowUseInfiniteFarPlane )
			{
				// infinite far distance
				camera.Far = 0.0f;
			}

			this.cameraInProgress = camera;
			this.hasCameraChanged = true;

			// Update the scene, only do this once per frame
			ulong thisFrameNumber = Root.Instance.CurrentFrameCount;
			if ( thisFrameNumber != this.lastFrameNumber )
			{
				// Update animations
				this.ApplySceneAnimations();
				// Update controllers
				ControllerManager.Instance.UpdateAll();
				this.lastFrameNumber = thisFrameNumber;
			}

			// Update scene graph for this camera (can happen multiple times per frame)
			this.UpdateSceneGraph( camera );

			// Auto-track nodes
			foreach ( SceneNode sn in autoTrackingSceneNodes.Values )
			{
				sn.AutoTrack();
			}

			// ask the camera to auto track if it has a target
			camera.AutoTrack();

			// Are we using any shadows at all?
			if ( this.IsShadowTechniqueInUse && this.illuminationStage != IlluminationRenderStage.RenderToTexture &&
				 viewport.ShowShadows && this.findVisibleObjects )
			{
				// Locate any lights which could be affecting the frustum
				this.FindLightsAffectingFrustum( camera );

				if ( this.IsShadowTechniqueTextureBased )
				{
					// *******
					// WARNING
					// *******
					// This call will result in re-entrant calls to this method
					// therefore anything which comes before this is NOT
					// guaranteed persistent. Make sure that anything which
					// MUST be specific to this camera / target is done
					// AFTER THIS POINT
					this.PrepareShadowTextures( camera, viewport );
					// reset the cameras because of the re-entrant call
					this.cameraInProgress = camera;
					this.hasCameraChanged = true;
				}
			}

			// Invert vertex winding?
			this.targetRenderSystem.InvertVertexWinding = camera.IsReflected;

			// Tell params about viewport
			this.autoParamDataSource.Viewport = viewport;
			// Set the viewport
			this.SetViewport( viewport );

			// set the current camera for use in the auto GPU program params
			this.autoParamDataSource.Camera = camera;

			// Set autoparams for finite dir light extrusion
			this.autoParamDataSource.SetShadowDirLightExtrusionDistance( this.shadowDirLightExtrudeDist );

			// sets the current ambient light color for use in auto GPU program params
			this.autoParamDataSource.AmbientLight = this.ambientColor;
			// Tell rendersystem
			this.targetRenderSystem.AmbientLight = this.ambientColor;

			// Tell params about render target
			this.autoParamDataSource.RenderTarget = viewport.Target;

			// set fog params
			float fogScale = 1f;
			if ( this.fogMode == FogMode.None )
			{
				fogScale = 0f;
			}
			this.autoParamDataSource.FogParams = new Vector4( this.fogStart, this.fogEnd, fogScale, 0 );

			// set the time in the auto param data source
			//autoParamDataSource.Time = ((float)Root.Instance.Timer.Milliseconds) / 1000f;

			// Set camera window clipping planes (if any)
			if ( this.targetRenderSystem.Capabilities.HasCapability( Capabilities.UserClipPlanes ) )
			{
				// TODO: Add ClipPlanes to RenderSystem.cs
				if ( camera.IsWindowSet )
				{
				    targetRenderSystem.ResetClipPlanes();
					IList<Plane> planeList = camera.WindowPlanes;
					for ( ushort i = 0; i < 4; ++i )
					{
					    targetRenderSystem.AddClipPlane( planeList[ i ] );

						//this.targetRenderSystem.EnableClipPlane( i, true );
						//this.targetRenderSystem.SetClipPlane( i, planeList[ i ] );
					}
				}
				// this disables any user-set clipplanes... this should be done manually
				//else
				//{
				//    for (ushort i = 0; i < 4; ++i)
				//    {
				//        targetRenderSystem.EnableClipPlane(i, false);
				//    }
				//}
			}

			// Prepare render queue for receiving new objects
			this.PrepareRenderQueue();

			// Parse the scene and tag visibles
			if ( this.findVisibleObjects )
			{
				if ( this.PreFindVisibleObjects != null )
					PreFindVisibleObjects( this, this.illuminationStage, viewport );
				this.FindVisibleObjects( camera, this.illuminationStage == IlluminationRenderStage.RenderToTexture );
				if ( this.PostFindVisibleObjects != null )
					PostFindVisibleObjects( this, this.illuminationStage, viewport );
			}

			// Add overlays, if viewport deems it
			if ( viewport.ShowOverlays && this.illuminationStage != IlluminationRenderStage.RenderToTexture )
			{
				// Queue overlays for rendering
				OverlayManager.Instance.QueueOverlaysForRendering( camera, this.GetRenderQueue(), viewport );
			}

			// queue overlays and skyboxes for rendering
			if ( viewport.ShowSkies && this.findVisibleObjects &&
				 this.illuminationStage != IlluminationRenderStage.RenderToTexture )
			{
				this.QueueSkiesForRendering( camera );
			}

			// begin frame geometry count
			this.targetRenderSystem.BeginGeometryCount();

			// clear the device if need be
			if ( viewport.ClearEveryFrame )
			{
				this.targetRenderSystem.ClearFrameBuffer( viewport.ClearBuffers, viewport.BackgroundColor );
			}

			// being a frame of animation
			this.targetRenderSystem.BeginFrame();

			// use the camera's current scene detail level
			this.targetRenderSystem.PolygonMode = camera.PolygonMode;

			// Set initial camera state
			this.targetRenderSystem.ProjectionMatrix = camera.ProjectionMatrixRS;
			this.targetRenderSystem.ViewMatrix = camera.ViewMatrix;

			// render all visible objects
			this.RenderVisibleObjects();

			// end the current frame
			this.targetRenderSystem.EndFrame();

			// Notify camera of the number of rendered faces
			camera.NotifyRenderedFaces( this.targetRenderSystem.FaceCount );

			// Notify camera of the number of rendered batches
			camera.NotifyRenderedBatches( this.targetRenderSystem.BatchCount );
		}
Exemplo n.º 22
0
		/// <summary>
		/// 
		/// </summary>
		protected override void SetupView()
		{
			// setup default viewport layout and camera
			this.Camera = SceneManager.CreateCamera( "MainCamera" );
			this.Viewport = Window.AddViewport( this.Camera );
			this.Camera.AspectRatio = (Real)this.Viewport.ActualWidth / (Real)this.Viewport.ActualHeight;
			this.Camera.Near = 5;

			this.CameraManager = new SdkCameraManager( this.Camera );   // create a default camera controller
		}
Exemplo n.º 23
0
		/// <summary>
		///		Internal method for setting the destination viewport for the next render.
		/// </summary>
		/// <param name="viewport"></param>
		protected virtual void SetViewport( Viewport viewport )
		{
			this.currentViewport = viewport;
			// Set viewport in render system
			this.targetRenderSystem.Viewport = viewport;
			// Set the active material scheme for this viewport
			MaterialManager.Instance.ActiveScheme = viewport.MaterialScheme;
		}
Exemplo n.º 24
0
		/// <summary>
		///		Called to ask a camera to render the scene into the given viewport.
		/// </summary>
		/// <param name="viewport"></param>
		/// <param name="showOverlays"></param>
		internal void RenderScene( Viewport viewport, bool showOverlays )
		{
			if ( CameraPreRenderScene != null )
			{
				CameraPreRenderScene( new CameraEventArgs( this ) );
			}

			SceneManager.RenderScene( this, viewport, showOverlays );

			if ( CameraPostRenderScene != null )
			{
				CameraPostRenderScene( new CameraEventArgs( this ) );
			}
		}
 protected virtual void OnAfterViewportUpdate(Viewport viewport)
 {
     if(AfterViewportUpdate != null) {
         ViewportUpdateEventArgs e = new ViewportUpdateEventArgs();
         e.viewport = viewport;
         AfterViewportUpdate(this, e);
     }
 }
Exemplo n.º 26
0
		/// <summary>
		///		Manual rendering method, for advanced users only.
		/// </summary>
		/// <remarks>
		///		This method allows you to send rendering commands through the pipeline on
		///		demand, bypassing any normal world processing. You should only use this if you
		///		really know what you're doing; the engine does lots of things for you that you really should
		///		let it do. However, there are times where it may be useful to have this manual interface,
		///		for example overlaying something on top of the scene.
		///		<p/>
		///		Because this is an instant rendering method, timing is important. The best
		///		time to call it is from a RenderTarget event handler.
		///		<p/>
		///		Don't call this method a lot, it's designed for rare (1 or 2 times per frame) use.
		///		Calling it regularly per frame will cause frame rate drops!
		/// </remarks>
		/// <param name="op">A RenderOperation object describing the rendering op.</param>
		/// <param name="pass">The Pass to use for this render.</param>
		/// <param name="vp">Reference to the viewport to render to.</param>
		/// <param name="worldMatrix">The transform to apply from object to world space.</param>
		/// <param name="viewMatrix">The transform to apply from object to view space.</param>
		/// <param name="projMatrix">The transform to apply from view to screen space.</param>
		/// <param name="doBeginEndFrame">
		///		If true, BeginFrame() and EndFrame() are called, otherwise not.
		///		You should leave this as false if you are calling this within the main render loop.
		/// </param>
		public virtual void ManualRender( RenderOperation op,
										  Pass pass,
										  Viewport vp,
										  Matrix4 worldMatrix,
										  Matrix4 viewMatrix,
										  Matrix4 projMatrix,
										  bool doBeginEndFrame )
		{
			// configure all necessary parameters
			this.targetRenderSystem.Viewport = vp;
			this.targetRenderSystem.WorldMatrix = worldMatrix;
			this.targetRenderSystem.ViewMatrix = viewMatrix;
			this.targetRenderSystem.ProjectionMatrix = projMatrix;

			if ( doBeginEndFrame )
			{
				this.targetRenderSystem.BeginFrame();
			}

			// set the pass and render the object
			this.SetPass( pass );
			this.targetRenderSystem.Render( op );

			if ( doBeginEndFrame )
			{
				this.targetRenderSystem.EndFrame();
			}
		}
Exemplo n.º 27
0
		public override void SetViewport( Viewport viewport )
		{
			if ( viewport != activeViewport || viewport.IsUpdated )
			{
				RenderTarget target = viewport.Target;
				SetRenderTarget( target );
				activeViewport = viewport;

				int x, y, w, h;
				w = viewport.ActualWidth;
				h = viewport.ActualHeight;
				x = viewport.ActualLeft;
				y = viewport.ActualTop;

				if ( !target.RequiresTextureFlipping )
				{
					// Convert "upper-left" corner to "lower-left"
					y = target.Height - h - y;
				}

				OpenGL.Viewport( x, y, w, h );
				GLESConfig.GlCheckError( this );
				// Configure the viewport clipping
				OpenGL.Scissor( x, y, w, h );
				GLESConfig.GlCheckError( this );
				viewport.IsUpdated = false;

			}
		}
Exemplo n.º 28
0
		/// <summary>
		/// Internal method for preparing shadow textures ready for use in a regular render
		/// </summary>
		/// <param name="camera"></param>
		/// <param name="viewPort"></param>
		protected internal virtual void PrepareShadowTextures( Camera camera, Viewport viewPort )
		{
			// Set the illumination stage, prevents recursive calls
			IlluminationRenderStage savedStage = this.illuminationStage;
			this.illuminationStage = IlluminationRenderStage.RenderToTexture;

			// Determine far shadow distance
			float shadowDist = this.shadowFarDistance;
			if ( shadowDist == 0.0f )
			{
				// need a shadow distance, make one up
				shadowDist = camera.Near * 300;
			}
			// set fogging to hide the shadow edge
			float shadowOffset = shadowDist * this.shadowTextureOffset;
			// Precalculate fading info
			float shadowEnd = shadowDist + shadowOffset;
			float fadeStart = shadowEnd * this.shadowTextureFadeStart;
			float fadeEnd = shadowEnd * this.shadowTextureFadeEnd;
			// Additive lighting should not use fogging, since it will overbrighten; use border clamp
			if ( !this.IsShadowTechniqueAdditive )
			{
				this.shadowReceiverPass.SetFog( true,
												FogMode.Linear,
												ColorEx.White,
												0,
												fadeStart,
												fadeEnd );
				// if we have a custom receiver material, then give it the fog params too
				if ( this.shadowTextureCustomReceiverPass != null )
				{
					this.shadowTextureCustomReceiverPass.SetFog( true,
																 FogMode.Linear,
																 ColorEx.White,
																 0,
																 fadeStart,
																 fadeEnd );
				}
			}
			else
			{
				// disable fogging explicitly
				this.shadowReceiverPass.SetFog( true, FogMode.None );
				// if we have a custom receiver material, then give it the fog params too
				if ( this.shadowTextureCustomReceiverPass != null )
				{
					this.shadowTextureCustomReceiverPass.SetFog( true, FogMode.None );
				}
			}

			// Iterate over the lights we've found, max out at the limit of light textures
			int sti = 0;
			foreach ( Light light in this.lightsAffectingFrustum )
			{
				// Check limit reached
				if ( sti == this.shadowTextures.Count )
					break;

				// Skip non-shadowing lights
				if ( !light.CastShadows )
				{
					continue;
				}

				Texture shadowTex = this.shadowTextures[ sti ];
				RenderTarget shadowRTT = shadowTex.GetBuffer().GetRenderTarget();
				Viewport shadowView = shadowRTT.GetViewport( 0 );
				Camera texCam = this.shadowTextureCameras[ sti ];

				// rebind camera, incase another SM in use which has switched to its cam
				shadowView.Camera = texCam;

				// Associate main view camera as LOD camera
				texCam.LodCamera = camera;

				//Vector3 dir;

				// set base
				if ( light.Type == LightType.Point )
					texCam.Direction = light.DerivedDirection;
				if ( light.Type == LightType.Directional )
					texCam.Position = light.DerivedPosition;

				// Use the material scheme of the main viewport
				// This is required to pick up the correct shadow_caster_material and similar properties.
				shadowView.MaterialScheme = viewPort.MaterialScheme;

				if ( light.CustomShadowCameraSetup == null )
				{
					_defaultShadowCameraSetup.GetShadowCamera( this, camera, viewPort, light, texCam, sti );
				}
				else
				{
					light.CustomShadowCameraSetup.GetShadowCamera( this, camera, viewPort, light, texCam, sti );
				}

				shadowView.BackgroundColor = ColorEx.White;

				// Fire shadow caster update, callee can alter camera settings
				// fireShadowTexturesPreCaster(light, texCam);

				// Update target
				shadowRTT.Update();

				++sti;
			}
			// Set the illumination stage, prevents recursive calls
			this.illuminationStage = savedStage;

			//fireShadowTexturesUpdated( std::min(mLightsAffectingFrustum.size(), mShadowTextures.size()));
		}
Exemplo n.º 29
0
			public void SetViewport( Viewport viewport )
			{
				vpWidth = viewport.ActualWidth;
				vpHeight = viewport.ActualHeight;
			}
        protected virtual void CreateViewports()
        {
            Debug.Assert(window != null, "Attempting to use a null RenderWindow.");

            // create a new viewport and set it's background color
            viewport = window.AddViewport(camera, 0, 0, 1.0f, 1.0f, 100);
            viewport.BackgroundColor = ColorEx.Black;
        }
        protected override void CreateViewports()
        {
            base.CreateViewports();

            viewport2 = window.AddViewport(camera2, 0.6f, 0, 0.4f, 0.4f, 102);
            viewport2.OverlaysEnabled = false;
            viewport2.BackgroundColor = ColorEx.Blue;
        }