예제 #1
0
 internal static void WritePointlightConstants(LightId lid, ref MyPointlightConstants data)
 {
     data.VsPosition = Vector3.Transform(Lights.Data[lid.Index].Position - MyEnvironment.CameraPosition, ref MyEnvironment.ViewAt0);
     data.Range      = Pointlights[lid.Index].Range;
     data.Color      = Pointlights[lid.Index].Color;
     data.Falloff    = Pointlights[lid.Index].Falloff;
 }
예제 #2
0
        internal static void WritePointlightConstants(LightId lid, ref MyPointlightConstants data)
        {
            if (lid == LightId.NULL)
            {
                data = default(MyPointlightConstants);
                return;
            }

            data.VsPosition = Vector3.Transform(Lights.Data[lid.Index].PointPosition - MyRender11.Environment.CameraPosition, ref MyRender11.Environment.ViewAt0);
            if (MyStereoRender.Enable)
            {
                if (MyStereoRender.RenderRegion == MyStereoRegion.LEFT)
                {
                    data.VsPosition = Vector3.Transform(Lights.Data[lid.Index].PointPosition - MyStereoRender.EnvMatricesLeftEye.CameraPosition, ref MyStereoRender.EnvMatricesLeftEye.ViewAt0);
                }
                else if (MyStereoRender.RenderRegion == MyStereoRegion.RIGHT)
                {
                    data.VsPosition = Vector3.Transform(Lights.Data[lid.Index].PointPosition - MyStereoRender.EnvMatricesRightEye.CameraPosition, ref MyStereoRender.EnvMatricesRightEye.ViewAt0);
                }
            }
            data.Range       = Pointlights[lid.Index].Range;
            data.Color       = Pointlights[lid.Index].Color;
            data.Falloff     = Pointlights[lid.Index].Falloff;
            data.GlossFactor = Pointlights[lid.Index].GlossFactor;
        }
예제 #3
0
        internal static void WritePointlightConstants(LightId lid, ref MyPointlightConstants data)
        {
            if (lid == LightId.NULL)
            {
                data = default(MyPointlightConstants);
                return;
            }

            data.VsPosition = Vector3.Transform(Lights.Data[lid.Index].PositionWithOffset - MyEnvironment.CameraPosition, ref MyEnvironment.ViewAt0);
            data.Range      = Pointlights[lid.Index].Range;
            data.Color      = Pointlights[lid.Index].Color;
            data.Falloff    = Pointlights[lid.Index].Falloff;
        }
예제 #4
0
        //internal static void AttachHemisphericalLightInfo(LightId light, ref MyHemisphericalLightInfo info)
        //{
        //}

        internal static void Update()
        {
            // touch all lights again, because they don't get updated always when parent is
            foreach (var light in IdIndex.Values)
            {
                var position = light.LocalPosition;
                var gid      = light.ParentGID;
                if (gid != -1 && MyIDTracker <MyActor> .FindByID((uint)gid) != null)
                {
                    var matrix = MyIDTracker <MyActor> .FindByID((uint)gid).WorldMatrix;

                    Vector3.Transform(ref position, ref matrix, out position);
                }
                Lights.Data[light.Index].Position = position;
            }

            if (DirtyPointlights.Count > 0)
            {
                foreach (var id in DirtyPointlights)
                {
                    var proxy    = Pointlights[id.Index].BvhProxyId;
                    var position = Lights.Data[id.Index].Position;
                    var range    = Pointlights[id.Index].Range;

                    var aabb = new BoundingBox(position - range, position + range);
                    Pointlights[id.Index].BvhProxyId            = UpdateBvh(PointlightsBvh, id, Pointlights[id.Index].Enabled, proxy, ref aabb);
                    Pointlights[id.Index].LastBvhUpdatePosition = position;
                }

                DirtyPointlights.Clear();
            }

            if (DirtySpotlights.Count > 0)
            {
                foreach (var id in DirtySpotlights)
                {
                    var proxy    = Spotlights[id.Index].BvhProxyId;
                    var position = Lights.Data[id.Index].Position;
                    var range    = Spotlights[id.Index].Range;

                    var aabb = MakeAabbFromSpotlightCone(ref Spotlights[id.Index], position);
                    Spotlights[id.Index].BvhProxyId            = UpdateBvh(SpotlightsBvh, id, Spotlights[id.Index].Enabled, proxy, ref aabb);
                    Spotlights[id.Index].LastBvhUpdatePosition = position;
                }

                DirtySpotlights.Clear();
            }
        }
예제 #5
0
        internal static void UpdateEntity(LightId light, ref MyLightInfo info)
        {
            Lights.Data[light.Index] = info;

            var position = info.Position;
            var gid      = info.ParentGID;

            if (gid != -1 && MyIDTracker <MyActor> .FindByID((uint)gid) != null)
            {
                var matrix = MyIDTracker <MyActor> .FindByID((uint)gid).WorldMatrix;

                Vector3.Transform(ref position, ref matrix, out position);
            }

            Lights.Data[light.Index].Position = position;
        }
예제 #6
0
        internal unsafe void Update(MyRenderMessageDebugDrawMesh message)
        {
            edges = !message.Shaded;
            depth = message.DepthRead;

            if (vbuffer.ElementCount < message.VertexCount)
            {
                MyManagers.Buffers.Resize(vbuffer, message.VertexCount);
            }

            var mapping = MyMapping.MapDiscard(MyPrimitivesRenderer.RC, vbuffer);

            for (int i = 0; i < message.VertexCount; i++)
            {
                MyVertexFormatPositionColor vert = new MyVertexFormatPositionColor(Vector3.Transform(message.Vertices[i].Position, message.WorldMatrix), message.Vertices[i].Color);
                mapping.WriteAndPosition(ref vert);
            }
            mapping.Unmap();

            message.Vertices.Clear();
        }
예제 #7
0
 private static void TransformRay(ref Ray ray, ref Matrix matrix)
 {
     ray.Direction = Vector3.Transform(ray.Position + ray.Direction, ref matrix);
     ray.Position  = Vector3.Transform(ray.Position, ref matrix);
     ray.Direction = ray.Direction - ray.Position;
 }
예제 #8
0
        internal static void DrawHierarchyDebug()
        {
            var worldToClip   = MyEnvironment.ViewProjection;
            var displayString = new StringBuilder();

            var batch = MyLinesRenderer.CreateBatch();

            if (MyRender11.Settings.DisplayIDs)
            {
                foreach (var actor in MyActorFactory.GetAll())
                {
                    var h = actor.GetGroupLeaf();
                    var r = actor.GetRenderable();

                    Vector3 position;
                    uint    ID;

                    if (r != null)
                    {
                        position = r.Owner.WorldMatrix.Translation;
                        ID       = r.Owner.ID;
                    }
                    else if (h != null)
                    {
                        position = h.Owner.WorldMatrix.Translation;
                        ID       = h.Owner.ID;
                    }
                    else
                    {
                        continue;
                    }

                    var clipPosition = Vector3.Transform(position, ref worldToClip);
                    clipPosition.X = clipPosition.X * 0.5f + 0.5f;
                    clipPosition.Y = clipPosition.Y * -0.5f + 0.5f;

                    if (clipPosition.Z > 0 && clipPosition.Z < 1)
                    {
                        displayString.AppendFormat("{0}", ID);
                        MySpritesRenderer.DrawText(new Vector2(clipPosition.X, clipPosition.Y) * MyRender11.ViewportResolution,
                                                   displayString, Color.DarkCyan, 0.5f);
                    }

                    displayString.Clear();
                }
            }

            if (MyRender11.Settings.DisplayAabbs)
            {
                foreach (var actor in MyActorFactory.GetAll())
                {
                    var h = actor.GetGroupRoot();
                    var r = actor.GetRenderable();

                    if (h != null)
                    {
                        var bb = BoundingBoxD.CreateInvalid();

                        foreach (var child in h.m_children)
                        {
                            if (child.IsVisible)
                            {
                                bb.Include(child.Aabb);
                            }
                        }

                        batch.AddBoundingBox((BoundingBox)bb, Color.Red);
                        MyPrimitivesRenderer.Draw6FacedConvexZ(bb.GetCorners().Select(x => (Vector3)x).ToArray(), Color.Red, 0.1f);
                    }
                    else if (r != null && actor.GetGroupLeaf() == null)
                    {
                        batch.AddBoundingBox((BoundingBox)r.Owner.Aabb, Color.Green);
                    }
                }
            }

            batch.Commit();
        }
예제 #9
0
        internal static void DrawSceneDebug()
        {
            //ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
            //ImmediateContext.Rasterizer.SetViewport(0, 0, m_settings.BackBufferWidth, m_settings.BackBufferHeight);
            //ImmediateContext.OutputMerger.ResetTargets();
            //ShaderResourceView[] shaderViews = m_gbuffer.ShaderViews;
            //ImmediateContext.OutputMerger.SetTargets(Backbuffer.RenderTarget);
            //ImmediateContext.PixelShader.SetConstantBuffer(0, m_frameCB.Buffer);
            //ImmediateContext.PixelShader.SetConstantBuffer(2, m_shadowsCB.Buffer);
            //ImmediateContext.PixelShader.SetShaderResources(0, shaderViews);

            //if (Settings.ShowGbufferDepth)
            //{
            //    ImmediateContext.PixelShader.Set(m_debugGbufferDepth.GetShader());
            //    DrawFullscreen();
            //}
            //else if (Settings.ShowGbufferAlbedo)
            //{
            //    ImmediateContext.PixelShader.Set(m_debugGbufferAlbedo.GetShader());
            //    DrawFullscreen();
            //}
            //else if (Settings.ShowGbufferNormals)
            //{
            //    ImmediateContext.PixelShader.Set(m_debugGbufferNormals.GetShader());
            //    DrawFullscreen();
            //}
            //else if (Settings.ShowCascadesRange)
            //{
            //    ImmediateContext.PixelShader.Set(m_debugContainingCascade.GetShader());
            //    DrawFullscreen();
            //}
            //if (Settings.ShowCascadesDepth)
            //{
            //    /*
            //    SetupSpritePipeline();
            //    ImmediateContext.PixelShader.Set(m_debugCascadeDepth.GetShader());
            //    ImmediateContext.PixelShader.SetConstantBuffer(3, m_debugCB.Buffer);
            //    ImmediateContext.PixelShader.SetShaderResource(7, m_cascadesTexture.ShaderView);

            //    const int horizontalCutoff = (MyRenderConstants.CASCADES_NUM + 1) / 2;
            //    var size = Math.Min(ViewportResolution.X / horizontalCutoff, ViewportResolution.Y / 2) - 3;

            //    for (int i = 0; i < MyRenderConstants.CASCADES_NUM; i++)
            //    {
            //        var stream = MapCB(m_debugCB);
            //        stream.Write(i);
            //        UnmapCB(m_debugCB);

            //        var gridX = i % horizontalCutoff;
            //        var gridY = i / horizontalCutoff;

            //        Vector2 csScale;
            //        Vector2 csOffset;
            //        CalculateSpriteClipspace(new RectangleF(new Vector2I(gridX * size + gridX, gridY * size + gridY), new Vector2I(size, size)), ViewportResolution, out csOffset, out csScale);

            //        DrawSprite(null, csOffset, csScale, Vector2.Zero, Vector2.One);
            //    }
            //     * */
            //}
            if (false)
            {
                /*
                 * var linesBatch = CreateLinesBatch();
                 *
                 * int objectsNum = MyRenderObjectPool.Size();
                 * for (int i = 0; i < objectsNum; i++)
                 * {
                 *  var bb = MyRenderObjectPool.m_cullinfos[i].worldAABB;
                 *
                 *  var v0 = bb.Center - bb.HalfExtents;
                 *  var v1 = v0 + new Vector3(bb.HalfExtents.X *2, 0, 0);
                 *  var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
                 *  var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
                 *  var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var color = new Byte4(255, 255, 255, 0);
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 * }
                 *
                 * linesBatch.Commit();
                 * */
                /*
                 * var linesBatch = CreateLinesBatch();
                 *
                 * int objectsNum = MyRenderObjectPool.Size();
                 * for (int i = 0; i < objectsNum; i++)
                 * {
                 *  var bb = MyRenderObjectPool.m_cullinfos[i].worldAABB;
                 *
                 *  var v0 = bb.Center - bb.HalfExtents;
                 *  var v1 = v0 + new Vector3(bb.HalfExtents.X *2, 0, 0);
                 *  var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
                 *  var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
                 *  var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var color = new Byte4(255, 255, 255, 0);
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 * }
                 *
                 * linesBatch.Commit();
                 * */
                /*
                 * var linesBatch = CreateLinesBatch();
                 *
                 * int objectsNum = MyRenderObjectPool.Size();
                 * for (int i = 0; i < objectsNum; i++)
                 * {
                 *  var bb = MyRenderObjectPool.m_cullinfos[i].worldAABB;
                 *
                 *  var v0 = bb.Center - bb.HalfExtents;
                 *  var v1 = v0 + new Vector3(bb.HalfExtents.X *2, 0, 0);
                 *  var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
                 *  var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
                 *  var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
                 *  var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);
                 *
                 *  var color = new Byte4(255, 255, 255, 0);
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 *
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
                 *  linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
                 * }
                 *
                 * linesBatch.Commit();
                 * */
            }

            //if(true)
            //{
            //    /*
            //    var linesBatch = MyRender.CreateLinesBatch();

            //    var list = new List<MySpatialObject>();
            //    var bsphere = new BoundingSphere(Vector3.Zero, 25.0f);
            //    MySpatialManager.Tree.OverlapAllBoundingSphere<MySpatialObject>(ref bsphere, list);
            //    var inIDs = new Dictionary<uint, object>();
            //    foreach(var item in list)
            //    {
            //        inIDs[item.ID] = null;
            //    }

            //    foreach (var item in MySpatialManager.AllValues())
            //    {
            //        var bb = item.m_aabb;

            //        var v0 = bb.Center - bb.HalfExtents;
            //        var v1 = v0 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
            //        var v2 = v0 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
            //        var v3 = v0 + new Vector3(0, bb.HalfExtents.Y * 2, 0);

            //        var v4 = v0 + new Vector3(0, 0, bb.HalfExtents.Z * 2);
            //        var v5 = v4 + new Vector3(bb.HalfExtents.X * 2, 0, 0);
            //        var v6 = v4 + new Vector3(bb.HalfExtents.X * 2, bb.HalfExtents.Y * 2, 0);
            //        var v7 = v4 + new Vector3(0, bb.HalfExtents.Y * 2, 0);

            //        var color = new Byte4(255, 0, 0, 0);
            //        if (inIDs.ContainsKey(item.ID))
            //        {
            //            color = new Byte4(0, 255, 0, 0);
            //        }

            //        linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v3, color));

            //        linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v7, color));

            //        linesBatch.Add(new MyVertexFormatPositionColor(v0, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v4, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v1, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v5, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v2, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v6, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v3, color));
            //        linesBatch.Add(new MyVertexFormatPositionColor(v7, color));
            //    }

            //    linesBatch.Commit();
            //     * */
            //}

            // draw culling structure
            if (false)
            {
                var linesBatch = MyLinesRenderer.CreateLinesBatch();

                List <MyRenderObjectProxy> list = new List <MyRenderObjectProxy>();

                foreach (var obj in MySceneObject.Collection)
                {
                    linesBatch.AddBoundingBox(obj.AABB, Color.AntiqueWhite);
                }



                linesBatch.Commit();
            }

            if (false)
            {
                var linesBatch = MyLinesRenderer.CreateLinesBatch();

                var worldToClip = m_viewMatrix * m_projectionMatrix;

                var displayString = new StringBuilder();

                var screenPositions = new List <Vector2>(10000);
                var display         = new List <bool>(10000);
                foreach (var obj in MySceneObject.Collection)
                {
                    var position     = obj.m_spatial.m_worldMatrix.Translation;
                    var clipPosition = Vector3.Transform(position, ref worldToClip);
                    clipPosition.X = clipPosition.X * 0.5f + 0.5f;
                    clipPosition.Y = clipPosition.Y * -0.5f + 0.5f;
                    screenPositions.Add(new Vector2(clipPosition.X, clipPosition.Y) * ViewportResolution);
                    display.Add(clipPosition.Z > 0 && clipPosition.Z < 1);
                }

                int i = 0;
                foreach (var obj in MySceneObject.Collection)
                {
                    if (display[i])
                    {
                        //displayString.AppendFormat("ID: {0}, proxy ID: {1}", obj.ID, obj.m_spatial.proxyID);

                        var v  = obj.m_spatial.m_aabb.Center;
                        var vv = obj.m_spatial.m_aabb.HalfExtents;

                        //var vv = obj.m_spatial.m_localAabb.HasValue ? obj.m_spatial.m_localAabb.Value.Center : Vector3.Zero;
                        displayString.AppendFormat("<{0}, {1}, {2}> <{3}, {4}, {5}>", v.X, v.Y, v.Z, vv.X, vv.Y, vv.Z);
                        if (obj.m_spatial.m_localAabb.HasValue)
                        {
                            v  = obj.m_spatial.m_localAabb.Value.Center;
                            vv = obj.m_spatial.m_localAabb.Value.HalfExtents;
                            displayString.AppendFormat("local: <{0}, {1}, {2}> <{3}, {4}, {5}>", v.X, v.Y, v.Z, vv.X, vv.Y, vv.Z);
                        }

                        //if (v.X != 0 && v.Y != 0 && v.Z != 0)
                        {
                            if (obj.m_spatial.m_parent != null)
                            {
                                MySpritesRenderer.DrawText(screenPositions[i], displayString, Color.DarkCyan, 0.5f);
                            }
                            else
                            {
                                MySpritesRenderer.DrawText(screenPositions[i] + new Vector2(0, -25.0f), displayString, Color.LightSkyBlue, 1);
                            }
                        }
                    }

                    if (obj.m_spatial.m_parent != null)
                    {
                        linesBatch.Add(new MyVertexFormatPositionColor(obj.m_spatial.m_parent.m_worldMatrix.Translation, new Byte4(0, 0, 128, 25)));
                        linesBatch.Add(new MyVertexFormatPositionColor(obj.m_spatial.m_worldMatrix.Translation, new Byte4(0, 0, 128, 25)));
                    }

                    displayString.Clear();

                    i++;
                }

                linesBatch.Commit();
            }

            //UpdateDepthBias();

            //ImmediateContext.ClearState();
        }