Ejemplo n.º 1
0
        private static void SetTop(RampType rampType, Dictionary <VoxelVertex, float> top)
        {
            float r = 0.5f;
            List <VoxelVertex> keys = top.Keys.ToList();

            foreach (VoxelVertex vert in keys)
            {
                top[vert] = 1.0f;
            }
            if (rampType.HasFlag(RampType.TopFrontLeft))
            {
                top[VoxelVertex.FrontTopLeft] = r;
            }

            if (rampType.HasFlag(RampType.TopFrontRight))
            {
                top[VoxelVertex.FrontTopRight] = r;
            }

            if (rampType.HasFlag(RampType.TopBackLeft))
            {
                top[VoxelVertex.BackTopLeft] = r;
            }
            if (rampType.HasFlag(RampType.TopBackRight))
            {
                top[VoxelVertex.BackTopRight] = r;
            }
        }
Ejemplo n.º 2
0
        public static bool ShouldRamp(VoxelVertex vertex, RampType rampType)
        {
            bool toReturn = false;

            if (Voxel.HasFlag(rampType, RampType.TopFrontRight))
            {
                toReturn = (vertex == VoxelVertex.BackTopRight);
            }

            if (Voxel.HasFlag(rampType, RampType.TopBackRight))
            {
                toReturn = toReturn || (vertex == VoxelVertex.FrontTopRight);
            }

            if (Voxel.HasFlag(rampType, RampType.TopFrontLeft))
            {
                toReturn = toReturn || (vertex == VoxelVertex.BackTopLeft);
            }

            if (Voxel.HasFlag(rampType, RampType.TopBackLeft))
            {
                toReturn = toReturn || (vertex == VoxelVertex.FrontTopLeft);
            }


            return(toReturn);
        }
Ejemplo n.º 3
0
        public static bool ShouldRamp(VoxelVertex vertex, RampType rampType)
        {
            bool toReturn = false;

            if(Voxel.HasFlag(rampType, RampType.TopFrontRight))
            {
                toReturn = (vertex == VoxelVertex.BackTopRight);
            }

            if(Voxel.HasFlag(rampType, RampType.TopBackRight))
            {
                toReturn = toReturn || (vertex == VoxelVertex.FrontTopRight);
            }

            if(Voxel.HasFlag(rampType, RampType.TopFrontLeft))
            {
                toReturn = toReturn || (vertex == VoxelVertex.BackTopLeft);
            }

            if(Voxel.HasFlag(rampType, RampType.TopBackLeft))
            {
                toReturn = toReturn || (vertex == VoxelVertex.FrontTopLeft);
            }

            return toReturn;
        }
Ejemplo n.º 4
0
        private static bool ShouldRamp(VoxelVertex vertex, RampType rampType)
        {
            bool toReturn = false;

            if ((rampType & RampType.TopFrontRight) == RampType.TopFrontRight)
            {
                toReturn = (vertex == VoxelVertex.FrontTopRight);
            }

            if ((rampType & RampType.TopBackRight) == RampType.TopBackRight)
            {
                toReturn = toReturn || (vertex == VoxelVertex.BackTopRight);
            }

            if ((rampType & RampType.TopFrontLeft) == RampType.TopFrontLeft)
            {
                toReturn = toReturn || (vertex == VoxelVertex.FrontTopLeft);
            }

            if ((rampType & RampType.TopBackLeft) == RampType.TopBackLeft)
            {
                toReturn = toReturn || (vertex == VoxelVertex.BackTopLeft);
            }

            return(toReturn);
        }
Ejemplo n.º 5
0
        protected static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp)
        {
            switch (face)
            {
            case BoxFace.Top:
            case BoxFace.Bottom:
                return(true);

            case BoxFace.Front:
                return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopBackRight,
                                  neighborRamp, RampType.TopFrontLeft, RampType.TopFrontRight));

            case BoxFace.Back:
                return(CheckRamps(myRamp, RampType.TopFrontLeft, RampType.TopFrontRight,
                                  neighborRamp, RampType.TopBackLeft, RampType.TopBackRight));

            case BoxFace.Left:
                return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopFrontLeft,
                                  neighborRamp, RampType.TopBackRight, RampType.TopFrontRight));

            case BoxFace.Right:
                return(CheckRamps(myRamp, RampType.TopBackRight, RampType.TopFrontRight,
                                  neighborRamp, RampType.TopBackLeft, RampType.TopFrontLeft));

            default:
                return(false);
            }
        }
Ejemplo n.º 6
0
        private static bool ShouldDrawFace(FaceOrientation face, RampType neighborRamp, RampType myRamp)
        {
            switch (face)
            {
            case FaceOrientation.Top:
            case FaceOrientation.Bottom:
                return(true);

            case FaceOrientation.South:
                return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopBackRight,
                                  neighborRamp, RampType.TopFrontLeft, RampType.TopFrontRight));

            case FaceOrientation.North:
                return(CheckRamps(myRamp, RampType.TopFrontLeft, RampType.TopFrontRight,
                                  neighborRamp, RampType.TopBackLeft, RampType.TopBackRight));

            case FaceOrientation.West:
                return(CheckRamps(myRamp, RampType.TopBackLeft, RampType.TopFrontLeft,
                                  neighborRamp, RampType.TopBackRight, RampType.TopFrontRight));

            case FaceOrientation.East:
                return(CheckRamps(myRamp, RampType.TopBackRight, RampType.TopFrontRight,
                                  neighborRamp, RampType.TopBackLeft, RampType.TopFrontLeft));

            default:
                return(false);
            }
        }
Ejemplo n.º 7
0
        public static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp)
        {
            if(face == BoxFace.Top || face == BoxFace.Bottom)
            {
                return true;
            }

            return FaceDrawMap[(int) face, (int) myRamp, (int) neighborRamp];
        }
Ejemplo n.º 8
0
        public static bool ShouldDrawFace(BoxFace face, RampType neighborRamp, RampType myRamp)
        {
            if (face == BoxFace.Top || face == BoxFace.Bottom)
            {
                return(true);
            }


            return(FaceDrawMap[(int)face, (int)myRamp, (int)neighborRamp]);
        }
Ejemplo n.º 9
0
        private static void SetTop(RampType rampType, Dictionary<VoxelVertex, float> top)
        {
            float r = 0.5f;
            List<VoxelVertex> keys = top.Keys.ToList();
            foreach (VoxelVertex vert in keys)
            {
                top[vert] = 1.0f;
            }
            if (rampType.HasFlag(RampType.TopFrontLeft))
            {
                top[VoxelVertex.FrontTopLeft] = r;
            }

            if (rampType.HasFlag(RampType.TopFrontRight))
            {
                top[VoxelVertex.FrontTopRight] = r;
            }

            if (rampType.HasFlag(RampType.TopBackLeft))
            {
                top[VoxelVertex.BackTopLeft] = r;
            }
            if (rampType.HasFlag(RampType.TopBackRight))
            {
                top[VoxelVertex.BackTopRight] = r;
            }
        }
Ejemplo n.º 10
0
 public static bool RampIsDegenerate(RampType rampType)
 {
     return(rampType == RampType.All ||
            (Voxel.HasFlag(rampType, RampType.Left) && Voxel.HasFlag(rampType, RampType.Right)) ||
            (Voxel.HasFlag(rampType, RampType.Front) && Voxel.HasFlag(rampType, RampType.Back)));
 }
Ejemplo n.º 11
0
 public static bool HasFlag(RampType ramp, RampType flag)
 {
     return((ramp & flag) == flag);
 }
Ejemplo n.º 12
0
 public uint RampToVolume(Channel channel, RampType rampType, short desiredVolume)
 {
     return(UPnP.InvokeAction <uint>(_service, "RampToVolume", InstanceId, channel.ToString(), rampType.ToString(), desiredVolume));
 }
Ejemplo n.º 13
0
    public static RenderGeometry CreateStraightRampGeometry(
        float width, float height, float length, int segmentWidth, int segmentLength, bool smoothWidth, bool smoothLength, RampType rampType = RampType.Right, float curvature = 0,
        float baseHeight = 0, float highPlatformWidth = 0, float lowPlatformWidth = 0)
    {
        StructureGeometry structure = new StructureGeometry();

        RenderGeometry.FaceType rampFaceType = GetFaceType(smoothWidth, smoothLength);
        RenderGeometry.FaceType sideFaceType = GetFaceType(false, smoothLength);

        float leftPlatformHeight   = (rampType == RampType.Left || rampType == RampType.Peak ? 0 : height) + baseHeight;
        float rightPlatformHeight  = (rampType == RampType.Right || rampType == RampType.Peak ? 0 : height) + baseHeight;
        float middlePlatformHeight = (rampType == RampType.Valley ? 0 : height) + baseHeight;

        float leftPlatformWidth   = ((rampType == RampType.Left || rampType == RampType.Peak) ? lowPlatformWidth : highPlatformWidth);
        float rightPlatformWidth  = ((rampType == RampType.Right || rampType == RampType.Peak) ? lowPlatformWidth : highPlatformWidth);
        float middlePlatformWidth = (rampType == RampType.Valley ? lowPlatformWidth : (rampType == RampType.Peak ? highPlatformWidth : 0));

        float leftX  = -width / 2 - middlePlatformWidth / 2;
        float rightX = width / 2 + middlePlatformWidth / 2;

        bool   isLeftTopAndBottomSameVertex  = (rampType == RampType.Left || rampType == RampType.Peak) && baseHeight == 0;
        bool   isRightTopAndBottomSameVertex = (rampType == RampType.Right || rampType == RampType.Peak) && baseHeight == 0;
        Vertex cornerBottomLeft1             = structure.CreateVertex(new Vector3(leftX, 0, -length / 2));
        Vertex cornerBottomLeft2             = structure.CreateVertex(new Vector3(leftX, 0, length / 2));
        Vertex cornerBottomRight1            = structure.CreateVertex(new Vector3(rightX, 0, -length / 2));
        Vertex cornerBottomRight2            = structure.CreateVertex(new Vector3(rightX, 0, length / 2));
        Vertex cornerTopLeft1  = isLeftTopAndBottomSameVertex ? cornerBottomLeft1 : structure.CreateVertex(new Vector3(leftX, leftPlatformHeight, -length / 2));
        Vertex cornerTopLeft2  = isLeftTopAndBottomSameVertex ? cornerBottomLeft2 : structure.CreateVertex(new Vector3(leftX, leftPlatformHeight, length / 2));
        Vertex cornerTopRight1 = isRightTopAndBottomSameVertex ? cornerBottomRight1 : structure.CreateVertex(new Vector3(rightX, rightPlatformHeight, -length / 2));
        Vertex cornerTopRight2 = isRightTopAndBottomSameVertex ? cornerBottomRight2 : structure.CreateVertex(new Vector3(rightX, rightPlatformHeight, length / 2));

        if (rampType == RampType.Left || rampType == RampType.Right)
        {
            CreateStraightRampPart(
                structure, rampType == RampType.Left,
                cornerTopLeft1, cornerTopLeft2, cornerTopRight1, cornerTopRight2,
                cornerBottomLeft1, cornerBottomLeft2, cornerBottomRight1, cornerBottomRight2,
                leftPlatformWidth == 0, rightPlatformWidth == 0, segmentWidth, segmentLength, curvature, rampFaceType, sideFaceType);
        }
        else
        {
            bool   isMiddleTopAndBottomSameVertex = rampType == RampType.Valley && baseHeight == 0;
            bool   isMiddleLeftAndRightSameVertex = middlePlatformWidth == 0 && !isMiddleTopAndBottomSameVertex;
            Vertex cornerBottomMiddleLeft1        = structure.CreateVertex(new Vector3(-middlePlatformWidth / 2, 0, -length / 2));
            Vertex cornerBottomMiddleLeft2        = structure.CreateVertex(new Vector3(-middlePlatformWidth / 2, 0, length / 2));
            Vertex cornerBottomMiddleRight1       = isMiddleLeftAndRightSameVertex ? cornerBottomMiddleLeft1 : structure.CreateVertex(new Vector3(middlePlatformWidth / 2, 0, -length / 2));
            Vertex cornerBottomMiddleRight2       = isMiddleLeftAndRightSameVertex ? cornerBottomMiddleLeft2 : structure.CreateVertex(new Vector3(middlePlatformWidth / 2, 0, length / 2));
            Vertex cornerTopMiddleLeft1           = isMiddleTopAndBottomSameVertex ? cornerBottomMiddleLeft1 : structure.CreateVertex(new Vector3(-middlePlatformWidth / 2, middlePlatformHeight, -length / 2));
            Vertex cornerTopMiddleLeft2           = isMiddleTopAndBottomSameVertex ? cornerBottomMiddleLeft2 : structure.CreateVertex(new Vector3(-middlePlatformWidth / 2, middlePlatformHeight, length / 2));
            Vertex cornerTopMiddleRight1          = isMiddleTopAndBottomSameVertex ? cornerBottomMiddleRight1 : structure.CreateVertex(new Vector3(middlePlatformWidth / 2, middlePlatformHeight, -length / 2));
            Vertex cornerTopMiddleRight2          = isMiddleTopAndBottomSameVertex ? cornerBottomMiddleRight2 : structure.CreateVertex(new Vector3(middlePlatformWidth / 2, middlePlatformHeight, length / 2));
            CreateStraightRampPart(
                structure, rampType == RampType.Peak,
                cornerTopLeft1, cornerTopLeft2, cornerTopMiddleLeft1, cornerTopMiddleLeft2,
                cornerBottomLeft1, cornerBottomLeft2, cornerBottomMiddleLeft1, cornerBottomMiddleLeft2,
                leftPlatformWidth == 0, false, segmentWidth, segmentLength, curvature, rampFaceType, sideFaceType);
            CreateStraightRampPart(
                structure, rampType == RampType.Valley,
                cornerTopMiddleRight1, cornerTopMiddleRight2, cornerTopRight1, cornerTopRight2,
                cornerBottomMiddleRight1, cornerBottomMiddleRight2, cornerBottomRight1, cornerBottomRight2,
                false, rightPlatformWidth == 0, segmentWidth, segmentLength, curvature, rampFaceType, sideFaceType);
            if (middlePlatformWidth > 0)
            {
                CreateStraightPlatformPart(
                    structure,
                    cornerTopMiddleLeft1, cornerTopMiddleLeft2, cornerTopMiddleRight1, cornerTopMiddleRight2,
                    cornerBottomMiddleLeft1, cornerBottomMiddleLeft2, cornerBottomMiddleRight1, cornerBottomMiddleRight2,
                    false, false, segmentLength, sideFaceType);
            }
        }

        if (leftPlatformWidth > 0)
        {
            Vertex cornerBottomFarLeft1 = structure.CreateVertex(cornerBottomLeft1.p + leftPlatformWidth * Vector3.left);
            Vertex cornerBottomFarLeft2 = structure.CreateVertex(cornerBottomLeft2.p + leftPlatformWidth * Vector3.left);
            Vertex cornerTopFarLeft1    = cornerTopLeft1 == cornerBottomLeft1 ? cornerBottomFarLeft1 : structure.CreateVertex(cornerTopLeft1.p + leftPlatformWidth * Vector3.left);
            Vertex cornerTopFarLeft2    = cornerTopLeft2 == cornerBottomLeft2 ? cornerBottomFarLeft2 : structure.CreateVertex(cornerTopLeft2.p + leftPlatformWidth * Vector3.left);
            CreateStraightPlatformPart(
                structure,
                cornerTopFarLeft1, cornerTopFarLeft2, cornerTopLeft1, cornerTopLeft2,
                cornerBottomFarLeft1, cornerBottomFarLeft2, cornerBottomLeft1, cornerBottomLeft2,
                true, false, segmentLength, sideFaceType);
        }
        if (rightPlatformWidth > 0)
        {
            Vertex cornerBottomFarRight1 = structure.CreateVertex(cornerBottomRight1.p + rightPlatformWidth * Vector3.right);
            Vertex cornerBottomFarRight2 = structure.CreateVertex(cornerBottomRight2.p + rightPlatformWidth * Vector3.right);
            Vertex cornerTopFarRight1    = cornerTopRight1 == cornerBottomRight1 ? cornerBottomFarRight1 : structure.CreateVertex(cornerTopRight1.p + rightPlatformWidth * Vector3.right);
            Vertex cornerTopFarRight2    = cornerTopRight2 == cornerBottomRight2 ? cornerBottomFarRight2 : structure.CreateVertex(cornerTopRight2.p + rightPlatformWidth * Vector3.right);
            CreateStraightPlatformPart(
                structure,
                cornerTopRight1, cornerTopRight2, cornerTopFarRight1, cornerTopFarRight2,
                cornerBottomRight1, cornerBottomRight2, cornerBottomFarRight1, cornerBottomFarRight2,
                false, true, segmentLength, sideFaceType);
        }
        return(structure.Build());
    }
Ejemplo n.º 14
0
 private static bool CheckRamps(RampType A, RampType A1, RampType A2, RampType B, RampType B1, RampType B2)
 {
     return((!RampSet(A, A1) && RampSet(B, B1)) || (!RampSet(A, A2) && RampSet(B, B2)));
 }
Ejemplo n.º 15
0
 private static bool RampSet(RampType ToCheck, RampType For)
 {
     return((ToCheck & For) != 0);
 }
Ejemplo n.º 16
0
 public uint RampToVolume(Channel channel, RampType rampType, short desiredVolume)
 {
     return UPnP.InvokeAction<uint>(_service, "RampToVolume", InstanceId, channel.ToString(), rampType.ToString(), desiredVolume);
 }
Ejemplo n.º 17
0
    public static RenderGeometry CreateTurningRampGeometry(
        float width, float height, float angle, float extraRadius, int segmentWidth, int segmentLength, bool smoothWidth, bool smoothLength, RampType rampType = RampType.Right, float curvature = 0,
        float baseHeight = 0, float highSideWidth = 0, float lowSideWidth = 0)
    {
        StructureGeometry structure = new StructureGeometry();

        RenderGeometry.FaceType rampFaceType = GetFaceType(smoothWidth, smoothLength);
        RenderGeometry.FaceType sideFaceType = GetFaceType(false, smoothLength);

        return(structure.Build());
    }
Ejemplo n.º 18
0
 public static bool RampIsDegenerate(RampType rampType)
 {
     return rampType == RampType.All
            || (Voxel.HasFlag(rampType, RampType.Left) && Voxel.HasFlag(rampType, RampType.Right))
            || (Voxel.HasFlag(rampType, RampType.Front) && Voxel.HasFlag(rampType, RampType.Back));
 }
Ejemplo n.º 19
0
 public static bool HasFlag(RampType ramp, RampType flag)
 {
     return (ramp & flag) == flag;
 }