Beispiel #1
0
        public static PMXQuaternion LoadFromStreamStatic(BinaryReader br)
        {
            PMXQuaternion res = new PMXQuaternion();

            res.LoadFromStream(br);
            return(res);
        }
Beispiel #2
0
        public override void WriteToStream(BinaryWriter bw, MMDExportSettings exportSettings)
        {
            this.Position.WriteToStream(bw);
            this.Normals.WriteToStream(bw);
            this.UV.WriteToStream(bw);

            if (exportSettings.Format == MMDExportSettings.ModelFormat.PMX)
            {
                //PMX format
                for (int i = 0; i < exportSettings.ExtendedUV; i++)
                {
                    PMXQuaternion set = ((i >= this.AddedUVs.Count) ? (new PMXQuaternion()) : this.AddedUVs[i]);
                    set.WriteToStream(bw);
                }

                this.Deform.WriteToStream(bw, exportSettings);

                bw.Write(this.OutlineMagnification);
            }
            else
            {
                this.Deform.WriteToStream(bw, exportSettings);

                bw.Write((byte)((this.OutlineMagnification > 0.2f) ? 0:1));
            }
        }
        public override void LoadFromStream(BinaryReader br, MMDImportSettings importSettings)
        {
            int boneIndex = PMXParser.ReadIndex(br, importSettings.BitSettings.BoneIndexLength);

            this.Bone        = this.Model.Bones[boneIndex];
            this.Translation = PMXVector3.LoadFromStreamStatic(br);
            this.Rotation    = PMXQuaternion.LoadFromStreamStatic(br);
        }
Beispiel #4
0
        public override void LoadFromStream(BinaryReader br, MMDImportSettings importSettings)
        {
            this.Position = PMXVector3.LoadFromStreamStatic(br);
            this.Normals  = PMXVector3.LoadFromStreamStatic(br);
            this.UV       = PMXVector2.LoadFromStreamStatic(br);


            if (importSettings.Format == MMDImportSettings.ModelFormat.PMX)
            { //PMX format
                for (int i = 0; i < importSettings.ExtendedUV; i++)
                {
                    this.AddedUVs.Add(PMXQuaternion.LoadFromStreamStatic(br));
                }

                byte deformType = br.ReadByte();

                switch (deformType)
                {
                case PMXBaseDeform.DEFORM_IDENTIFY_BDEF1:
                    this.Deform = new PMXVertexDeformBDEF1(this.Model, this);
                    break;

                case PMXBaseDeform.DEFORM_IDENTIFY_BDEF2:
                    this.Deform = new PMXVertexDeformBDEF2(this.Model, this);
                    break;

                case PMXBaseDeform.DEFORM_IDENTIFY_BDEF4:
                    this.Deform = new PMXVertexDeformBDEF4(this.Model, this);
                    break;

                case PMXBaseDeform.DEFORM_IDENTIFY_SDEF:
                    this.Deform = new PMXVertexDeformSDEF(this.Model, this);
                    break;

                case PMXBaseDeform.DEFORM_IDENTIFY_QDEF:
                default:
                    this.Deform = new PMXVertexDeformQDEF(this.Model, this);
                    break;
                }
                this.Deform.LoadFromStream(br, importSettings);

                this.OutlineMagnification = br.ReadSingle();
            }
            else
            { //PMD format
                this.Deform = PMXVertexDeformBDEF2.DeformFromPMDFile(this.Model, this, br);

                this.OutlineMagnification = ((br.ReadByte() == 0) ? 1.0f : 0.0f);
            }
        }
 public PMXMorphOffsetBone(PMXModel model, PMXMorph morph) : base(model, morph)
 {
     this.MorphTargetType = PMXMorph.MORPH_IDENTIFY_BONE;
     this.Translation     = new PMXVector3();
     this.Rotation        = new PMXQuaternion();
 }