Example #1
0
        public LensFlare(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Texture2D glowSprite, Texture2D[] flareSprites)
        {
            if (graphicsDevice == null) throw new ArgumentNullException("graphicsDevice");
            if (spriteBatch == null) throw new ArgumentNullException("spriteBatch");
            if (glowSprite == null) throw new ArgumentNullException("glowSprite");
            if (flareSprites == null) throw new ArgumentNullException("flareSprites");

            Enabled = true;

            this.graphicsDevice = graphicsDevice;
            this.spriteBatch = spriteBatch;
            this.glowSprite = glowSprite;

            for (int i = 0; i < flares.Length; i++)
            {
                var index = flares[i].TextureIndex;
                if (index < 0 || flareSprites.Length <= index)
                    throw new InvalidOperationException("Invalid index of flare sprite: " + index);

                flares[i].Texture = flareSprites[index];
            }

            basicEffect = new BasicEffect(graphicsDevice);
            basicEffect.View = Matrix.Identity;
            basicEffect.VertexColorEnabled = true;

            queryVertices = new VertexPositionColor[4];
            queryVertices[0].Position = new Vector3(-querySize / 2, -querySize / 2, -1);
            queryVertices[1].Position = new Vector3( querySize / 2, -querySize / 2, -1);
            queryVertices[2].Position = new Vector3(-querySize / 2,  querySize / 2, -1);
            queryVertices[3].Position = new Vector3( querySize / 2,  querySize / 2, -1);

            occlusionQuery = new OcclusionQuery(graphicsDevice);
        }
Example #2
0
        public ChunkMesh(string name, ChunkEffect chunkEffect)
            : base(name)
        {
            if (chunkEffect == null) throw new ArgumentNullException("chunkEffect");

            this.chunkEffect = chunkEffect;
            this.graphicsDevice = chunkEffect.GraphicsDevice;

            occlusionQuery = new OcclusionQuery(graphicsDevice);
        }
Example #3
0
        public void MismatchedBeginEnd()
        {
            Game.DrawWith += (sender, e) =>
            {
                var occlusionQuery = new OcclusionQuery(Game.GraphicsDevice);

                Assert.Throws<InvalidOperationException>(() => occlusionQuery.End());

                occlusionQuery.Begin();
                Assert.Throws<InvalidOperationException>(() => occlusionQuery.Begin());
            };
            Game.Run();
        }
Example #4
0
        public void ConstructorsAndProperties()
        {
            Game.DrawWith += (sender, e) =>
            {
                Assert.Throws<ArgumentNullException>(() => new OcclusionQuery(null));

                var occlusionQuery = new OcclusionQuery(Game.GraphicsDevice);

                Assert.IsFalse(occlusionQuery.IsComplete);

                Assert.Throws<InvalidOperationException>(
                    () => { var n = occlusionQuery.PixelCount; },
                    "PixelCount throws when query not yet started.");
            };
            Game.Run();
        }
Example #5
0
        public LensFlareComponent(SpriteBatch sprite, ContentManager cont, GraphicsDevice device)
        {
            this.spriteBatch = sprite;
            glowSprite = cont.Load<Texture2D>("Textures/glow");

            foreach (Flare flare in flares)
            {
                flare.Texture = cont.Load<Texture2D>("Textures/" + flare.TextureName);
            }

            basicEffect = new BasicEffect(device);

            basicEffect.View = Matrix.Identity;
            basicEffect.VertexColorEnabled = true;

            queryVertices = new VertexPositionColor[4];

            queryVertices[0].Position = new Vector3(-querySize / 2, -querySize / 2, -1);
            queryVertices[1].Position = new Vector3(querySize / 2, -querySize / 2, -1);
            queryVertices[2].Position = new Vector3(-querySize / 2, querySize / 2, -1);
            queryVertices[3].Position = new Vector3(querySize / 2, querySize / 2, -1);

            occlusionQuery = new OcclusionQuery(device);
        }
		/// <summary>
		///		Default constructor.
		/// </summary>
		/// <param name="device">Reference to a Direct3D device.</param>
		public XnaHardwareOcclusionQuery( XFG.GraphicsDevice device )
		{
			this.device = device;
			oQuery = new XFG.OcclusionQuery( device );
		}
Example #7
0
        public void LoadContent(GraphicsDevice graphics, ContentManager content)
        {
            sphere = content.Load<Model>("Models\\sphere");

            occlusionQuery = new OcclusionQuery(graphics);
            starEffect = content.Load<Effect>("Planets\\Star");
            glowSprite = content.Load<Texture2D>("Textures\\glow");
            spriteBatch = new SpriteBatch(graphics);
            this.graphics = graphics;

            foreach (Flare flare in flares) {
                flare.Texture = content.Load<Texture2D>("Textures\\" + flare.TextureName);
            }
        }
Example #8
0
		public void LoadContent(GraphicsDevice graphics, ContentManager content)
		{
			sphere = content.Load<Model>("Models\\sphere");
			sunTexture = content.Load<TextureCube>("Textures\\SkyBox\\SunTexture");
			sunLayerTexture0 = content.Load<TextureCube>("Textures\\SkyBox\\SunLayer0");
			sunLayerTexture1 = content.Load<TextureCube>("Textures\\SkyBox\\SunLayer1");
			gradientTexture = content.Load<Texture2D>("Textures\\Planet\\FireGradient");
			occlusionQuery = new OcclusionQuery(graphics);
			sunEffect = content.Load<Effect>("Planets\\SunEffect");
			sunLayerEffect = content.Load<Effect>("Planets\\SunLayerEffect");
			extractHDREffect = content.Load<Effect>("Planets\\ExtractHDREffect");

			linearFilter = content.Load<Effect>("Planets\\LinearFilter");
			gaussianFilter = content.Load<Effect>("Planets\\GaussianFilter");
			/*glowSprite = content.Load<Texture2D>("Textures\\glow");
			spriteBatch = new SpriteBatch(graphics);
			
			foreach (Flare flare in flares) {
				flare.Texture = content.Load<Texture2D>("Textures\\" + flare.TextureName);
			}*/
			b1 = new BillboardSystem(graphicsDevice, content, null, new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Vector3[] { Position });
			b2 = new BillboardSystem(graphicsDevice, content, null, new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), new Vector3[] { Position });

			basicEffect = new BasicEffect(graphicsDevice) {
				TextureEnabled = true,
				VertexColorEnabled = true,
			};

			SetupRenderTargets();
		}
		/// <summary>
		/// Draw the predicate, and if the predicate draws at least <see cref="MinimumPixelCount"/> pixels, the 'complex' object will be drawn
		/// </summary>
		/// <param name="state"></param>
		public void Draw(DrawState state)
		{
			int frame = state.Properties.FrameIndex;

			if (!supported || frame == frameIndex)
			{
				if (item.CullTest(state))
					item.Draw(state);
				return;
			}

			if (resetOnCullChange && frameIndex != frame - 1)
			{
				//XNA requires IsComplete to be checked.
				if (query != null)
					queryInProgress = query.IsComplete;

				queryInProgress = false;//reset the query
				queryPixelCount = ushort.MaxValue;
			}

			if (queryInProgress && query.IsComplete)
			{
				queryInProgress = false;
				this.queryPixelCount = (ushort)query.PixelCount;
			}

			if (!queryInProgress)
			{
				GraphicsDevice device = (GraphicsDevice)state;

				//run the query
				if (query == null)
				{
					query = new OcclusionQuery(device);
				}

				query.Begin();

				state.RenderState.Push();

				state.RenderState.CurrentDepthState.DepthWriteEnabled = false;
				state.RenderState.CurrentRasterState.ColourWriteMask = ColorWriteChannels.None;
				state.RenderState.CurrentBlendState = new AlphaBlendState();

				predicate.Draw(state);

				state.RenderState.Pop();

				query.End();

				queryInProgress = true;
			}

			frameIndex = frame;

			if (queryPixelCount >= pixelCount && item.CullTest(state))
				item.Draw(state);
		}
		/// <summary>
		/// Dispose the <see cref="OcclusionQuery"/>
		/// </summary>
		public void Dispose()
		{
			if (query != null)
				query.Dispose();
			query = null;
		}
Example #11
0
            public int VisiblePixels; // The number of visible pixels.

            #endregion Fields

            #region Methods

            public void Dispose()
            {
                if (OcclusionQuery != null)
                {
                  OcclusionQuery.Dispose();
                  OcclusionQuery = null;
                  TotalPixels = 0;
                  VisiblePixels = 0;
                }
            }
Example #12
0
        public void QueryOccludedSprites()
        {
            SpriteBatch spriteBatch = null;
            Texture2D whiteTexture = null;
            OcclusionQuery occlusionQuery = null;

            int state = 0;
            int queryFrameCount = 0;

            Game.LoadContentWith += (sender, e) =>
            {
                spriteBatch = new SpriteBatch(Game.GraphicsDevice);
                whiteTexture = Game.Content.Load<Texture2D>(Paths.Texture("white-64"));
            };

            Game.DrawWith += (sender, e) =>
            {
                if (occlusionQuery == null)
                    occlusionQuery = new OcclusionQuery(Game.GraphicsDevice);

                Game.GraphicsDevice.Clear(Color.CornflowerBlue);

                // White rectangle at depth 0.
                spriteBatch.Begin(SpriteSortMode.Immediate, null, null, DepthStencilState.Default, null);
                spriteBatch.Draw(whiteTexture, new Rectangle(100, 100, 100, 100), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
                spriteBatch.End();

                if (state == 0)
                {
                    // Make query with red rectangle, 50% occluded.
                    occlusionQuery.Begin();
                    spriteBatch.Begin(SpriteSortMode.Immediate, null, null, DepthStencilState.Default, null);
                    spriteBatch.Draw(whiteTexture, new Rectangle(50, 100, 100, 100), null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, 1);
                    spriteBatch.End();
                    occlusionQuery.End();
                    state = 1;
                    queryFrameCount = 0;
                }
                else if (state == 1)
                {
                    queryFrameCount++;

                    if (queryFrameCount > 5)
                        Assert.Fail("Occlusion query did not complete.");

                    if (occlusionQuery.IsComplete)
                    {
                        Assert.AreEqual(100 * 100 / 2, occlusionQuery.PixelCount);
                        state = 2;
                    }
                }
                else if (state == 2)
                {
                    // Same results as last frame.
                    Assert.IsTrue(occlusionQuery.IsComplete);
                    Assert.AreEqual(100 * 100 / 2, occlusionQuery.PixelCount);

                    // Reuse query a second time, 10% occlusion.
                    occlusionQuery.Begin();
                    spriteBatch.Begin(SpriteSortMode.Immediate, null, null, DepthStencilState.Default, null);
                    spriteBatch.Draw(whiteTexture, new Rectangle(10, 100, 100, 100), null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, 1);
                    spriteBatch.End();
                    occlusionQuery.End();
                    state = 3;
                    queryFrameCount = 0;
                }
                else if (state == 3)
                {
                    queryFrameCount++;

                    if (queryFrameCount > 5)
                        Assert.Fail("Occlusion query did not complete.");

                    if (occlusionQuery.IsComplete)
                    {
                        Assert.AreEqual(100 * 100 * 9 / 10, occlusionQuery.PixelCount);
                        state = 4;
                    }
                }
            };

            Game.Run(until: frameInfo => state == 4 || frameInfo.DrawNumber > 15);
        }
Example #13
0
        public override void Initialize()
        {
            // initiate the viewport
            ContentManager Content = ScreenManager.Game.Content;
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            staticVBRenderer = new StaticVBRenderer[(int)xychunks, (int)xychunks][];
            occlusionCull = new OcclusionQuery(ScreenManager.GraphicsDevice);
            ScreenManager.Game.IsFixedTimeStep = false;

            raster = ScreenManager.GraphicsDevice.RasterizerState.ToString();

            //Textures
            kootenayFont = Content.Load<SpriteFont>("Fonts\\Kootenay");
            staticVBEffect = Content.Load<Effect>("VertexBuffer");
            Textures[0] = Content.Load<Texture2D>("Textures\\CubeTextures\\Stone");
            Textures[1] = Content.Load<Texture2D>("Textures\\CubeTextures\\Grass");
            Textures[2] = Content.Load<Texture2D>("Textures\\CubeTextures\\dirt");
            Textures[3] = Content.Load<Texture2D>("Textures\\CubeTextures\\water_noborder");

            //Call map generation, at bottom
            GenerateMap();

            base.Initialize();
        }
        public void LoadContent()
        {
            // Create a SpriteBatch for drawing the glow and flare sprites.
            spriteBatch = new SpriteBatch(graphicsDevice);

            // Load the glow and flare textures.
            glowSprite = game.Content.Load<Texture2D>("textures//LensFlare//glow");

            foreach (Flare flare in flares)
            {
                flare.Texture = game.Content.Load<Texture2D>(flare.TextureName);
            }

            // Effect for drawing occlusion query polygons.
            basicEffect = new BasicEffect(graphicsDevice);

            basicEffect.View = Matrix.Identity;
            basicEffect.VertexColorEnabled = true;

            // Create vertex data for the occlusion query polygons.
            queryVertices = new VertexPositionColor[4];

            queryVertices[0].Position = new Vector3(-querySize / 2, -querySize / 2, -1);
            queryVertices[1].Position = new Vector3(querySize / 2, -querySize / 2, -1);
            queryVertices[2].Position = new Vector3(-querySize / 2, querySize / 2, -1);
            queryVertices[3].Position = new Vector3(querySize / 2, querySize / 2, -1);

            // Create the occlusion query object.
            occlusionQuery = new OcclusionQuery(graphicsDevice);
        }
Example #15
0
        /// <summary>
        /// A private constructor.
        /// </summary>
        private iWearTracker()
        {
            identifier = "iWearTracker";
            isAvailable = false;
            stereoAvailable = false;
            trackerAvailable = false;
            sensorAvailable = false;
            productID = iWearDllBridge.IWRProductID.IWR_PROD_NONE;
            rotation = Quaternion.Identity;
            yaw = 0;
            pitch = 0;
            roll = 0;
            magneticData = Vector3.Zero;
            accelerationData = Vector3.Zero;
            gyroData = Vector3.Zero;
            lbGyroData = Vector3.Zero;
            sensorData = new iWearDllBridge.IWRSensorData();
            isHiDef = (State.Device.GraphicsProfile == GraphicsProfile.HiDef);

            stereoHandle = ((IntPtr)(-1));
            // Setup a query, to provide GPU syncing method.
            if(isHiDef)
                g_QueryGPU = new OcclusionQuery(State.Device);
            windowBottomLine = 0;
        }
Example #16
0
        /// <summary>
        /// Loads the content used by the lensflare component.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a SpriteBatch for drawing the glow and flare sprites.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the glow and flare textures.
            glowSprite = Game.Content.Load<Texture2D>("glow");

            foreach (Flare flare in flares)
            {
                flare.Texture = Game.Content.Load<Texture2D>(flare.TextureName);
            }

            // Effect and vertex declaration for drawing occlusion query polygons.
            basicEffect = new BasicEffect(GraphicsDevice, null);

            basicEffect.View = Matrix.Identity;
            basicEffect.VertexColorEnabled = true;

            vertexDeclaration = new VertexDeclaration(GraphicsDevice,
                                                VertexPositionColor.VertexElements);

            // Create vertex data for the occlusion query polygons.
            queryVertices = new VertexPositionColor[4];

            queryVertices[0].Position = new Vector3(-querySize / 2, -querySize / 2, -1);
            queryVertices[1].Position = new Vector3( querySize / 2, -querySize / 2, -1);
            queryVertices[2].Position = new Vector3( querySize / 2,  querySize / 2, -1);
            queryVertices[3].Position = new Vector3(-querySize / 2,  querySize / 2, -1);

            // Create the occlusion query object.
            occlusionQuery = new OcclusionQuery(GraphicsDevice);
        }
Example #17
0
        /// <inheritdoc/>
        protected override void Dispose(bool disposing, bool disposeData)
        {
            if (!IsDisposed)
              {
            if (disposing)
            {
              OcclusionQuery.SafeDispose();
              OcclusionQuery = null;
              SunOcclusion = 0;

              if (disposeData)
            CloudMap.SafeDispose();
            }

            base.Dispose(disposing, disposeData);
              }
        }
		/// <summary>
		/// Draw the statistics
		/// </summary>
		/// <param name="state"></param>
		public void Draw(DrawState state)
		{
#if DEBUG


			float fade = 8 - state.TotalTimeSeconds * 0.5f;
			if (fade > 1)
				fade = 1;
			if (fade < 0)
				fade = 0;


			if (!enabled)
			{
				if (toggleTextDisplay != null && fade > 0)
				{
					this.toggleTextDisplay.ColourFloat = new Vector4(1, 1, 1, fade);
					toggleTextDisplay.Draw(state);

					AlignElements(state);
				}
				return;
			}


			if (state.Application.IsHiDefDevice)
			{
				if (fillRateQuery == null)
				{
					GraphicsDevice device = (GraphicsDevice)state;
					fillRateQuery = new OcclusionQuery(device);

					fillRateQuery.Begin();
					fillRateQueryActive = true;
				}

				if (fillRateQueryActive)
				{
					fillRateQuery.End();
					fillRateQueryActive = false;
				}
			}

			DrawStatistics stats;
			state.GetPreviousFrameStatistics(out stats);

			stats -= previousFrameOverhead;

			if (graphs == null)
			{
				const int width = 210;
				const int height = 128;
				const int fontPix = 20;
				List<Call> calls = new List<Call>();

				Func<string, Call, float, Graph> add = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width, height, width - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalf = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 0, font, -good); };
				Func<string, Call, float, Graph> addHalfMin1 = delegate(string name, Call call, float good) { calls.Add(call); return new Graph(name, width / 2, height, width / 2 - fontPix / 2, fontPix, 1, font, -good); };

				graphs = new Graph[]
				{
					add("Frame Rate (Approx)",delegate(ref DrawStatistics s, DrawState dstate)
						{return (float)dstate.ApproximateFrameRate;}, -20),
					
#if XBOX360
					addHalf("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn\n(Approx)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled - (float)s.XboxPixelFillBias);}, 20000000), // not accurate
#else
			
					add("Primitives Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.TrianglesDrawn+s.LinesDrawn+s.PointsDrawn);}, 1000000),

					addHalf("Pixels Drawn",delegate(ref DrawStatistics s, DrawState dstate)
					    {return Math.Max(0,pixelsFillled);}, 18000000),
#endif
					
					addHalf("Draw Calls",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (float)(s.DrawIndexedPrimitiveCallCount + s.DrawPrimitivesCallCount);}, 300),
					
					addHalf("Garbage Collected",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							if (garbageTracker.Target == null) { garbageTracker.Target = new object(); return 1; }
							return 0;
						},0),
						
					addHalf("Allocated Bytes (Managed)",delegate(ref DrawStatistics s, DrawState dstate)
					    {
							return (int)GC.GetTotalMemory(false);
						},0),
					
#if XBOX360
					
					addHalfMin1("CPU Usage\n(Primary)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return threads[0].Usage;},-0.5f),
					addHalfMin1("CPU Usage\n(Task Threads)",delegate(ref DrawStatistics s, DrawState dstate)
					    {return (threads[1].Usage+threads[2].Usage+threads[3].Usage) / 3.0f;},-0.25f),
#endif
						
				};

				this.setGraphCalls = calls.ToArray();
			}

			for (int i = 0; i < graphs.Length; i++)
			{
				graphs[i].SetGraphValue(setGraphCalls[i](ref stats, state));
				graphs[i].Visible = true;
			}

			AlignElements(state);


			DrawStatistics currentPreDraw;
			state.GetCurrentFrameStatistics(out currentPreDraw);


			for (int i = 0; i < graphs.Length; i++)
			{
				if (graphs[i].Visible)
					graphs[i].Draw(state);
			}


			DrawStatistics currentPostDraw;
			state.GetCurrentFrameStatistics(out currentPostDraw);

			previousFrameOverhead = currentPostDraw - currentPreDraw;


			if (state.Application.IsHiDefDevice)
			{
				if (fillRateQuery.IsComplete)
				{
					pixelsFillled = (float)fillRateQuery.PixelCount;

					fillRateQuery.Begin();
					fillRateQueryActive = true;
				}
			}
			else
				pixelsFillled = -1;
#endif
		}
        /// <summary>
        /// Loads the content used by the lensflare component.
        /// </summary>
        public void LoadContent(Game game)
        {
            this.game = game;

              fCameraManager = (ICameraManager)game.Services.GetService(typeof(ICameraManager));

            // Create a SpriteBatch for drawing the glow and flare sprites.
            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            // Load the glow and flare textures.
            glowSprite = game.Content.Load<Texture2D>(@"textures\glow");

            foreach (Flare flare in flares)
            {
              flare.Texture = game.Content.Load<Texture2D>(@"textures\" + flare.TextureName);
            }

            // Effect and vertex declaration for drawing occlusion query polygons.
            basicEffect = new BasicEffect(game.GraphicsDevice);

            basicEffect.View = Matrix.Identity;
            basicEffect.VertexColorEnabled = true;

            fMaskCombine = game.Content.Load<Effect>(@"effects\maskcombine");

            vertexDeclaration = VertexPositionColor.VertexDeclaration; // new VertexDeclaration(game.GraphicsDevice, VertexPositionColor.VertexElements);

            // Create vertex data for the occlusion query polygons.
            queryVertices = new VertexPositionColor[4];

            queryVertices[0].Position = new Vector3(-querySize / 2, -querySize / 2, -1);
            queryVertices[1].Position = new Vector3( querySize / 2, -querySize / 2, -1);
            queryVertices[2].Position = new Vector3( querySize / 2,  querySize / 2, -1);
            queryVertices[3].Position = new Vector3(-querySize / 2,  querySize / 2, -1);

            // Create the occlusion query object.
            occlusionQuery = new OcclusionQuery(game.GraphicsDevice);

            fSunCamera = fCameraManager.GetCamera("SunCam");

            PresentationParameters pp = game.GraphicsDevice.PresentationParameters;

            fSunView = new RenderTarget2D(game.GraphicsDevice, MaskSize, MaskSize, false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);
            fIntensityMap = new RenderTarget2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Single, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);

            fIntensityEffect = game.Content.Load<Effect>(@"effects\intensity");
            fIntensityMaskVertexDeclaration = VertexPositionTexture.VertexDeclaration; // new VertexDeclaration(game.GraphicsDevice, VertexPositionTexture.VertexElements);

            fOcclusionPoints = GenerateOcclusionPoints();
        }
Example #20
0
        protected override void Initialize()
        {
            occQuery = new OcclusionQuery(GraphicsDevice);
            GameUtilities.Content = Content;
            GameUtilities.GraphicsDevice = GraphicsDevice;
            debug.Initialize();
            shapeDrawer.Initialize();

            mainCamera = new Camera("cam", new Vector3(0, 5, 10), new Vector3(0, 0, -1));
            mainCamera.Initialize();

            base.Initialize();
        }
Example #21
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public virtual void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj)
        {
            #if !WINDOWS_PHONE && !REACH
            basicDraw = factory.GetEffect("clippingPlane", false, true);
            getDepth = factory.GetEffect("ShadowDepth",false,true);
            BasicDrawSamplerState = SamplerState.LinearWrap;            
            #endif
            if (useOcclusionCulling)
            {
                if(Modelo==null)
                    Modelo = new SimpleModel(factory, "block", true);

                if (BasicEffect == null)
                {
                    BasicEffect = factory.GetBasicEffect();
                    BasicEffect.TextureEnabled = false;
                    BasicEffect.VertexColorEnabled = false;                    
                }

                if (BlendState == null)
                {
                    BlendState = new Microsoft.Xna.Framework.Graphics.BlendState();
                    BlendState.ColorWriteChannels = ColorWriteChannels.None;                    
                }
                OcclusionQuery = factory.CreateOcclusionQuery();
                OcclusionQuery.Tag = "Begin";
            }
            this.GraphicFactory = factory;
            isInitialized = true;    
        }