/// <summary>
        /// Initializes the Points and Triangles collections.
        /// Called By Sculptor.BuildMesh()
        /// </summary>
        protected override void CreateTriangles()
        {
            _ps1 = new PolygonSculptor();
            _ps1.Initialize(_circumferenceSideCount, _initialAngle);
            _ps1.RoundingRate = _roundingRate;
            _ps1.BuildTriangles(TriangleSideKind.Back);
            foreach (Vector3Triplet tpl in _ps1.Triangles)
            {
                this.Triangles.Add(tpl);
            }
            foreach (Vector3 p in _ps1.Points)
            {
                this.Points.Add(p);
            }

            _ps2 = new PolygonSculptor();
            _ps2.Initialize(_circumferenceSideCount, _initialAngle);
            _ps2.RoundingRate = _roundingRate;
            _ps2.Center       = new Vector3(
                _ps2.Center.X,
                _ps2.Center.Y,
                _ps2.Center.Z + 1.0f);
            this.Points.Add(_ps2.Center);
            _ps2.BuildTriangles(TriangleSideKind.Front);
            foreach (Vector3Triplet tpl in _ps2.Triangles)
            {
                this.Triangles.Add(tpl);
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes the Points and Triangles collections.
        /// Called By Sculptor.BuildMesh()
        /// </summary>
        /// <remarks>The cull mode is supposed to be clockwise (front faces are counter-clockwise).</remarks>
        protected override void CreateTriangles()
        {
            Vector3 radiusVector = new Vector3(_radius, 0, 0);

            PolygonSculptor pv1 = new PolygonSculptor();

            pv1.Initialize(_circumferenceSideCount, _initialAngle);
            pv1.RoundingRate = _roundingRate;
            pv1.RoundCorner();
            int circumferencePointCount = pv1.Points.Count;

            foreach (Vector3 p in pv1.Points)
            {
                Vector3 p1 = new Vector3(p.X, p.Y, p.Z) + radiusVector;
                this.Points.Add(p1);
            }

            float thetaStep = 2 * MathHelper.Pi / _segmentCount;
            float theta     = 0.0f;

            for (int i = 1; i <= _segmentCount; i++)
            {
                theta = (thetaStep * i);
                Vector3 thetaVector = new Vector3(
                    (float)Math.Cos(theta),
                    0,
                    (float)Math.Sin(theta));

                for (int i1 = 0; i1 < circumferencePointCount; i1++)
                {
                    Vector3 p2 = Helper3D.RotateVector(Points[i1], theta, AxisDirection.Y);
                    this.Points.Add(p2);
                }

                for (int j = 0; j < circumferencePointCount; j++)
                {
                    int index1Min  = (i - 1) * circumferencePointCount;
                    int index1     = index1Min + j;
                    int index2Min  = i * circumferencePointCount;
                    int index2     = index2Min + j;
                    int indexLimit = index2Min + circumferencePointCount - 1;

                    if (index2 < indexLimit)
                    {
                        this.Triangles.Add(new Vector3Triplet(Points[index2], Points[index2 + 1], Points[index1]));
                        this.Triangles.Add(new Vector3Triplet(Points[index2 + 1], Points[index1 + 1], Points[index1]));
                    }
                    else
                    {
                        this.Triangles.Add(new Vector3Triplet(Points[index2], Points[index2Min], Points[index1]));
                        this.Triangles.Add(new Vector3Triplet(Points[index2Min], Points[index1Min], Points[index1]));
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes the Points and Triangles collections.
        /// Called By Sculptor.BuildMesh()
        /// </summary>
        /// <remarks>The cull mode is supposed to be clockwise (front faces are counter-clockwise).</remarks>
        protected override void CreateTriangles()
        {
            _ps1 = new PolygonSculptor();
            _ps1.Initialize(_circumferenceSideCount, _initialAngle);
            _ps1.RoundingRate = _roundingRate;
            _ps1.BuildTriangles(TriangleSideKind.Back);
            foreach (Vector3 p in _ps1.Points)
            {
                this.Points.Add(p);
            }
            foreach (Vector3Triplet tpl in _ps1.Triangles)
            {
                this.Triangles.Add(tpl);
            }

            _ps2 = new PolygonSculptor();
            _ps2.Initialize(_circumferenceSideCount, _initialAngle);
            _ps2.Center = new Vector3(
                _ps2.Center.X,
                _ps2.Center.Y,
                _ps2.Center.Z + 1.0f);
            for (int i = 0; i < _ps2.Points.Count; i++)
            {
                _ps2.Points[i] = new Vector3(
                    _ps2.Points[i].X,
                    _ps2.Points[i].Y,
                    _ps2.Points[i].Z + 1.0f);
                this.Points.Add(_ps2.Points[i]);
            }
            _ps2.RoundingRate = _roundingRate;
            _ps2.BuildTriangles(TriangleSideKind.Front);

            foreach (Vector3Triplet tpl in _ps2.Triangles)
            {
                this.Triangles.Add(tpl);
            }

            for (int i = 0; i < _ps1.Points.Count; i++)
            {
                if (i < _ps1.Points.Count - 1)
                {
                    this.Triangles.Add(new Vector3Triplet(_ps1.Points[i], _ps2.Points[i + 1], _ps2.Points[i]));
                    this.Triangles.Add(new Vector3Triplet(_ps1.Points[i], _ps1.Points[i + 1], _ps2.Points[i + 1]));
                }
                else
                {
                    this.Triangles.Add(new Vector3Triplet(_ps1.Points[i], _ps2.Points[0], _ps2.Points[i]));
                    this.Triangles.Add(new Vector3Triplet(_ps1.Points[i], _ps1.Points[0], _ps2.Points[0]));
                }
            }
        }