Пример #1
0
        /// <summary>
        /// Processes the light draw.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="render">The render.</param>
        /// <param name="camera">The camera.</param>
        /// <param name="objects">The objects.</param>
        /// <param name="color">The color.</param>
        /// <param name="light">The light.</param>
        public void ProcessLightDraw(GameTime gameTime, SceneControl.RenderHelper render, SceneControl._2DScene.ICamera2D camera, List <SceneControl._2DScene.I2DObject> objects, Color color, PloobsEngine.Light2D.Light2D light)
        {
            render.RenderBegin(camera.View, null, SpriteSortMode.Deferred);

            foreach (var iobj in objects)
            {
                if (iobj.PhysicObject.Enabled == true)
                {
                    iobj.Material.LightDraw(gameTime, iobj, render, color, light);
                }
            }
            render.RenderEnd();
        }
Пример #2
0
        protected override void PosWithDepthDraw(SceneControl.RenderHelper render, Microsoft.Xna.Framework.GameTime gt, ref Microsoft.Xna.Framework.Matrix activeView, ref Microsoft.Xna.Framework.Matrix activeProjection)
        {
            base.PosWithDepthDraw(render, gt, ref activeView, ref activeProjection);

            foreach (var item in debugDrawers)
            {
                foreach (var shape in item.GetShapes())
                {
                    shape.Draw(render, activeView, activeProjection);
                }

                item.EndFrame();
            }
        }
Пример #3
0
        protected override void AfterDraw(SceneControl.RenderHelper render, GameTime gt, ref Matrix activeView, ref Matrix activeProjection)
        {
            base.AfterDraw(render, gt, ref activeView, ref activeProjection);

            _TotalTime += (float)gt.ElapsedGameTime.TotalSeconds;
            _Fps       += 1;

            if (_TotalTime >= 1.0f)
            {
                _TotalTime  = _TotalTime - (float)(_TotalTime);
                _DisplayFPS = _Fps;
                _Fps        = 0;
            }
        }
Пример #4
0
 /// <summary>
 /// Processes the draw.
 /// </summary>
 /// <param name="uselayer">if set to <c>true</c> [uselayer].</param>
 /// <param name="gameTime">The game time.</param>
 /// <param name="render">The render.</param>
 /// <param name="camera">The camera.</param>
 /// <param name="objects">The objects.</param>
 public void ProcessDraw(bool uselayer, GameTime gameTime, SceneControl.RenderHelper render, SceneControl._2DScene.ICamera2D camera, List <SceneControl._2DScene.I2DObject> objects)
 {
     if (uselayer)
     {
         render.RenderBegin(camera.View, null, SpriteSortMode.BackToFront);
     }
     else
     {
         render.RenderBegin(camera.View, null, SpriteSortMode.Deferred);
     }
     foreach (var iobj in objects)
     {
         if (iobj.PhysicObject.Enabled == true)
         {
             iobj.Material.Draw(gameTime, iobj, render);
         }
     }
     render.RenderEnd();
 }
Пример #5
0
 /// <summary>
 /// Exctract the depth from an object
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="View">The view.</param>
 /// <param name="projection">The projection.</param>
 /// <param name="render">The render.</param>
 public override void DepthExtractor(GameTime gt, SceneControl.IObject obj, ref Matrix View, ref Matrix projection, SceneControl.RenderHelper render)
 {
 }
Пример #6
0
 /// <summary>
 /// Draw the object in a simple way (WITH MINIMUM EFFECTS,....)
 /// USED IN RELECTIONS, REFRACTION .....
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="view">The view.</param>
 /// <param name="projection">The projection.</param>
 /// <param name="lights">The lights.</param>
 /// <param name="render">The render.</param>
 /// <param name="clippingPlane">The clipping plane.</param>
 /// <param name="useAlphaBlending">if set to <c>true</c> [use alpha blending].</param>
 public override void BasicDraw(GameTime gt, SceneControl.IObject obj, ref Matrix view, ref Matrix projection, System.Collections.Generic.IList <Light.ILight> lights, SceneControl.RenderHelper render, Plane?clippingPlane, bool useAlphaBlending = false)
 {
 }
Пример #7
0
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            if (SamplePositions != null)
            {
                for (int i = 0; i < SamplePositions.Count(); i++)
                {
                    render.SetSamplerState(SamplerState[i], SamplePositions[i]);
                    samplers[SamplePositions[i]] = SamplerState[i];
                }
            }

            if (BlendState != null)
            {
                render.PushBlendState(BlendState);
            }
            if (RasterizerState != null)
            {
                render.PushRasterizerState(RasterizerState);
            }
            material.Drawn(gt, obj, cam, lights, render);

            if (RasterizerState != null)
            {
                render.PopRasterizerState();
            }
            if (BlendState != null)
            {
                render.PopBlendState();
            }

            if (SamplePositions != null)
            {
                for (int i = 0; i < SamplePositions.Count(); i++)
                {
                    render.SetSamplerState(samplers[SamplePositions[i]], SamplePositions[i]);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Normal Draw Function.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            PhysxFluidObject       PhysxFluidObject       = obj.PhysicObject as PhysxFluidObject;
            InstancedBilboardModel InstancedBilboardModel = obj.Modelo as InstancedBilboardModel;

            if (!PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles.HasValue)
            {
                return;
            }

            Phyx.Vector3[]     pos  = PhysxFluidObject.Fluid.ParticleWriteData.PositionBuffer.GetData <Phyx.Vector3>();
            BilboardInstance[] inst = new Modelo.BilboardInstance[PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles.Value];
            for (int i = 0; i < PhysxFluidObject.Fluid.ParticleWriteData.NumberOfParticles; i++)
            {
                inst[i]          = BilboardInstance[i];
                inst[i].Position = pos[i].AsXNA();
            }

            InstancedBilboardModel.SetBilboardInstances(inst);

            shader.iDraw(gt, obj, render, cam, lights);
        }
        public override void DepthExtractor(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, ref Microsoft.Xna.Framework.Matrix View, ref Microsoft.Xna.Framework.Matrix projection, SceneControl.RenderHelper render)
        {
            SimpleTree tree = (obj.Modelo as TreeModel).Tree;

            tree.DrawTrunk(obj.WorldMatrix, View, projection, false, true);
            render.ResyncStates();
            tree.DrawLeaves(obj.WorldMatrix, View, projection, false, true);
            render.ResyncStates();
        }
Пример #10
0
 /// <summary>
 /// Pre drawn Function.
 /// Called before all the objects are draw
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="mundo">The mundo.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="cam">The cam.</param>
 /// <param name="lights">The lights.</param>
 /// <param name="render">The render.</param>
 public void PreDrawnPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IWorld mundo, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
 {
 }
 protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam)
 {
     throw new System.NotImplementedException();
 }
 protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam)
 {
 }
        /// <summary>
        /// Normal Draw Function.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            PhysxClothObject PhysxClothObject = obj.PhysicObject as PhysxClothObject;
            ClothModel       ClothModel       = obj.Modelo as ClothModel;

            StillDesign.PhysX.MathPrimitives.Vector3[] pos  = PhysxClothObject.Cloth.GetMeshData().PositionsStream.GetData <StillDesign.PhysX.MathPrimitives.Vector3>();
            StillDesign.PhysX.MathPrimitives.Vector3[] norm = PhysxClothObject.Cloth.GetMeshData().NormalsStream.GetData <StillDesign.PhysX.MathPrimitives.Vector3>();

            for (int i = 0; i < ClothModel.BatchInformation.NumVertices; i++)
            {
                ClothModel.vertexPositionNormalTexture[i].Position = pos[i].AsXNA();
                ClothModel.vertexPositionNormalTexture[i].Normal   = norm[i].AsXNA();
            }

            ClothModel.BatchInformation.VertexBuffer.SetData <VertexPositionNormalTexture>(ClothModel.vertexPositionNormalTexture);

            if (rasterizerState != null && rasterizerState != render.PeekRasterizerState())
            {
                rasterStateFlag = true;
                render.PushRasterizerState(rasterizerState);
            }

            shader.iDraw(gt, obj, render, cam, lights);

            if (rasterStateFlag)
            {
                render.PopRasterizerState();
                rasterStateFlag = false;
            }
        }
Пример #14
0
        /// <summary>
        /// Normal Drawn Function.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            WorldMatrix.SetValue(obj.PhysicObject.WorldMatrix);
            ViewMatrix.SetValue(cam.View);
            ProjectionMatrix.SetValue(cam.Projection);

            TerrainShader.CurrentTechnique = TerrainShader.Techniques["Technique1"];
            TerrainShader.CurrentTechnique.Passes[0].Apply();

            QuadTerrain.DrawTerrain(TerrainShader, render.device);

            render.ResyncStates();
        }
Пример #15
0
 public override void Draw(GameTime gt, SceneControl._2DScene.I2DObject obj, SceneControl.RenderHelper render)
 {
     render.RenderTexture(obj.Modelo.Texture, obj.PhysicObject.Position, obj.Modelo.SourceRectangle, Color.White, obj.PhysicObject.Rotation + obj.Modelo.Rotation, obj.Modelo.Origin + obj.PhysicObject.Origin, 1, SpriteEffects.None, obj.Modelo.LayerDepth);
 }
Пример #16
0
 public override void LightDraw(GameTime gt, SceneControl._2DScene.I2DObject obj, SceneControl.RenderHelper render, Color color, PloobsEngine.Light2D.Light2D light)
 {
     if (CastShadow)
     {
         render.RenderTexture(obj.Modelo.Texture, light.ToRelativePosition(obj.PhysicObject.Position), obj.Modelo.SourceRectangle, color, obj.PhysicObject.Rotation + obj.Modelo.Rotation, obj.Modelo.Origin + obj.PhysicObject.Origin, 1);
     }
 }
Пример #17
0
        /// <summary>
        /// Normal Drawn Function.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            if (isupdated == false)
            {
                QuadTerrain.UpdateTerrain(cam.Position, cam.BoundingFrustum, LOD);
            }

            WorldMatrix.SetValue(obj.PhysicObject.WorldMatrix);
            ViewMatrix.SetValue(cam.View);
            ProjectionMatrix.SetValue(cam.Projection);

            TerrainShader.CurrentTechnique = TerrainShader.Techniques["Technique2"];
            TerrainShader.CurrentTechnique.Passes[0].Apply();

            QuadTerrain.DrawTerrain(TerrainShader, render.device);

            render.ResyncStates();
            isupdated = false;
            render.SetSamplerStates(ginfo.SamplerState, 6);
        }
        protected override void Draw(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, IList <Light.ILight> lights)
        {
            SimpleTree tree = (obj.Modelo as TreeModel).Tree;

            tree.DrawTrunk(obj.WorldMatrix, cam.View, cam.Projection, true);
            tree.DrawLeaves(obj.WorldMatrix, cam.View, cam.Projection, true);
            render.ResyncStates();
        }
        public override void PosDrawPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, IList <Light.ILight> lights)
        {
            SimpleTree tree = (obj.Modelo as TreeModel).Tree;

            tree.DrawLeaves(obj.WorldMatrix, cam.View, cam.Projection, false);
            render.ResyncStates();
            render.SetSamplerStates(ginfo.SamplerState);
        }
Пример #20
0
 /// <summary>
 /// Pos drawn Function.
 /// Called after all objects are Draw
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="cam">The cam.</param>
 /// <param name="lights">The lights.</param>
 /// <param name="render">The render.</param>
 public void PosDrawnPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
 {
     shader.PosDrawPhase(gt, obj, render, cam, lights);
 }
        /// <summary>
        /// Normal Draw Function.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        public void Drawn(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, Cameras.ICamera cam, IList <Light.ILight> lights, SceneControl.RenderHelper render)
        {
            if (rasterizerState != null && rasterizerState != render.PeekRasterizerState())
            {
                rasterStateFlag = true;
                render.PushRasterizerState(rasterizerState);
            }

            shader.iDraw(gt, obj, render, cam, lights);

            if (rasterStateFlag)
            {
                render.PopRasterizerState();
                rasterStateFlag = false;
            }
        }
Пример #22
0
 /// <summary>
 /// Draws the specified gt.
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="render">The render.</param>
 /// <param name="cam">The cam.</param>
 /// <param name="lights">The lights.</param>
 protected override void Draw(GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, System.Collections.Generic.IList <Light.ILight> lights)
 {
 }
Пример #23
0
        protected override void DebugDrawn(SceneControl.RenderHelper render, GameTime gt, Cameras.ICamera cam)
        {
            if (BasicEffect == null)
            {
                BasicEffect = new BasicEffect(render.device);
                BasicEffect.VertexColorEnabled = true;
                BasicEffect.TextureEnabled     = false;
            }

            //if (_fetchedResults == false)
            {
                DebugRenderable RenderBuffer = Scene.GetDebugRenderable();
                if (RenderBuffer == null || (RenderBuffer.TriangleCount == 0 && RenderBuffer.LineCount == 0))
                {
                    return;
                }

                Color c = Color.Red;
                if (RenderBuffer.TriangleCount > 0)
                {
                    VertexPositionColor1 = new VertexPositionColor[RenderBuffer.TriangleCount * 3];
                    for (int i = 0, j = 0; i < RenderBuffer.TriangleCount; i += 3, j++)
                    {
                        VertexPositionColor1[i].Color    = c;
                        VertexPositionColor1[i].Position = RenderBuffer.GetDebugTriangles()[j].Point0.AsXNA();

                        VertexPositionColor1[i + 1].Color    = c;
                        VertexPositionColor1[i + 1].Position = RenderBuffer.GetDebugTriangles()[j].Point1.AsXNA();

                        VertexPositionColor1[i + 2].Color    = c;
                        VertexPositionColor1[i + 2].Position = RenderBuffer.GetDebugTriangles()[j].Point2.AsXNA();
                    }
                }

                if (RenderBuffer.LineCount > 0)
                {
                    VertexPositionColor2 = new VertexPositionColor[RenderBuffer.LineCount * 2];
                    for (int i = 0, j = 0; i < RenderBuffer.LineCount; i += 2, j++)
                    {
                        VertexPositionColor2[i].Color    = c;
                        VertexPositionColor2[i].Position = RenderBuffer.GetDebugLines()[j].Point0.AsXNA();

                        VertexPositionColor2[i + 1].Color    = c;
                        VertexPositionColor2[i + 1].Position = RenderBuffer.GetDebugLines()[j].Point1.AsXNA();
                    }
                }
            }

            BasicEffect.View       = cam.View;
            BasicEffect.Projection = cam.Projection;
            BasicEffect.World      = Matrix.Identity;

            if (VertexPositionColor2 != null)
            {
                render.RenderUserPrimitive <VertexPositionColor>(BasicEffect, PrimitiveType.LineList, VertexPositionColor2, 0, VertexPositionColor2.Length / 2);
            }

            if (VertexPositionColor1 != null)
            {
                render.RenderUserPrimitive <VertexPositionColor>(BasicEffect, PrimitiveType.TriangleList, VertexPositionColor1, 0, VertexPositionColor1.Length / 3);
            }
        }