Exemplo n.º 1
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            SingleSelectParameter unit = args[0] as SingleSelectParameter;
            bool degree = unit.Value == 0;

            MotionObjectInfo info1  = selected[0];
            MotionObjectInfo info2  = selected[1];
            TimeSeriesValues values = new TimeSeriesValues(degree ? "degree" : "radian");

            foreach (ReadOnlyMotionFrame frame in frames)
            {
                LineObject line1 = frame[info1] as LineObject;
                LineObject line2 = frame[info2] as LineObject;
                if (line1 != null && line2 != null)
                {
                    float  cos    = Vector3.Dot(line1.Direction(), line2.Direction());
                    double radian = 0;
                    if (cos <= -1)
                    {
                        radian = Math.PI;
                    }
                    else if (cos < 1)
                    {
                        radian = Math.Acos(cos);
                    }
                    if (degree)
                    {
                        values.SetValue(frame.Time, (decimal)(radian * 180 / Math.PI));
                    }
                    else
                    {
                        values.SetValue(frame.Time, (decimal)radian);
                    }
                }
                else
                {
                    values.SetValue(frame.Time, null);
                }
            }
            SequenceData data = new SequenceData(values, null, PathEx.GiveName("Angle", info1.Name, info2.Name));

            return(new SequenceData[] { data });
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter mode  = args[0] as SingleSelectParameter;
            NumberParameter       value = args[1] as NumberParameter;
            List <MotionObject>   ret   = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                LineObject line = frame[info] as LineObject;
                if (line != null)
                {
                    float length = line.Edge.Length();
                    try {
                        switch (mode.Value)
                        {
                        case 0:
                            length *= (float)value.Value;
                            break;

                        case 1:
                            length = (float)value.Value;
                            break;

                        case 2:
                            length += (float)value.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    ret.Add(new LineObject(line.Position, line.Direction() * length));
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }