예제 #1
0
        /// <summary>
        /// Initializes the Points and Triangles collections.
        /// Called By Sculptor.BuildMesh()
        /// </summary>
        protected override void CreateTriangles()
        {
            ConicalSculptor _conicalSculptor = new ConicalSculptor(40, 0.0f, 0.0f);

            _conicalSculptor.BuildMesh();
            ModelTransformGroup tgHead = new ModelTransformGroup();

            tgHead.Children.Add(new Scaling(0.2f, 0.2f, _headUnitRatio));
            // tgHead.Children.Add(new Translation(0.0f, 0.0f, _length - 1.0f + 0.8f));
            tgHead.Children.Add(new Translation(0.0f, 0.0f, _length - _headUnitRatio));
            _conicalSculptor.Transform(tgHead);
            CopyFrom(_conicalSculptor);

            BarSculptor _barSculptor = new BarSculptor();

            _barSculptor.Initialize(40, 0.0f, 0.0f);
            _barSculptor.BuildMesh();
            // _barSculptor.Transform(new Scaling(0.1f, 0.1f, _length - 1.0f + 0.8f));
            _barSculptor.Transform(new Scaling(0.1f, 0.1f, _length - _headUnitRatio));
            CopyFrom(_barSculptor);
        }
        /// <summary>
        /// Creates the 3 arrows objects
        /// </summary>
        /// <param name="s">Sign enum value.</param>
        private void CreateArrows(Sign s)
        {
            float headUnitRatio = 0.2f;
            // float arrowScaleFactor = _radius * 10.0 / 2.0;
            float   arrowScaleFactor = _radius * 10.0f;
            Scaling arrowScaling     = new Scaling(arrowScaleFactor, arrowScaleFactor, 1.0f);

            DartSculptor asZ = new DartSculptor();

            asZ.Initialize(_length, headUnitRatio);
            asZ.BuildMesh();
            ModelTransformGroup tgZ = new ModelTransformGroup();

            tgZ.Children.Add(arrowScaling);
            if (((s == Sign.Negative) && (_coordinateSystemKind == CoordinateSystemKind.RightHanded)) ||
                ((s == Sign.Positive) && (_coordinateSystemKind == CoordinateSystemKind.LeftHanded)))
            {
                tgZ.Children.Add(new Rotation(180.0f, AxisDirection.Y));
            }
            asZ.Transform(tgZ);
            CopyFrom(asZ);

            DartSculptor asX = new DartSculptor();

            asX.Initialize(_length, headUnitRatio);
            asX.BuildMesh();
            ModelTransformGroup tgX = new ModelTransformGroup();

            tgX.Children.Add(arrowScaling);
            tgX.Children.Add(new Rotation(s == Sign.Positive ? 90.0f : -90.0f, AxisDirection.Y));
            asX.Transform(tgX);
            CopyFrom(asX);

            DartSculptor asY = new DartSculptor();

            asY.Initialize(_length, headUnitRatio);
            asY.BuildMesh();
            ModelTransformGroup tgY = new ModelTransformGroup();

            tgY.Children.Add(arrowScaling);
            tgY.Children.Add(new Rotation(s == Sign.Positive ? -90.0f : 90.0f, AxisDirection.X));
            asY.Transform(tgY);
            CopyFrom(asY);

            if (_length > 1.0)
            {
                float           sepRadius = _radius * 2.0f;
                int             sep       = Convert.ToInt32(_length) - 1;
                BarSculptor[][] bars      = new BarSculptor[sep][];
                Rotation[]      r         = new Rotation[2];
                r[0] = new Rotation(s == Sign.Positive ? 90.0f : -90.0f, AxisDirection.Y);
                r[1] = new Rotation(s == Sign.Positive ? -90.0f : 90.0f, AxisDirection.X);
                for (int i = 0; i < sep; i++)
                {
                    int offset  = (s == Sign.Positive ? i + 1 : -i - 1);
                    int offsetZ = (
                        (((s == Sign.Positive) && (_coordinateSystemKind == CoordinateSystemKind.RightHanded)) ||
                         ((s == Sign.Negative) && (_coordinateSystemKind == CoordinateSystemKind.LeftHanded))) ?
                        i + 1 : -i - 1);
                    bars[i] = new BarSculptor[3];
                    for (int j = 0; j < 3; j++)
                    {
                        bars[i][j] = new BarSculptor();
                        bars[i][j].Initialize(40, 0.0f, 0.0f);
                        bars[i][j].BuildMesh();
                        ModelTransformGroup tg = new ModelTransformGroup();
                        tg.Children.Add(new Scaling(sepRadius, sepRadius, 0.01f));
                        if (j != 2)
                        {
                            tg.Children.Add(r[j]);
                        }
                        tg.Children.Add(new Translation(
                                            j == 0 ? offset : 0.0f,
                                            j == 1 ? offset : 0.0f,
                                            j == 2 ? offsetZ : 0.0f));
                        bars[i][j].Transform(tg);
                        CopyFrom(bars[i][j]);
                    }
                }
            }
        }