Ejemplo n.º 1
0
        private float PopulateCompleteSide(ref CrossSection face, int quadrant, float halfCubeWidth, bool outer)
        {
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

            Vector3 startPoint = ReferenceVertices[quadrant];
            Vector3 endPoint;

            if (quadrant < NumberFaces - 1)
            {
                endPoint = ReferenceVertices[quadrant + 1];
            }
            else
            {
                endPoint = ReferenceVertices[0];
            }

            startPoint = startPoint * halfCubeWidth / 0.5f;
            endPoint   = endPoint * halfCubeWidth / 0.5f;

            if (outer)
            {
                face.AddPoint(startPoint);
                face.AddPoint(endPoint);
            }
            else
            {
                face.AddPoint(endPoint);
                face.AddPoint(startPoint);
            }

            return(2f * halfCubeWidth);
        }
Ejemplo n.º 2
0
        // Handles the first face in the cut, starting from cutstart,
        // and running anticlockwise to first reference vertex
        private float PopulateSingleCutFacePositiveDirection(ref CrossSection face, Vector3 cutPoint, int quadrant,
                                                             float halfCubeWidth, bool outer)
        {
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

            Vector3 startPoint = cutPoint;
            Vector3 endPoint;

            if (quadrant < NumberFaces - 1)
            {
                endPoint = ReferenceVertices[quadrant + 1] * halfCubeWidth / 0.5f;
            }
            else
            {
                endPoint = ReferenceVertices[0] * halfCubeWidth / 0.5f;
            }

            if (outer)
            {
                face.AddPoint(startPoint);
                face.AddPoint(endPoint);
            }
            else
            {
                face.AddPoint(endPoint);
                face.AddPoint(startPoint);
            }

            return(Vector3.Distance(startPoint, endPoint));
        }
        public PrimVisualCylinder(PrimObject prim)
            : base(prim)
        {
            NumberFaces = 1;
            FirstOuterFace = 0;
            LastOuterFace = 0;

            OuterFaces = new CrossSection[1];
            OuterFaces[0] = new CrossSection();

            if (prim.ProfileHollow != 0)
            {
                hollow = true;
                InnerFaces = new CrossSection[1];
                InnerFaces[0] = new CrossSection();

                //for (int i = 0; i < 4; i++)
                //{
                //    InnerFaces[i] = new CrossSection();
                //}
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
Ejemplo n.º 4
0
        public PrimVisualCylinder(PrimObject prim)
            : base(prim)
        {
            NumberFaces    = 1;
            FirstOuterFace = 0;
            LastOuterFace  = 0;

            OuterFaces    = new CrossSection[1];
            OuterFaces[0] = new CrossSection();

            if (prim.ProfileHollow != 0)
            {
                hollow        = true;
                InnerFaces    = new CrossSection[1];
                InnerFaces[0] = new CrossSection();

                //for (int i = 0; i < 4; i++)
                //{
                //    InnerFaces[i] = new CrossSection();
                //}
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut      = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
        public PrimVisualBox(PrimObject prim)
            : base(prim)
        {
            NumberFaces = 4;
            FirstOuterFace = 0;
            LastOuterFace = 3;

            ReferenceVertices = new Vector3[4];

            ReferenceVertices[1] = new Vector3(0.5f, -0.5f, 0f);
            ReferenceVertices[2] = new Vector3(0.5f, 0.5f, 0f);
            ReferenceVertices[3] = new Vector3(-0.5f, 0.5f, 0f);
            ReferenceVertices[0] = new Vector3(-0.5f, -0.5f, 0f);

            OuterFaces = new CrossSection[4];
            for (int i = 0; i < 4; i++)
            {
                OuterFaces[i] = new CrossSection();
            }

            if (prim.ProfileHollow != 0)
            {
                hollow = true;
                InnerFaces = new CrossSection[4];
                for (int i = 0; i < 4; i++)
                {
                    InnerFaces[i] = new CrossSection();
                }
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
Ejemplo n.º 6
0
        public PrimVisualRing(PrimObject prim)
            : base(prim)
        {
            NumberFaces    = 3;
            FirstOuterFace = 0;
            LastOuterFace  = 2;

            ReferenceVertices = new Vector3[3];

            ReferenceVertices[0] = new Vector3(0.5f, -0.5f, 0f);
            ReferenceVertices[1] = new Vector3(0f, 0.5f, 0f);
            ReferenceVertices[2] = new Vector3(-0.5f, -0.5f, 0f);

            OuterFaces = new CrossSection[4];
            for (int i = 0; i < 4; i++)
            {
                OuterFaces[i] = new CrossSection();
            }

            if (prim.ProfileHollow != 0)
            {
                hollow     = true;
                InnerFaces = new CrossSection[4];
                for (int i = 0; i < 4; i++)
                {
                    InnerFaces[i] = new CrossSection();
                }
            }

            if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1)
            {
                cut      = true;
                CutFaces = new CrossSection[2];
                for (int i = 0; i < 2; i++)
                {
                    CutFaces[i] = new CrossSection();
                }
            }

            BuildFaces();
        }
        // Handles the first face in the cut, starting from cutstart,
        // and running anticlockwise to first reference vertex
        private float PopulateSingleCutFacePositiveDirection(ref CrossSection face, Vector3 cutPoint, int quadrant, 
            float halfCubeWidth, bool outer)
        {
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

            Vector3 startPoint = cutPoint;
            Vector3 endPoint;
            if (quadrant < NumberFaces - 1)
            {
                endPoint = ReferenceVertices[quadrant + 1] * halfCubeWidth / 0.5f;
            }
            else
            {
                endPoint = ReferenceVertices[0] * halfCubeWidth / 0.5f;
            }

            if (outer)
            {
                face.AddPoint(startPoint);
                face.AddPoint(endPoint);
            }
            else
            {
                face.AddPoint(endPoint);
                face.AddPoint(startPoint);
            }

            return Vector3.Distance(startPoint, endPoint);
        }
        private float PopulateCompleteSide(ref CrossSection face, int quadrant, float halfCubeWidth, bool outer)
        {
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

            Vector3 startPoint = ReferenceVertices[quadrant];
            Vector3 endPoint;
            if (quadrant < NumberFaces - 1)
            {
                endPoint = ReferenceVertices[quadrant + 1];
            }
            else
            {
                endPoint = ReferenceVertices[0];
            }

            startPoint = startPoint * halfCubeWidth / 0.5f;
            endPoint = endPoint * halfCubeWidth / 0.5f;

            if (outer)
            {
                face.AddPoint(startPoint);
                face.AddPoint(endPoint);
            }
            else
            {
                face.AddPoint(endPoint);
                face.AddPoint(startPoint);
            }

            return 2f * halfCubeWidth;
        }
        protected void BuildSideVertexes(CrossSection[] crossSection, int transforms)
        {
            float transformOffset = 1.0f / (float)transforms;
            float currentOffset = -0.5f;

            for (int i = 0; i < transforms; i++)
            {
                for (int j = 0; j < crossSection.Length; j++)
                {
                    int pointCount = crossSection[j].GetNumPoints();

                    if (pointCount > 0)
                    {
                        for (int k = 0; k < pointCount - 1; k++)
                        {
                            Vector3 lower1, lower2, upper1, upper2;
                            float lowerRatio = (float)i / (float)transforms;
                            float upperRatio = (float)(i + 1) / (float)transforms;

                            lower1 = crossSection[j].GetRawVertex(k);
                            lower2 = crossSection[j].GetRawVertex(k + 1);

                            lower1.Z = currentOffset;
                            lower2.Z = currentOffset;

                            upper1 = lower1;
                            upper2 = lower2;

                            upper1.Z = currentOffset + transformOffset;
                            upper2.Z = currentOffset + transformOffset;

                            lower1 = Transform(lower1, lowerRatio);
                            lower2 = Transform(lower2, lowerRatio);
                            upper1 = Transform(upper1, upperRatio);
                            upper2 = Transform(upper2, upperRatio);

                            Vertexes.Add(new VertexPositionColor(lower1, color));
                            Vertexes.Add(new VertexPositionColor(lower2, color));
                            Vertexes.Add(new VertexPositionColor(upper2, color));

                            Vertexes.Add(new VertexPositionColor(lower1, color));
                            Vertexes.Add(new VertexPositionColor(upper2, color));
                            Vertexes.Add(new VertexPositionColor(upper1, color));
                        }
                    }
                }

                currentOffset += transformOffset;
            }
        }