Beispiel #1
0
        public void Write(StringWriter fileBuffer, IList rawSkeleton, object rawKeyframe)
        {
            BoneKeyframe keyframe = rawKeyframe as BoneKeyframe;

            fileBuffer.WriteLine("time " + keyframe.Time);

            foreach (Bone bone in keyframe.Bones)
            {
                int boneIndex = keyframe.Bones.IndexOf(bone);
                fileBuffer.Write(boneIndex + " ");
                int    parentIndex = bone.Node.ParentIndex;
                CFrame boneCFrame  = bone.C0;
                if (DeltaSequence)
                {
                    Bone refBone = BaseRig[boneIndex];
                    boneCFrame = refBone.C0 * boneCFrame;
                    Node refNode        = refBone.Node;
                    int  refParentIndex = refNode.ParentIndex;
                    if (refParentIndex >= 0)
                    {
                        Bone refParent = BaseRig[refParentIndex];
                        boneCFrame = refParent.C1.inverse() * boneCFrame;
                    }
                }
                else if (parentIndex >= 0)
                {
                    Bone parentBone = keyframe.Bones[parentIndex];
                    boneCFrame = parentBone.C1.inverse() * boneCFrame;
                }

                fileBuffer.Write(boneCFrame.ToStudioMdlString());
                fileBuffer.WriteLine();
            }
        }
        /*
         * 释放页面弹窗
         */
        private void releaseFrameDialogCanvas(FrameworkElement element)
        {
            Canvas frameDialogCanvas = (Canvas)element;
            Canvas innerCanvas       = null;

            foreach (FrameworkElement ele in frameDialogCanvas.Children)
            {
                if (ele is Canvas)
                {
                    Canvas tmp = (Canvas)ele;
                    if (tmp.Name == "innerCanvas")
                    {
                        innerCanvas = tmp;
                    }
                }
            }

            if (innerCanvas != null)
            {
                foreach (FrameworkElement ele in innerCanvas.Children)
                {
                    if (ele is CFrame)
                    {
                        CFrame cFrame = (CFrame)ele;
                        cFrame.Content = null;
                        cFrame         = null;
                    }
                    else if (ele is Button)
                    {
                        Button closebtn = (Button)ele;
                        closebtn.Background = null;
                    }
                }
            }
        }
        public static void OverwriteHead(DataModelMesh mesh, BasePart head)
        {
            Contract.Requires(mesh != null && head != null);
            DataModelMesh currentMesh = head.FindFirstChild <DataModelMesh>("Mesh");

            if (currentMesh != null)
            {
                currentMesh.Destroy();
            }

            mesh.Name   = "Mesh";
            mesh.Parent = head;

            // Apply Rthro adjustments
            Vector3Value[] overrides = mesh.GetChildrenOfType <Vector3Value>();

            foreach (Vector3Value overrider in overrides)
            {
                Attachment attachment = head.FindFirstChild <Attachment>(overrider.Name);
                if (attachment != null)
                {
                    CFrame cf = attachment.CFrame;
                    attachment.CFrame = new CFrame(overrider.Value) * (cf - cf.Position);
                }
            }

            // Move any extra instances into the Head.
            var extraInstances = mesh.GetChildren()
                                 .Except(overrides)
                                 .ToList();

            extraInstances.ForEach((inst) => inst.Parent = head);
        }
        /*
         * 1.1 释放一个弹窗
         */
        public static void ReleaseOneFrameDialog(Grid mainGrid, Canvas frameDialogCanvas)
        {
            for (int j = 0; j < frameDialogCanvas.Children.Count; j++)
            {
                FrameworkElement Ej = (FrameworkElement)frameDialogCanvas.Children[j];
                if (Ej is Canvas && Ej.Name == "innerCanvas")
                {
                    Canvas innerCanvas = (Canvas)Ej;

                    foreach (FrameworkElement ele in innerCanvas.Children)
                    {
                        if (ele is CFrame)
                        {
                            CFrame cFrame = (CFrame)ele;
                            cFrame.Content = null;
                            cFrame         = null;
                        }
                        else if (ele is Button)
                        {
                            Button closebtn = (Button)ele;
                            closebtn.Background = null;
                        }
                    }

                    break;
                }
            }
            mainGrid.Children.Remove(frameDialogCanvas);
        }
Beispiel #5
0
 public void BakeGeometry(Vector3 scale, CFrame offset)
 {
     for (int i = 0; i < VertCount; i++)
     {
         Verts[i].Pos = (offset * new CFrame(Verts[i].Pos * scale)).p;
     }
 }
Beispiel #6
0
        /// <inheritdoc />
        public Weld()
        {
            _c0 = CFrame.Identity;
            _c1 = CFrame.Identity;

            RunService.Service.SimulationStarted.Event += OnSessionStarted;
        }
Beispiel #7
0
        /*
         * 插入小窗口到页面
         */
        internal void insertCFrameToPage(DControl ctl)
        {
            CFrame cFrame = new CFrame(ctl, App.localStorage.cfg, pageTemplate.mqServer);

            cFrame.BorderThickness     = new Thickness(0);
            cFrame.Margin              = new Thickness(ctl.left, ctl.top, 0, 0);
            cFrame.Width               = ctl.width;
            cFrame.Height              = ctl.height;
            cFrame.HorizontalAlignment = HorizontalAlignment.Left;
            cFrame.VerticalAlignment   = VerticalAlignment.Top;
            cFrame.Opacity             = ctl.opacity / 100.0;
            Panel.SetZIndex(cFrame, ctl.idx);
            cFrame.Tag = ctl;
            TransformGroup group = new TransformGroup();

            cFrame.RenderTransform       = group;
            cFrame.RenderTransformOrigin = new Point(0.5, 0.5);


            System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultCFrameStyle");
            cFrame.Style      = myStyle;
            cFrame.Focusable  = false;
            cFrame.Visibility = Visibility.Visible;
            //控件拖动
            cFrame.PreviewMouseLeftButtonDown += control_MouseDown;
            cFrame.PreviewMouseMove           += control_MouseMove;
            cFrame.PreviewMouseLeftButtonUp   += control_MouseUp;
            //控件上右击显示菜单
            cFrame.MouseRightButtonUp += control_MouseRightButtonUp;


            pageTemplate.container.Children.Add(cFrame);
        }
Beispiel #8
0
        public void Multiply_Identity()
        {
            var cframe = new CFrame(new Vector3(1, 2, 3), Matrix3.FromEulerAngles(1, 2, 3));

            var product = cframe * CFrame.Identity;

            Assert.AreEqual(cframe, product);
        }
Beispiel #9
0
        public void Identity()
        {
            var par0 = new CFrame(0, 0, 0);
            var par1 = new CFrame(1, 2, 3);

            Assert.IsTrue(par0.isIdentity, "isIdentity was false for identity matrix.");
            Assert.IsFalse(par1.isIdentity, "isIdentity was true for non-identity matrix.");
        }
Beispiel #10
0
 public void BakeGeometry(Vector3 scale, CFrame offset)
 {
     for (int i = 0; i < NumVerts; i++)
     {
         var vert = Verts[i];
         vert.Position = (offset * new CFrame(vert.Position * scale)).Position;
     }
 }
Beispiel #11
0
            private void RotateVector(ref Vector3 startVector, ref Vector2 xyRotateVector, out Vector3 resultLookVector)
            {
                var startCFrame = new CFrame(Vector3.Zero, startVector);

                resultLookVector =
                    (CFrame.Angles(0, -xyRotateVector.x, 0) * startCFrame * CFrame.Angles(-xyRotateVector.y, 0, 0))
                    .lookVector;
            }
Beispiel #12
0
 private static byte GetSpecialMatrixType(CFrame cFrame)
 {
     if (SpecialMatrixTypesReverse.ContainsKey(cFrame.Matrix))
     {
         return(SpecialMatrixTypesReverse[cFrame.Matrix]);
     }
     return(0x0);
 }
Beispiel #13
0
 public void New()
 {
     Assert.AreEqual(new CFrame(1, 2, 3), CFrame.@new(1, 2, 3));
     Assert.AreEqual(new CFrame(1, 2, 3, 4, 5, 6, 7), CFrame.@new(1, 2, 3, 4, 5, 6, 7));
     Assert.AreEqual(new CFrame(new Vector3(1, 2, 3)), CFrame.@new(new Vector3(1, 2, 3)));
     Assert.AreEqual(new CFrame(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
                     CFrame.@new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
     Assert.AreEqual(new CFrame(1, 2, 3), CFrame.@new(1, 2, 3));
 }
Beispiel #14
0
        public void LookAt()
        {
            var expected = new CFrame(0, 10, 0, -0.980580688f, -0.0377425663f, -0.192450076f, -0f, 0.981306732f,
                                      -0.192450076f, 0.196116135f, -0.188712835f, -0.962250412f);
            var actual =
                new CFrame(new Vector3(0, 10, 0), new Vector3(10, 20, 50));

            Assert.AreEqual(expected, actual, "LookAt constructor did not return expected results.");
        }
Beispiel #15
0
        public void Quaternion()
        {
            var expected = new CFrame(1, 2, 3, 0.258819103f, 0, 0.965925753f, 0.965925753f, 5.96046448e-008f,
                                      -0.258819044f, 0, 0.99999994f, 5.96046448e-008f);
            var actual = new CFrame(1, 2, 3, 0.560985526796931f, 0.43045933457687935f, 0.4304593345768794f,
                                    0.5609855267969309f);

            Assert.AreEqual(expected, actual, "Quaternion constructor did not return expected results.");
        }
Beispiel #16
0
 // Initializes the framebuffer with the size of each frame
 // MUST be called before all others
 public void Init(int dataSize)
 {
     _DataSize = dataSize;
     for (int i = 0; i < _Size; i++)
     {
         _Frames[i] = new CFrame(this, i, dataSize);
     }
     _Initialized = true;
 }
Beispiel #17
0
        public void UnitVectors()
        {
            var actualCF        = new CFrame(1, 2, 3) * CFrame.Angles(4, 5, 6);
            var expectedForward = new Vector3(0.958924294f, -0.214676261f, 0.185413986f);

            Assert.AreEqual(actualCF.forward, expectedForward, "forward did not return expected vector.");
            Assert.AreEqual(actualCF.lookVector, expectedForward, "lookVector did not return expected vector.");

            // TODO: get expected left/right/top/bottom/front/back vectors from roblox
        }
Beispiel #18
0
        public void Inverse()
        {
            var expected = new CFrame(-4.79425526f, -8.7758255f, -0, 0.87319833f, 0.47942555f, -0.0876120701f,
                                      -0.477030426f, 0.87758255f, 0.0478626937f, 0.0998334214f, 0, 0.995004177f);
            var actual =
                new CFrame(0, 10, 0, 0.87319833f, -0.477030426f, 0.0998334214f, 0.47942555f, 0.87758255f, 0,
                           -0.0876120701f, 0.0478626937f, 0.995004177f).inverse();

            Assert.AreEqual(expected, actual, "Inverse did not return expected results.");
        }
Beispiel #19
0
        public void Subtraction()
        {
            var expected = new CFrame(-5, 4, -7, 0.87319833f, -0.477030426f, 0.0998334214f, 0.47942555f, 0.87758255f, 0f,
                                      -0.0876120701f, 0.0478626937f, 0.995004177f);
            var actual =
                new CFrame(0, 10, 0, 0.87319833f, -0.477030426f, 0.0998334214f, 0.47942555f, 0.87758255f, 0,
                           -0.0876120701f, 0.0478626937f, 0.995004177f) - new Vector3(5, 6, 7);

            Assert.AreEqual(expected, actual, "Subtraction did not return expected results.");
        }
Beispiel #20
0
        public void Lerp()
        {
            var expected = new CFrame(2.5f, 3.5f, 4.5f, 0.858355939f, -0.272098392f, 0.434956968f, 0.359638363f,
                                      0.923728108f, -0.131858498f, -0.365903497f, 0.269608736f, 0.890744507f);
            var p1     = new CFrame(1, 2, 3) * CFrame.Angles(0.1f, 0.2f, 0.3f);
            var p2     = new CFrame(4, 5, 6) * CFrame.Angles(0.2f, 0.7f, 0.3f);
            var actual = p1.lerp(p2, 0.5f);

            Assert.AreEqual(expected, actual, "Rotation * Translation did not return expected results.");
        }
Beispiel #21
0
        public void Multiply()
        {
            var cframe1  = CFrame.FromEulerAngles((float)Math.PI, 0, 0);
            var cframe2  = new CFrame(1, 2, 3);
            var expected = new CFrame(new Vector3(1, -1.99999976f, -3.00000024f), new Matrix3((float)1, (float)0, (float)0, (float)0, (float)-1, (float)8.74227766e-008, (float)0, (float)-8.74227766e-008, (float)-1));

            var product = cframe1 * cframe2;

            Assert.AreEqual(expected, product);
        }
Beispiel #22
0
        public void Multiply2()
        {
            var cframe1  = CFrame.FromEulerAngles((float)Math.PI / 2, 0, 0);
            var cframe2  = new CFrame(2, 4, 6);
            var expected = new CFrame(new Vector3(2, -6, 3.99999976f), new Matrix3((float)1, (float)0, (float)0, (float)0, (float)-4.37113883e-008, (float)-1, (float)0, (float)1, (float)-4.37113883e-008));

            var product = cframe1 * cframe2;

            Assert.AreEqual(expected, product);
        }
Beispiel #23
0
        public void Multiply4()
        {
            var cframe1  = new CFrame(new Vector3(1, -1.99999976f, -3.00000024f), new Matrix3((float)1, (float)0, (float)0, (float)0, (float)-1, (float)8.74227766e-008, (float)0, (float)-8.74227766e-008, (float)-1));
            var cframe2  = new CFrame(new Vector3(2, -6, 3.99999976f), new Matrix3((float)1, (float)0, (float)0, (float)0, (float)-4.37113883e-008, (float)-1, (float)0, (float)1, (float)-4.37113883e-008));
            var expected = new CFrame(new Vector3(3, -2.99999976f, 2f), new Matrix3((float)1, (float)0, (float)0, (float)0, (float)1.31134158e-007, (float)1, (float)0, (float)-1, (float)1.31134158e-007));

            var product = cframe2 * cframe1;

            Assert.AreEqual(expected, product);
        }
Beispiel #24
0
        public void Addition()
        {
            var expected1 = new CFrame(5, 16, 7, 0.87319833f, -0.477030426f, 0.0998334214f, 0.47942555f, 0.87758255f, 0,
                                       -0.0876120701f, 0.0478626937f, 0.995004177f);
            var result1 =
                new CFrame(0, 10, 0, 0.87319833f, -0.477030426f, 0.0998334214f, 0.47942555f, 0.87758255f, 0,
                           -0.0876120701f, 0.0478626937f, 0.995004177f) + new Vector3(5, 6, 7);

            Assert.AreEqual(expected1, result1, "Addition did not return expected results.");
        }
Beispiel #25
0
        /// <summary>
        /// Sets the CFrame of the <see cref="PrimaryPart" />, respecting all relative distances between parts.
        /// </summary>
        /// <remarks>
        /// If <see cref="PrimaryPart" /> is not set, this method will error.
        /// </remarks>
        public void SetPrimaryPartCFrame(CFrame cframe)
        {
            var primaryPart = _primaryPart;

            if (primaryPart == null)
            {
                throw new InvalidOperationException("Cannot call SetPrimaryPartCFrame() on a model with no PrimaryPart.");
            }
            throw new NotImplementedException();
        }
Beispiel #26
0
        /// <summary/>
        public ArcHandles()
        {
            _cframe    = CFrame.Identity;
            _spheres   = new ShapeAdornment[6];
            _testers   = new BoundingBox[6];
            _scales    = new float[6];
            _cylinders = new ShapeAdornment[_segments * 3];

            var colours = new[]
            {
                Colour.Red,
                Colour.Green,
                Colour.Blue,
                Colour.Red,
                Colour.Green,
                Colour.Blue
            };

            for (int i = 0; i < 6; i++)
            {
                _spheres[i] = new ShapeAdornment(Shape.Sphere)
                {
                    Colour = colours[i]
                };
                _testers[i] = new BoundingBox();
            }

            for (int i = 0; i < _segments * 3; i++)
            {
                Colour colour;
                if (i < _segments)
                {
                    colour = Colour.Red;
                }
                else if (i < _segments * 2)
                {
                    colour = Colour.Blue;
                }
                else
                {
                    colour = Colour.Green;
                }

                _cylinders[i] = new ShapeAdornment(Shape.Cylinder)
                {
                    Colour = colour
                };
            }

            LeftMouseButtonDown = new Signal <Axis>(this);
            RightMouseButtonUp  = new Signal <Axis>(this);
            MouseDrag           = new Signal <Axis, float, float>(this);
            MouseEnter          = new Signal <Axis>(this);
            MouseLeave          = new Signal <Axis>(this);
        }
Beispiel #27
0
        //Pops the next frame if available
        //You have to call ResetNext before the first call to this function and call the CFrame.SetRead to free the buffers
        //Only call from reader thread
        public CFrame Pop()
        {
            if (_Next == _Last)
            {
                return(null);
            }
            CFrame res = _Frames[_Next];

            _Next = _GetNextIndex(_Next);
            return(res);
        }
Beispiel #28
0
        internal void UpdateConstants(ref DeviceContext context)
        {
            var cb = Constants;

            CFrame.GetViewMatrix(out cb.Data.ViewMatrix);
            Matrix.Multiply(ref cb.Data.ViewMatrix, ref _projectionMatrix, out _viewProjectionMatrix);
            cb.Data.ViewProjectionMatrix = _viewProjectionMatrix;
            Matrix.Invert(ref cb.Data.ViewProjectionMatrix, out cb.Data.InverseViewProjection);
            cb.Data.Position = CFrame.p;

            Constants.Update(ref context);
        }
Beispiel #29
0
        //Only call from writer thread
        public bool Put(IntPtr data, float time)
        {
            if (!_Initialized || IsFull())
            {
                return(false);
            }
            CFrame frame = _Frames[_Last];

            Marshal.Copy(data, frame.Data, 0, _DataSize);
            frame.Time = time;
            return(true);
        }
Beispiel #30
0
        public void HashCode()
        {
            var par0 = new CFrame(1, 1, 1);
            var par1 = new CFrame(new Vector3(1, 1, 1));

            Assert.AreEqual(par0.GetHashCode(), par1.GetHashCode(), "Hashcodes did not match when they should have.");

            var par2 = new CFrame(1, 1, 1);
            var par3 = new CFrame(new Vector3(2, 2, 2));

            Assert.AreNotEqual(par2.GetHashCode(), par3.GetHashCode(), "Hashcodes did match when they should not have.");
        }