コード例 #1
0
        public void Execute(BoundingFrustum frustum, Action <Octree> action)
        {
            var frustumSphere = BoundingSphere.CreateFromFrustum(frustum);

            foreach (var root in rootsByPositionGrid.Values)
            {
                Execute(frustum, ref frustumSphere, action, root);
            }
        }
コード例 #2
0
ファイル: BoundarySystem.cs プロジェクト: third1020/MiniRTS
        public void Render2DOverlay(PerspectiveCamera viewPoint, GBuffer gBuffer)
        {
            this.Effect.World      = Matrix.Identity;
            this.Effect.View       = Matrix.Identity;
            this.Effect.Projection = Matrix.Identity;

            this.Effect.DepthMap              = gBuffer.DepthTarget;
            this.Effect.CameraPosition        = viewPoint.Position;
            this.Effect.InverseViewProjection = viewPoint.InverseViewProjection;

            this.Device.PostProcessState();

            foreach ((var entity, var component, var info, var property, var attribute) in this.EnumerateAttributes <BoundaryAttribute>())
            {
                this.Effect.Color       = info.Color2D;
                this.Effect.VisibleTint = info.VisibileIconTint;
                this.Effect.ClippedTint = info.ClippedIconTint;

                var boundary = property.GetGetMethod().Invoke(component, null);
                switch (attribute.Type)
                {
                case BoundaryType.Frustum:
                    var frustum = (BoundingFrustum)boundary;
                    if (viewPoint.Frustum.Intersects(frustum))
                    {
                        this.Effect.WorldPosition = BoundingSphere.CreateFromFrustum(frustum).Center;
                        this.Effect.Apply(ColorEffectTechniques.ColorPointDepthTest);
                        this.Quad.RenderOutline(frustum, viewPoint);
                    }
                    break;

                case BoundaryType.BoundingBox:
                    var boundingBox = (BoundingBox)boundary;
                    if (viewPoint.Frustum.Intersects(boundingBox))
                    {
                        this.Effect.WorldPosition = BoundingSphere.CreateFromBoundingBox(boundingBox).Center;
                        this.Effect.Apply(ColorEffectTechniques.ColorPointDepthTest);
                        this.Quad.RenderOutline(boundingBox, viewPoint);
                    }
                    break;
                }
            }
        }
コード例 #3
0
        public void BoundingSphere_CreateFromFrustumWorksCorrectly_WithOutParam()
        {
            var view    = Matrix.CreateLookAt(new Vector3(0, 0, 5), Vector3.Zero, Vector3.Up);
            var proj    = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4f, 4f / 3f, 1f, 1000f);
            var frustum = new BoundingFrustum(view * proj);

            BoundingSphere.CreateFromFrustum(frustum, out BoundingSphere result);

            if (Environment.Is64BitProcess)
            {
                TheResultingValue(result.Center).WithinDelta(0.0001f)
                .ShouldBe(-0.0853f, 0.06398f, -840.6783f);
                TheResultingValue(result.Radius).WithinDelta(0.0001f)
                .ShouldBe(844.6787f);
            }
            else
            {
                TheResultingValue(result.Center).WithinDelta(0.0001f)
                .ShouldBe(-0.0853f, 0.06398f, -840.6783f);
                TheResultingValue(result.Radius).WithinDelta(0.0001f)
                .ShouldBe(844.6785f);
            }
        }