示例#1
0
 private bool SameLocation(PMXVector3 a, PMXVector3 b)
 {
     return
         (
         a.X == b.X &&
         a.Y == b.Y &&
         a.Z == b.Z
         );
 }
示例#2
0
        public void LoadFromStream(BinaryReader br)
        {
            this.BoneName    = VMDString.ReadString(br, 15);
            this.FrameNumber = br.ReadUInt32();
            this.Translation = PMXVector3.LoadFromStreamStatic(br);
            this.Rotation    = PMXQuaternion.LoadFromStreamStatic(br);

            this.Bezier = new byte[64];
            br.BaseStream.Read(this.Bezier, 0, 64);
        }
示例#3
0
        public void LoadFromStream(BinaryReader br)
        {
            this.FrameNumber = br.ReadUInt32();
            this.Distance    = br.ReadSingle();
            this.Position    = PMXVector3.LoadFromStreamStatic(br);
            this.Rotation    = PMXVector3.LoadFromStreamStatic(br);
            this.Rotation.X *= (-1);

            this.Bezier = new byte[24];
            br.BaseStream.Read(this.Bezier, 0, 24);

            this.ViewAngle   = br.ReadUInt32();
            this.Perspective = (br.ReadByte() == 1);
        }
示例#4
0
            public override bool Equals(object obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                if (!(obj is TriangleEdge))
                {
                    return(false);
                }

                TriangleEdge t = (TriangleEdge)obj;

                bool sameVertices = (t.Vertex1 == this.Vertex1 && t.Vertex2 == this.Vertex2);

                if (sameVertices)
                {
                    return(true);
                }

                if (!this._identicalLocation)
                {
                    return(false);
                }

                /*if(t.Vertex1.EasySlashIndex == 8857 && t.Vertex2.EasySlashIndex == 8858)
                 * {
                 *  Console.WriteLine("Mat 6");
                 * }*/

                PMXVector3 va1 = this.Vertex1.Position;
                PMXVector3 va2 = this.Vertex2.Position;

                PMXVector3 vb1 = t.Vertex1.Position;
                PMXVector3 vb2 = t.Vertex2.Position;

                if ((SameLocation(va1, vb1) && SameLocation(va2, vb2)) || (SameLocation(va2, vb1) && SameLocation(va1, vb2)))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
示例#5
0
        private static PMXVector3 Rotate(PMXVector3 centre, PMXVector3 point, double angle, float weight)
        {
            PMXVector3 offset = point - centre;

            if (offset.Value == 0)
            {
                return(point);
            }

            RotateTransform3D xrotation = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), angle)); //WPF for whatever reasons uses degrees and not Radian

            PMXVector3 rotated = xrotation.Transform(offset.ToPoint3D()).ToPMXVector3();

            PMXVector3 actualRotation = (rotated - offset) * weight + offset;

            return(centre + actualRotation);
        }
示例#6
0
        public static void RotateZ(PMXModel mdl, PMXBone parent, double angle)
        {
            List <PMXBone> children = GetAllChildBones(mdl, parent);

            foreach (PMXBone child in children)
            {
                PMXVector3 originalLocation = child.Position;
                child.Position = Rotate(parent.Position, originalLocation, angle, 1.0f);

                if (!child.HasChildBone)
                {
                    PMXVector3 targetLocation = Rotate(parent.Position, originalLocation + child.ChildVector, angle, 1.0f);
                    child.ChildVector = targetLocation - child.Position;
                }
            }

            List <PMXBone> weightBones = new List <PMXBone>()
            {
                parent
            };

            weightBones.AddRange(children);

            PMXVector3 baseVector = new PMXVector3();

            foreach (PMXVertex v in mdl.Vertices)
            {
                float w = DetermineWeight(v, weightBones);

                if (w <= 0.0f)
                {
                    continue;
                }

                PMXVector3 originalLocation = v.Position;

                v.Position = Rotate(parent.Position, originalLocation, angle, w);
                v.Normals  = Rotate(baseVector, v.Normals, angle, w);
            }
        }
示例#7
0
 public void LoadFromStream(BinaryReader br)
 {
     this.FrameNumber = br.ReadUInt32();
     this.Color       = PMXColorRGB.LoadFromStreamStatic(br);
     this.Location    = PMXVector3.LoadFromStreamStatic(br);
 }
示例#8
0
 public VMDLightFrame()
 {
     this.Color    = new PMXColorRGB();
     this.Location = new PMXVector3();
 }
示例#9
0
 public static Point3D ToPoint3D(this PMXVector3 v)
 {
     return(new Point3D(v.X, v.Y, v.Z));
 }