Ejemplo n.º 1
0
        public PrimVisualCylinder(OpenMetaverse.Primitive prim)
            : base(prim)
        {
            NumberFaces = 1;
            FirstOuterFace = 0;
            LastOuterFace = 0;

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

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

            BuildFaces();
        }
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, OpenMetaverse.Vector3 cutPoint, int quadrant, 
            float halfCubeWidth, bool outer)
        {
            V3ToV3Xna XnaOMV = new V3ToV3Xna();
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

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

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

            return OpenMetaverse.Vector3.Distance(startPoint, endPoint);
        }
Ejemplo n.º 3
0
        private float PopulateCompleteSide(ref CrossSection face, int quadrant, float halfCubeWidth, bool outer)
        {
            V3ToV3Xna XnaOMV = new V3ToV3Xna();
            quadrant = NormalizeQuadrant(quadrant);

            face.RemoveAllPoints();

            OpenMetaverse.Vector3 startPoint = XnaOMV.V3XToV3(ReferenceVertices[quadrant]);
            OpenMetaverse.Vector3 endPoint;
            if (quadrant < NumberFaces - 1)
            {
                endPoint = XnaOMV.V3XToV3(ReferenceVertices[quadrant + 1]);
            }
            else
            {
                endPoint = XnaOMV.V3XToV3(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.º 4
0
        protected void BuildSideVertexes(CrossSection[] crossSection, int transforms)
        {
            V3ToV3Xna XnaOMV = new V3ToV3Xna();
            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 = XnaOMV.V3ToV3X(crossSection[j].GetRawVertex(k));
                            lower2 = XnaOMV.V3ToV3X(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;
            }
        }