예제 #1
0
    public static void DownloadValues(TextBox txt, Action update)
    {
        string id = txt.Text;

        if (id.Length != 8)
        {
            MessageBox.Show("Invalid ID detected.\nPlease ensure your ID is correct and try again.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return;
        }
        string result = Networking.ShareDownload("values", id);

        if (string.IsNullOrEmpty(result))
        {
            MessageBox.Show("An error has occurred.\nUnable to download values from ID: " + id + "\nPlease ensure your ID is correct and try again.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return;
        }
        int validOffsets = 0, validBones = 0;

        OffsetList.ParseOffsets(OffsetList.List, result, ref validOffsets);
        BoneList.ParseBones(BoneList.List, result, ref validBones);
        MessageBox.Show("Values downloaded and parsed successfully!\n" +
                        "Valid Offsets: " + validOffsets + "/" + OffsetList.List.Count + "\n" +
                        "Valid Bones: " + validBones + "/" + BoneList.List.Count,
                        "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Information);
        txt.Clear();
        update();
    }
예제 #2
0
        private void updateOffsetInformation()
        {
            int           offsetsCountSet = 0, bonesCountSet = 0;
            List <Offset> offsets = OffsetList.List;
            List <Bone>   bones   = BoneList.List;

            foreach (Offset offset in offsets)
            {
                if (offset.GetValue() > 0)
                {
                    offsetsCountSet++;
                }
            }
            foreach (Bone bone in bones)
            {
                if (bone.GetValue() > 0)
                {
                    bonesCountSet++;
                }
            }
            lblOffsetsSet.Text = offsetsCountSet + "/" + offsets.Count;
            lblBonesSet.Text   = bonesCountSet + "/" + bones.Count;
            OffsetList.RefreshOffsets(lbOffsets);
            BoneList.RefreshBones(lbBones);
        }
예제 #3
0
        private void Parse(Stream s)
        {
            BinaryReader br = new BinaryReader(s);

            version = br.ReadUInt32();

            string[] names = new string[br.ReadInt32()];
            for (int l = 0; l < names.Length; l++)
            {
                names[l] = System.Text.BigEndianUnicodeString.Read(s);
            }

            int i = br.ReadInt32();

            if (checking && i != names.Length)
            {
                throw new InvalidDataException(String.Format("Unequal counts for bone names and matrices.  Bone name count {0}, matrix count {1}.  Position {2:X8}.",
                                                             names.Length, i, s.Position));
            }

            Matrix4x3[] matrices = new Matrix4x3[i];
            for (int l = 0; l < matrices.Length; l++)
            {
                matrices[l] = new Matrix4x3(0, null, s);
            }

            bones = new BoneList(OnResourceChanged, names.Zip(matrices, (name, matrix) => new Bone(requestedApiVersion, null, name, matrix)));
        }
예제 #4
0
        protected override Stream UnParse()
        {
            MemoryStream s  = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(s);

            bw.Write(version);

            if (bones == null)
            {
                bones = new BoneList(OnResourceChanged);
            }

            bw.Write(bones.Count);
            foreach (var bone in bones)
            {
                System.Text.BigEndianUnicodeString.Write(s, bone.Name);
            }

            bw.Write(bones.Count);
            foreach (var bone in bones)
            {
                bone.InverseBindPose.UnParse(s);
            }

            return(s);
        }
예제 #5
0
        public override void Read(BinaryReader b)
        {
            base.Read(b);
            NumBones = b.ReadInt32();

            for (int i = 0; i < NumBones; i++)
            {
                CompiledBone tempBone = new CompiledBone();
                tempBone.ReadCompiledBone_900(b);

                if (RootBone == null)  // First bone read is root bone
                {
                    RootBone = tempBone;
                }

                BoneList.Add(tempBone);
                BoneDictionary[i] = tempBone;
            }

            List <string> boneNames = GetNullSeparatedStrings(NumBones, b);

            // Post bone read setup.  Parents, children, etc.
            // Add the ChildID to the parent bone.  This will help with navigation. Also set up the TransformSoFar
            for (int i = 0; i < NumBones; i++)
            {
                BoneList[i].boneName = boneNames[i];
                SetParentBone(BoneList[i]);
                AddChildIDToParent(BoneList[i]);
                SetBoneLocalTransformMatrix(BoneList[i]);
            }
        }
예제 #6
0
        public override void Read(BinaryReader b)
        {
            base.Read(b);
            this.SkipBytes(b, 32);  // Padding between the chunk header and the first bone.
            Vector3  localTranslation;
            Matrix33 localRotation;

            //  Read the first bone with ReadCompiledBone, then recursively grab all the children for each bone you find.
            //  Each bone structure is 584 bytes, so will need to seek childOffset * 584 each time, and go back.
            NumBones = (int)((this.Size - 32) / 584);
            for (int i = 0; i < NumBones; i++)
            {
                CompiledBone tempBone = new CompiledBone();
                tempBone.ReadCompiledBone(b);
                if (RootBone == null)  // First bone read is root bone
                {
                    this.RootBone = tempBone;
                }

                tempBone.LocalTranslation = tempBone.boneToWorld.GetBoneToWorldTranslationVector();      // World positions of the bone
                tempBone.LocalRotation    = tempBone.boneToWorld.GetBoneToWorldRotationMatrix();         // World rotation of the bone.
                //tempBone.ParentBone = BoneMap[i + tempBone.offsetParent];
                tempBone.ParentBone = GetParentBone(tempBone, i);
                if (tempBone.ParentBone != null)
                {
                    tempBone.parentID = tempBone.ParentBone.ControllerID;
                }
                else
                {
                    tempBone.parentID = 0;
                }

                if (tempBone.parentID != 0)
                {
                    localRotation    = GetParentBone(tempBone, i).boneToWorld.GetBoneToWorldRotationMatrix().ConjugateTransposeThisAndMultiply(tempBone.boneToWorld.GetBoneToWorldRotationMatrix());
                    localTranslation = GetParentBone(tempBone, i).LocalRotation *(tempBone.LocalTranslation - GetParentBone(tempBone, i).boneToWorld.GetBoneToWorldTranslationVector());
                }
                else
                {
                    localTranslation = tempBone.boneToWorld.GetBoneToWorldTranslationVector();
                    localRotation    = tempBone.boneToWorld.GetBoneToWorldRotationMatrix();
                }
                tempBone.LocalTransform = GetTransformFromParts(localTranslation, localRotation);

                BoneList.Add(tempBone);
                BoneDictionary[i] = tempBone;
            }

            // Add the ChildID to the parent bone.  This will help with navigation. Also set up the TransformSoFar
            foreach (CompiledBone bone in BoneList)
            {
                AddChildIDToParent(bone);
            }
            SkinningInfo skin = GetSkinningInfo();

            skin.CompiledBones   = new List <CompiledBone>();
            skin.HasSkinningInfo = true;
            skin.CompiledBones   = BoneList;
        }
예제 #7
0
 public void SetRange(int index, BoneList values)
 {
     OgrePINVOKE.BoneList_SetRange(swigCPtr, index, BoneList.getCPtr(values));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #8
0
 public void AddRange(BoneList values)
 {
     OgrePINVOKE.BoneList_AddRange(swigCPtr, BoneList.getCPtr(values));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #9
0
            public Header(FileReader reader)
            {
                config   = ParseSection <Config>(reader, this);
                boneList = ParseSection <BoneList>(reader, this);

                Console.WriteLine($"config NumKeyFrames {config.NumKeyFrames}");
                Console.WriteLine($"config FramesPerSecond {config.FramesPerSecond}");
            }
예제 #10
0
        public BoneList getBones()
        {
            BoneList ret = new BoneList(OgrePINVOKE.SkeletonPtr_getBones(swigCPtr), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #11
0
        public BoneList GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.BoneList_GetRange(swigCPtr, index, count);
            BoneList ret = (cPtr == global::System.IntPtr.Zero) ? null : new BoneList(cPtr, true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #12
0
        public static BoneList Repeat(Bone value, int count)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.BoneList_Repeat(Bone.getCPtr(value), count);
            BoneList ret = (cPtr == global::System.IntPtr.Zero) ? null : new BoneList(cPtr, true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #13
0
        public void InitializeBone()
        {
            BoneList.Clear();
            PmxBone pmxBone = new PmxBone();

            pmxBone.Name   = "センター";
            pmxBone.NameE  = "center";
            pmxBone.Parent = -1;
            pmxBone.SetFlag(PmxBone.BoneFlags.Translation, val: true);
            BoneList.Add(pmxBone);
        }
예제 #14
0
        public CurtainFireModel(World world)
        {
            World = world;

            PmxBoneData centerBone = new PmxBoneData()
            {
                BoneName = "センター",
                ParentId = -1,
                Flag     = 0x0002 | 0x0004 | 0x0008 | 0x0010
            };

            BoneList.Add(centerBone);
        }
        public ModelBoneCollection(World world)
        {
            World = world;

            PmxBoneData centerBone = new PmxBoneData()
            {
                BoneName = "センター",
                ParentId = -1,
                Flag     = BoneFlags.ROTATE | BoneFlags.MOVE | BoneFlags.VISIBLE | BoneFlags.OP,
            };

            BoneList.Add(centerBone);
        }
예제 #16
0
파일: RigResource.cs 프로젝트: yakoder/s3pi
        private void ParseClear(Stream s)
        {
            BinaryReader r = new BinaryReader(s);

            major        = r.ReadUInt32();
            minor        = r.ReadUInt32();
            bones        = new BoneList(OnResourceChanged, s);
            skeletonName = new String(r.ReadChars(r.ReadInt32()));
            if (major >= 4)
            {
                ikChains = new IKChainList(OnResourceChanged, s);
            }
        }
예제 #17
0
 public virtual void Clear()
 {
     Header.ElementFormat.Ver      = 2.1f;
     Header.ElementFormat.UVACount = 0;
     ModelInfo.Clear();
     VertexList.Clear();
     FaceList.Clear();
     MaterialList.Clear();
     BoneList.Clear();
     MorphList.Clear();
     BodyList.Clear();
     JointList.Clear();
     SoftBodyList.Clear();
     InitializeSystemNode();
     FilePath     = "";
     LoadErrCount = 0;
 }
예제 #18
0
 private void btnChangeValue_Click(object sender, EventArgs e)
 {
     try {
         int value = Convert.ToInt32(txtValue.Text);
         bone.SetValue(value);
         BoneList.RefreshBones(listBox);
         Hide();
         MessageBox.Show("Bone value changed!\n" + bone.GetName() + " is now equal to " + value.ToString() + ".", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Close();
     } catch (System.FormatException) {
         MessageBox.Show("Invalid decimal value detected.\nThat couldn't be converted to an integer.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     } catch (Exception ex) {
         MessageBox.Show("An error has occurred while converting value.\n" + ex.Message, "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }
예제 #19
0
        public void SetupBone(params PmxBoneData[] bones)
        {
            foreach (var bone in bones)
            {
                bone.BoneName = "B" + (BoneList.Count - 1);
                bone.BoneId   = BoneList.Count;
                bone.Flag     = BoneFlags.ROTATE | BoneFlags.MOVE | BoneFlags.OP;

                if (-1 < bone.ParentId && bone.ParentId < bones.Length - 1)
                {
                    bone.ParentId = bones[bone.ParentId].BoneId;
                }
                else
                {
                    bone.ParentId = 0;
                }
                BoneList.Add(bone);
            }
        }
예제 #20
0
        private void SetupBone(ShotModelData data, params PmxBoneData[] bones)
        {
            for (int i = 0; i < bones.Length; i++)
            {
                PmxBoneData bone = bones[i];

                bone.BoneName = data.Property.Type.Name[0] + (BoneList.Count - 1).ToString();
                bone.Flag     = 0x0002 | 0x0004 | 0x0010;
                bone.BoneId   = BoneList.Count + i;

                if (-1 < bone.ParentId && bone.ParentId < bones.Length)
                {
                    bone.ParentId = BoneList.IndexOf(bones[bone.ParentId]);
                }
                else
                {
                    bone.ParentId = 0;
                }
                BoneList.Add(bone);
            }
        }
        public void SetupBone(ShotModelData data, params PmxBoneData[] bones)
        {
            for (int i = 0; i < bones.Length; i++)
            {
                PmxBoneData bone = bones[i];

                bone.BoneName = $"B_{(BoneList.Count - 1).ToString()}";
                bone.Flag     = BoneFlags.ROTATE | BoneFlags.MOVE | BoneFlags.OP;
                bone.BoneId   = BoneList.Count + i;

                if (-1 < bone.ParentId && bone.ParentId < bones.Length)
                {
                    bone.ParentId = BoneList.IndexOf(bones[bone.ParentId]);
                }
                else
                {
                    bone.ParentId = 0;
                }
                BoneList.Add(bone);
            }
        }
예제 #22
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            int    valid    = 0;
            string boneData = txtBones.Text;

            foreach (Bone bone in bones)
            {
                Regex regex = new Regex(bone.GetName() + ":.*");
                Match m     = regex.Match(boneData);
                if (!m.Success)
                {
                    goto bone_not_found;
                }
                string data = m.Value.Split(':').GetValue(1).ToString();
                data = data.Trim();
                if (data.Length < 1)
                {
                    goto bone_not_found;
                }
                try {
                    int value = Convert.ToInt32(data);
                    bone.SetValue(value);
                    valid++;
                    continue;
                } catch (System.FormatException) { goto bone_error_converting; } catch (Exception) { goto bone_error_unknown; }
bone_not_found:
                MessageBox.Show("An error has occurred while finding " + bone.GetName() + ".", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                continue;
bone_error_converting:
                MessageBox.Show("An error has occurred while converting " + bone.GetName() + ".", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                continue;
bone_error_unknown:
                MessageBox.Show("An unknown error has occurred while parsing data from " + bone.GetName() + ".", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                continue;
            }
            BoneList.RefreshBones(listBox);
            Hide();
            MessageBox.Show(valid + "/" + bones.Count + " bones were parsed and replaced successfully.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }
예제 #23
0
파일: SKIN.cs 프로젝트: Onebeld/Regul
        public override Stream UnParse()
        {
            MemoryStream s  = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(s);

            bw.Write((uint)FOURCC(Tag));
            bw.Write(mVersion);
            if (mBones == null)
            {
                mBones = new BoneList(handler);
            }
            bw.Write(mBones.Count);
            foreach (Bone j in mBones)
            {
                bw.Write(j.NameHash);
            }
            foreach (Bone j in mBones)
            {
                j.InverseBindPose.UnParse(s);
            }
            return(s);
        }
예제 #24
0
파일: SKIN.cs 프로젝트: Onebeld/Regul
        protected override void Parse(Stream s)
        {
            BinaryReader br  = new BinaryReader(s);
            string       tag = FOURCC(br.ReadUInt32());

            if (tag != Tag)
            {
                throw new InvalidDataException(string.Format("Invalid Tag read: '{0}'; expected: '{1}'; at 0x{1:X8}", tag, Tag, s.Position));
            }
            mVersion = br.ReadUInt32();
            mBones   = new BoneList(handler);
            int count = br.ReadInt32();

            uint[] names = new uint[count];
            for (int i = 0; i < count; i++)
            {
                names[i] = br.ReadUInt32();
            }
            for (int i = 0; i < count; i++)
            {
                mBones.Add(new Bone(handler, names[i], new Matrix43(handler, s)));
            }
        }
예제 #25
0
파일: SKIN.cs 프로젝트: Onebeld/Regul
 public SKIN(EventHandler handler, BoneList bones, uint version) : base(handler, null)
 {
     mBones   = bones == null ? null : new BoneList(handler, bones);
     mVersion = version;
 }
예제 #26
0
			public PMDFormat(BinaryReader bin, GameObject caller, string path)
			{
				EntryPathes(path);
				
				this.caller = caller;
				
				try {
					this.head = new Header(bin);
					this.vertex_list = new VertexList(bin);
					this.face_vertex_list = new FaceVertexList(bin);
					this.material_list = new MaterialList(bin);
					this.bone_list = new BoneList(bin); 
					this.ik_list = new IKList(bin); read_count++;
					this.skin_list = new SkinList(bin); read_count++;
					this.skin_name_list = new SkinNameList(bin);
					this.bone_name_list = new BoneNameList(bin);
					this.bone_display_list = new BoneDisplayList(bin);
					this.eg_head = new EnglishHeader(bin);
					if (this.eg_head.english_name_compatibility != 0)
					{
						this.eg_bone_name_list = new EnglishBoneNameList(bin, bone_list.bone_count);
						this.eg_skin_name_list = new EnglishSkinNameList(bin, skin_list.skin_count);
						this.eg_bone_display_list = new EnglishBoneDisplayList(bin, bone_name_list.bone_disp_name_count);
					}
					this.toon_texture_list = new ToonTextureList(bin);
					this.rigidbody_list = new RigidbodyList(bin);
					this.rigidbody_joint_list = new RigidbodyJointList(bin);
				} catch {
					Debug.Log("Don't read full format");
				}
			}
예제 #27
0
        private void CompileCheat()
        {
            if (BuildInProgress)
            {
                txtLog.Log("Build already in progress.", Color.Yellow);
                return;
            }
            BuildInProgress = true;


            string sourceMemory     = Properties.Resources.Memory;
            string sourceOffsets    = Properties.Resources.Offsets;
            string sourceProgram    = Properties.Resources.Program;
            string sourceAimbotMath = Properties.Resources.AimbotMath;

            // Temporarily getting cheat source from local files, replace before release.

            /*
             * string sourceMemory = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Memory.cs");
             * string sourceOffsets = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Offsets.cs");
             * string sourceProgram = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Program.cs");
             * string sourceAimbotMath = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\AimbotMath.cs");
             */

            string sourceFinal = sourceMemory + sourceOffsets + sourceProgram;

            txtLog.Log("Initialized original cheat source.");

            #region settings
            // Note: use.ToString(format) when converting floats/decimals.
            #region aimbot settings
            bool aimbot_required = cb_aimbot_enabled.Checked || general_settings.trigger_magnetic || pistol_settings.trigger_magnetic || sniper_settings.trigger_magnetic;
            if (aimbot_required)
            {
                sourceFinal += sourceAimbotMath;
            }
            for (int i = 0; i < cmb_aimbot_type.Items.Count; i++)
            {
                string         typeName = cmb_aimbot_type.Items[i].ToString();
                WeaponSettings type     = null;
                switch (typeName)
                {
                case "general": type = general_settings; break;

                case "pistols": type = pistol_settings; break;

                case "snipers": type = sniper_settings; break;
                }
                if (type.aimbot_on_key)
                {
                    sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_key", KeyManagement.KeyFromText(type.aimbot_key_txt).ToString());
                }
                else
                {
                    sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_key", "-1");
                }
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_bone", BoneList.GetBone((cmb_aimbot_bone.Items[type.aimbot_bone_index]).ToString()).ToString());
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_fov", type.aimbot_fov.ToString(format) + "f");
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_smooth", type.aimbot_smooth.ToString(format) + "f");
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_rcs", type.aimbot_control_recoil.ToString().ToLower());
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_enemy", type.aimbot_shoot_enemies.ToString().ToLower());
                sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_team", type.aimbot_shoot_teammates.ToString().ToLower());
            }
            sourceFinal = sourceFinal.ReplaceComment("setting_aimbot_thread_delay", Convert.ToInt32(nud_aimbot_thread_delay.Value).ToString());
            if (!cb_aimbot_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_aimbot");
            }
            if (!aimbot_required)
            {
                sourceFinal = sourceFinal.EraseComment("feature_aimbot/magnet");
            }
            #endregion
            #region trigger settings
            for (int i = 0; i < cmb_triggerbot_type.Items.Count; i++)
            {
                string         typeName = cmb_triggerbot_type.Items[i].ToString();
                WeaponSettings type     = null;
                switch (typeName)
                {
                case "general": type = general_settings; break;

                case "pistols": type = pistol_settings; break;

                case "snipers": type = sniper_settings; break;
                }
                if (type.trigger_on_key)
                {
                    sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_key", KeyManagement.KeyFromText(type.trigger_key_txt).ToString());
                }
                else
                {
                    sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_key", "-1");
                }
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetbone", BoneList.GetBone((cmb_trigger_magnet_bone.Items[type.trigger_magnet_bone_index]).ToString()).ToString());
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetfov", type.trigger_magnet_fov.ToString(format) + "f");
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetsmooth", type.trigger_magnet_smooth.ToString(format) + "f");
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetic", type.trigger_magnetic.ToString().ToLower());
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_enemy", type.trigger_shoot_enemies.ToString().ToLower());
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_team", type.trigger_shoot_teammates.ToString().ToLower());
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_delay", type.trigger_delay.ToString());
                sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_overshoot", type.trigger_overshoot.ToString());
            }
            if (nud_trigger_thread_delay.Value > 0)
            {
                sourceFinal = sourceFinal.ReplaceComment("setting_trigger_thread_delay", Convert.ToInt32(nud_trigger_thread_delay.Value).ToString());
            }
            if (!cb_trigger_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_triggerbot");
            }
            #endregion
            #region visual settings
            // Teammate settings
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_r", lbl_visuals_teammates_color.BackColor.R.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_g", lbl_visuals_teammates_color.BackColor.G.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_b", lbl_visuals_teammates_color.BackColor.B.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_alpha", Convert.ToInt32(nud_visuals_teammates_glowalpha.Value).ToString());
            if (!cb_visuals_teammates_visibleonly.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate_chams_enabled");
            }
            else
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate_chams_disabled");
            }
            if (!cb_visuals_teammates_healthbased.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_teammate_healthbased");
            }
            if (!cb_visuals_teammates_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate");
            }
            // Enemy settings
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_r", lbl_visuals_enemies_color.BackColor.R.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_g", lbl_visuals_enemies_color.BackColor.G.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_b", lbl_visuals_enemies_color.BackColor.B.ToString());
            sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_alpha", Convert.ToInt32(nud_visuals_enemies_glowalpha.Value).ToString());
            if (!cb_visuals_enemies_visibleonly.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy_chams_enabled");
            }
            else
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy_chams_disabled");
            }
            if (!cb_visuals_enemies_healthbased.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_enemy_healthbased");
            }
            if (!cb_visuals_enemies_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy");
            }
            // Settings that apply to both
            if (!cb_visuals_teammates_healthbased.Checked && !cb_visuals_enemies_healthbased.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_healthbased");
            }
            if (nud_visuals_thread_delay.Value > 0)
            {
                sourceFinal = sourceFinal.ReplaceComment("setting_visuals_thread_delay", Convert.ToInt32(nud_visuals_thread_delay.Value).ToString());
            }
            else
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals_thread_delay");
            }
            if (!cb_visuals_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_visuals");
            }
            #endregion
            #region misc settings
            // Bunny hop
            sourceFinal = sourceFinal.ReplaceComment("setting_bhop_key", KeyManagement.KeyFromText(txt_bhop_key.Text).ToString());
            if (!cb_bhop_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_bhop");
            }
            // No flash
            sourceFinal = sourceFinal.ReplaceComment("setting_noflash_percent", nud_noflash_percent.Value.ToString());
            if (!cb_noflash_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_noflash");
            }
            // Recoil control
            sourceFinal = sourceFinal.ReplaceComment("setting_rcs_scale_x", ((float)nud_rcs_x_percent.Value * 0.02f).ToString(format) + "f");
            sourceFinal = sourceFinal.ReplaceComment("setting_rcs_scale_y", ((float)nud_rcs_y_percent.Value * 0.02f).ToString(format) + "f");
            if (!cb_rcs_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_rcs");
            }
            // Radar
            if (!cb_radar_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_radar");
            }
            // FOV Changer
            sourceFinal = sourceFinal.ReplaceComment("setting_custom_fov", nud_fov_changer.Value.ToString());
            if (!cb_fov_changer.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_fov_changer");
            }
            // Skin Changer
            sourceFinal = sourceFinal.ReplaceComment("setting_skinchanger_bat", Randomize.String() + ".bat");
            if (!cb_skinchanger_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("feature_skinchanger");
            }
            #endregion
            #region removals
            if (!cb_aimbot_enabled.Checked && !cb_trigger_enabled.Checked)
            {
                sourceFinal = sourceFinal.EraseComment("weapon_type_lists");
            }
            #endregion
            #endregion

            txtLog.Log("Implemented selected settings.");
            sourceFinal = Randomize.RandomizeOrders(sourceFinal);
            txtLog.Log("Randomized order of code.");
            sourceFinal = Randomize.Code("rnd", sourceFinal);
            txtLog.Log("Randomized class names.");
            txtLog.Log("Randomized variable names.");
            txtLog.Log("Randomized namespace names.");
            txtLog.Log("Randomized method names.");
            txtLog.Log("Randomized goto labels.");
            sourceFinal = OffsetList.ReplaceOffsets(sourceFinal);
            txtLog.Log("Replaced offset variables.");
            sourceFinal = Randomize.ReplaceNumbers(sourceFinal);
            //txtLog.Log("Replaced numbers with new sigs."); // Does nothing so excluding from logs for now.
            sourceFinal = sourceFinal.Junkify();
            txtLog.Log("Distributed randomized junk code.");
            sourceFinal = sourceFinal.ReplaceComment("setting_window_title", Randomize.String(16, 32));
            sourceFinal = sourceFinal.ReplaceComment("dynago_version", Program.currentVersion);
            sourceFinal = sourceFinal.ReplaceComment("dynago_user", Program.currentUser);
            txtLog.Log("Replaced dynamic build strings.");

            // ENABLE WHEN TESTING
            Clipboard.SetText(sourceFinal);

            new Thread(() => {
                List <string> errors = Compiler.Compile(sourceFinal, txt_build_path.Text);
                bool success         = errors.Count == 0;
                if (success)
                {
                    txtLog.Log("Compiled cheat to " + Path.GetFileName(txt_build_path.Text));

                    // Credits to ConfuserEx (https://yck1509.github.io/ConfuserEx/)
                    // Works by using the Confuser CLI obfuscate an assembly with settings from a .crproj file.
                    if (cb_obfuscation_enabled.Checked)
                    {
                        txtLog.Log("Beginning obfuscation process...");
                        txtLog.Log("Installing obfuscation dependencies...");
                        string obf = Program.directory + "\\" + Randomize.String();
                        Confuser.Install(obf);
                        string confuserPreset = cmb_obfuscation_preset.SelectedItem.ToString();
                        txtLog.Log("Running obfuscation file...");
                        string confuserOutput = Confuser.Obfuscate(obf, txt_build_path.Text, confuserPreset);
                        Regex completionCheck = new Regex("Finished at.* elapsed.");
                        Match completionMatch = completionCheck.Match(confuserOutput);
                        if (completionMatch.Success)
                        {
                            txtLog.Log("Build obfuscated successfully.");
                        }
                        else
                        {
                            txtLog.Log("Build obfuscation failed & skipped.", Color.Yellow);
                        }
                    }

                    DialogResult result = MessageBox.Show("Cheat compiled successfully.\nWould you like to run it now?", "Dynago", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    try {
                        if (result == DialogResult.Yes)
                        {
                            ProcessStartInfo info = new ProcessStartInfo(txt_build_path.Text);
                            info.UseShellExecute  = true;
                            info.Verb             = "runas";
                            Process.Start(info);
                        }
                    } catch (Exception) {
                        MessageBox.Show("Failed to run the cheat.\nPlease launch Dynago manually.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    txtLog.Log("Oh no! There were " + errors.Count + " errors.", Color.Yellow);
                    foreach (string err in errors)
                    {
                        txtLog.Log(err, Color.Red);
                    }
                    // upload sourcefinal + error log to server???
                    string result = string.Empty;
                    if (string.IsNullOrEmpty(result))
                    {
                        result = "Shit is scuffed.";
                    }
                    txtLog.Log("Error log ID: " + result, Color.Yellow);
                    txtLog.Log("[Please give that to Me-re-ly]", Color.Green);
                    MessageBox.Show("Build failed!\nWe found some errors :(", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }).Start();
            BuildInProgress = false;
        }
예제 #28
0
        public void FromPmx(Pmx pmx)
        {
            Clear();
            FilePath     = pmx.FilePath;
            LoadErrCount = pmx.LoadErrCount;
            Header       = pmx.Header.Clone();
            ModelInfo    = pmx.ModelInfo.Clone();
            int count = pmx.VertexList.Count;

            VertexList.Capacity = count;
            for (int i = 0; i < count; i++)
            {
                VertexList.Add(pmx.VertexList[i].Clone());
            }
            count             = pmx.FaceList.Count;
            FaceList.Capacity = count;
            for (int j = 0; j < count; j++)
            {
                FaceList.Add(pmx.FaceList[j]);
            }
            count = pmx.MaterialList.Count;
            MaterialList.Capacity = count;
            for (int k = 0; k < count; k++)
            {
                MaterialList.Add(pmx.MaterialList[k].Clone());
            }
            count             = pmx.BoneList.Count;
            BoneList.Capacity = count;
            for (int l = 0; l < count; l++)
            {
                BoneList.Add(pmx.BoneList[l].Clone());
            }
            count = pmx.MorphList.Count;
            MorphList.Capacity = count;
            for (int m = 0; m < count; m++)
            {
                MorphList.Add(pmx.MorphList[m].Clone());
            }
            count = pmx.NodeList.Count;
            NodeList.Clear();
            NodeList.Capacity = count;
            for (int n = 0; n < count; n++)
            {
                NodeList.Add(pmx.NodeList[n].Clone());
                if (NodeList[n].SystemNode)
                {
                    if (NodeList[n].Name == "Root")
                    {
                        RootNode = NodeList[n];
                    }
                    else if (NodeList[n].Name == "表情")
                    {
                        ExpNode = NodeList[n];
                    }
                }
            }
            count             = pmx.BodyList.Count;
            BodyList.Capacity = count;
            for (int num = 0; num < count; num++)
            {
                BodyList.Add(pmx.BodyList[num].Clone());
            }
            count = pmx.JointList.Count;
            JointList.Capacity = count;
            for (int num2 = 0; num2 < count; num2++)
            {
                JointList.Add(pmx.JointList[num2].Clone());
            }
            count = pmx.SoftBodyList.Count;
            SoftBodyList.Capacity = count;
            for (int num3 = 0; num3 < count; num3++)
            {
                SoftBodyList.Add(pmx.SoftBodyList[num3].Clone());
            }
        }
예제 #29
0
        public virtual void FromStream(Stream s, bool id)
        {
            Action <Action> action = delegate(Action a)
            {
                try
                {
                    a();
                }
                catch (Exception)
                {
                    LoadErrCount++;
                }
            };
            PmxHeader head = new PmxHeader();

            head.FromStreamEx(s);
            Header.FromHeader(head);
            head.ElementFormat.WithID = id;
            action(delegate
            {
                ModelInfo.FromStreamEx(s, head.ElementFormat);
            });
            int count = 0;

            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            VertexList.Clear();
            VertexList.Capacity = count;
            for (int k = 0; k < count; k++)
            {
                PmxVertex v = new PmxVertex();
                action(delegate
                {
                    v.FromStreamEx(s, head.ElementFormat);
                });
                VertexList.Add(v);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            FaceList.Clear();
            FaceList.Capacity = count;
            for (int l = 0; l < count; l++)
            {
                int ix = 0;
                action(delegate
                {
                    ix = PmxStreamHelper.ReadElement_Int32(s, head.ElementFormat.VertexSize, signed: false);
                });
                FaceList.Add(ix);
            }
            PmxTextureTable tx = new PmxTextureTable();

            action(delegate
            {
                tx.FromStreamEx(s, head.ElementFormat);
            });
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MaterialList.Clear();
            MaterialList.Capacity = count;
            for (int m = 0; m < count; m++)
            {
                PmxMaterial j = new PmxMaterial();
                action(delegate
                {
                    j.FromStreamEx_TexTable(s, tx, head.ElementFormat);
                });
                MaterialList.Add(j);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BoneList.Clear();
            BoneList.Capacity = count;
            for (int n = 0; n < count; n++)
            {
                PmxBone b = new PmxBone();
                action(delegate
                {
                    b.FromStreamEx(s, head.ElementFormat);
                });
                BoneList.Add(b);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MorphList.Clear();
            MorphList.Capacity = count;
            for (int num = 0; num < count; num++)
            {
                PmxMorph morph = new PmxMorph();
                action(delegate
                {
                    morph.FromStreamEx(s, head.ElementFormat);
                });
                MorphList.Add(morph);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            NodeList.Clear();
            NodeList.Capacity = count;
            for (int num2 = 0; num2 < count; num2++)
            {
                PmxNode node = new PmxNode();
                action(delegate
                {
                    node.FromStreamEx(s, head.ElementFormat);
                });
                NodeList.Add(node);
                if (NodeList[num2].SystemNode)
                {
                    if (NodeList[num2].Name == "Root")
                    {
                        RootNode = NodeList[num2];
                    }
                    else if (NodeList[num2].Name == "表情")
                    {
                        ExpNode = NodeList[num2];
                    }
                }
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BodyList.Clear();
            BodyList.Capacity = count;
            for (int num3 = 0; num3 < count; num3++)
            {
                PmxBody b2 = new PmxBody();
                action(delegate
                {
                    b2.FromStreamEx(s, head.ElementFormat);
                });
                BodyList.Add(b2);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            JointList.Clear();
            JointList.Capacity = count;
            for (int num4 = 0; num4 < count; num4++)
            {
                PmxJoint i = new PmxJoint();
                action(delegate
                {
                    i.FromStreamEx(s, head.ElementFormat);
                });
                JointList.Add(i);
            }
            if (head.Ver >= 2.1f)
            {
                action(delegate
                {
                    count = PmxStreamHelper.ReadElement_Int32(s);
                });
                SoftBodyList.Clear();
                SoftBodyList.Capacity = count;
                for (int num5 = 0; num5 < count; num5++)
                {
                    PmxSoftBody b3 = new PmxSoftBody();
                    action(delegate
                    {
                        b3.FromStreamEx(s, head.ElementFormat);
                    });
                    SoftBodyList.Add(b3);
                }
            }
            if (id)
            {
                action(delegate
                {
                    FilePath = PmxStreamHelper.ReadString(s, head.ElementFormat);
                });
            }
            head.ElementFormat.WithID = false;
        }
예제 #30
0
        /// <summary>
        /// Reads the model data for specified item and converts it into a .obj file
        /// </summary>
        /// <param name="itemID">The item ID</param>
        /// <param name="raceID">The currently selected races ID</param>
        /// <param name="part">items equipment slot</param>
        /// <param name="parentNode">Equipment slot name</param>
        /// <param name="childNode">Item Name</param>
        public Read3D(string itemID, string raceID, string part, string parentNode, string childNode)
        {
            string modelFolder, modelFile;

            modelFolder = "chara/equipment/e" + itemID + "/model";
            modelFile   = "c" + raceID + "e" + itemID + "_" + part + ".mdl";


            FindOffset fo     = new FindOffset(modelFile);
            string     offset = fo.getFileOffset();

            int loc = ((int.Parse(offset, NumberStyles.HexNumber) / 8) & 0x000f) / 2;

            using (BinaryReader br = new BinaryReader(File.OpenRead(Properties.Settings.Default.DefaultDir + "/040000.win32.dat" + loc)))
            {
                int initialOffset = int.Parse(offset, NumberStyles.HexNumber);

                if (loc == 1)
                {
                    initialOffset = initialOffset - 16;
                }
                else if (loc == 2)
                {
                    initialOffset = initialOffset - 32;
                }
                else if (loc == 3)
                {
                    initialOffset = initialOffset - 48;
                }


                List <byte> byteList = new List <byte>();

                br.BaseStream.Seek(initialOffset, SeekOrigin.Begin);

                int headerLength     = br.ReadInt32();
                int type             = br.ReadInt32();
                int decompressedSize = br.ReadInt32();
                br.ReadBytes(8);
                int parts = br.ReadInt16();

                int endOfHeader = initialOffset + headerLength;

                int partCount = 0;

                byteList.AddRange(new byte[68]);

                br.BaseStream.Seek(initialOffset + 24, SeekOrigin.Begin);

                int[] chunkUncompSizes = new int[11];
                int[] chunkLengths     = new int[11];
                int[] chunkOffsets     = new int[11];
                int[] chunkBlockStart  = new int[11];
                int[] chunkNumBlocks   = new int[11];



                for (int f = 0; f < 11; f++)
                {
                    chunkUncompSizes[f] = br.ReadInt32();
                }
                for (int f = 0; f < 11; f++)
                {
                    chunkLengths[f] = br.ReadInt32();
                }
                for (int f = 0; f < 11; f++)
                {
                    chunkOffsets[f] = br.ReadInt32();
                }
                for (int f = 0; f < 11; f++)
                {
                    chunkBlockStart[f] = br.ReadInt16();
                }
                int totalBlocks = 0;
                for (int f = 0; f < 11; f++)
                {
                    chunkNumBlocks[f] = br.ReadInt16();

                    totalBlocks += chunkNumBlocks[f];
                }

                meshCount     = br.ReadInt16();
                materialCount = br.ReadInt16();

                br.ReadBytes(4);

                int[] blockSizes = new int[totalBlocks];

                for (int f = 0; f < totalBlocks; f++)
                {
                    blockSizes[f] = br.ReadInt16();
                }


                br.BaseStream.Seek(initialOffset + headerLength + chunkOffsets[0], SeekOrigin.Begin);

                for (int i = 0; i < blockSizes.Length; i++)
                {
                    int lastPos = (int)br.BaseStream.Position;

                    br.ReadBytes(8);
                    int partCompressedSize   = br.ReadInt32();
                    int partDecompressedSize = br.ReadInt32();

                    if (partCompressedSize == 32000)
                    {
                        byte[] forlist = br.ReadBytes(partDecompressedSize);
                        byteList.AddRange(forlist);
                    }
                    else
                    {
                        byte[] forlist = br.ReadBytes(partCompressedSize);
                        byte[] partDecompressedBytes = new byte[partDecompressedSize];

                        using (MemoryStream ms = new MemoryStream(forlist))
                        {
                            using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress))
                            {
                                int count = ds.Read(partDecompressedBytes, 0x00, partDecompressedSize);
                            }
                        }
                        byteList.AddRange(partDecompressedBytes);
                    }

                    br.BaseStream.Seek(lastPos + blockSizes[i], SeekOrigin.Begin);
                }

                decompBytes = byteList.ToArray();
            }

            using (BinaryReader br = new BinaryReader(new MemoryStream(decompBytes)))
            {
                Model model = new Model(meshCount, materialCount);

                for (int x = 0; x < 3; x++)
                {
                    List <MeshInfo> mInfo = new List <MeshInfo>();

                    for (int i = 0; i < meshCount / 3; i++)
                    {
                        mInfo.Clear();
                        br.BaseStream.Seek((x * 136) + 68, SeekOrigin.Begin);
                        int dataArrayNum = br.ReadByte();

                        while (dataArrayNum != 255)
                        {
                            MeshInfo meshInfo = new MeshInfo(dataArrayNum, br.ReadByte(), br.ReadByte(), br.ReadByte());
                            mInfo.Add(meshInfo);
                            br.ReadBytes(4);
                            dataArrayNum = br.ReadByte();
                        }

                        model.Quality[x].meshInfoDict.Add(i, mInfo.ToArray());
                    }
                }

                br.BaseStream.Seek(136 * meshCount + 68, SeekOrigin.Begin);
                model.numStrings      = br.ReadInt32();
                model.stringBlockSize = br.ReadInt32();

                br.ReadBytes(model.stringBlockSize);
                br.ReadBytes(4);

                model.numTotalMeshes     = br.ReadInt16();
                model.numAtrStrings      = br.ReadInt16();
                model.numParts           = br.ReadInt16();
                model.numMaterialStrings = br.ReadInt16();
                model.numBoneStrings     = br.ReadInt16();
                model.numBoneLists       = br.ReadInt16();
                model.unk1 = br.ReadInt16();
                model.unk2 = br.ReadInt16();
                model.unk3 = br.ReadInt16();
                model.unk4 = br.ReadInt16();
                model.unk5 = br.ReadInt16();
                model.unk6 = br.ReadInt16();
                br.ReadBytes(10);
                model.unk7 = br.ReadInt16();
                br.ReadBytes(16);

                br.ReadBytes(32 * model.unk5);

                for (int i = 0; i < 3; i++)
                {
                    model.Quality[i].meshOffset = br.ReadInt16();
                    model.Quality[i].numMeshes  = br.ReadInt16();

                    br.ReadBytes(40);

                    model.Quality[i].vertDataSize  = br.ReadInt32();
                    model.Quality[i].indexDataSize = br.ReadInt32();
                    model.Quality[i].vertOffset    = br.ReadInt32();
                    model.Quality[i].indexOffset   = br.ReadInt32();
                }

                for (int x = 0; x < 3; x++)
                {
                    for (int i = 0; i < meshCount / 3; i++)
                    {
                        Mesh m = new Mesh();

                        m.numVerts        = br.ReadInt32();
                        m.numIndex        = br.ReadInt32();
                        m.materialNumber  = br.ReadInt16();
                        m.partTableOffset = br.ReadInt16();
                        m.partTableCount  = br.ReadInt16();
                        m.boneListIndex   = br.ReadInt16();
                        m.indexDataOffset = br.ReadInt32();
                        for (int j = 0; j < 3; j++)
                        {
                            m.vertexDataOffsets[j] = br.ReadInt32();
                        }
                        for (int k = 0; k < 3; k++)
                        {
                            m.vertexSizes[k] = br.ReadByte();
                        }
                        m.numBuffers = br.ReadByte();

                        model.Quality[x].mesh[i] = m;
                    }
                }

                br.ReadBytes(model.numAtrStrings * 4);
                br.ReadBytes(model.unk6 * 20);

                model.setMeshParts();

                for (int i = 0; i < model.numParts; i++)
                {
                    MeshPart mp = new MeshPart();
                    mp.indexOffset         = br.ReadInt32();
                    mp.indexCount          = br.ReadInt32();
                    mp.attributes          = br.ReadInt32();
                    mp.boneReferenceOffset = br.ReadInt16();
                    mp.boneReferenceCount  = br.ReadInt16();

                    model.meshPart[i] = mp;
                }

                //something with attribute masks

                br.ReadBytes(model.unk7 * 12);
                br.ReadBytes(model.numMaterialStrings * 4);
                br.ReadBytes(model.numBoneStrings * 4);

                model.setBoneList();

                for (int i = 0; i < model.numBoneLists; i++)
                {
                    BoneList bl = new BoneList();
                    for (int j = 0; j < 64; j++)
                    {
                        bl.boneList[j] = br.ReadInt16();
                    }
                    bl.boneCount = br.ReadInt32();

                    model.boneList[i] = bl;
                }

                br.ReadBytes(model.unk1 * 16);
                br.ReadBytes(model.unk2 * 12);
                br.ReadBytes(model.unk3 * 4);

                model.boneIndexSize = br.ReadInt32();

                model.setBoneIndicies();

                for (int i = 0; i < model.boneIndexSize / 2; i++)
                {
                    model.boneIndicies[i] = br.ReadInt16();
                }

                int padding = br.ReadByte();
                br.ReadBytes(padding);

                for (int i = 0; i < model.bb.Length; i++)
                {
                    BoundingBoxes bb = new BoundingBoxes();
                    for (int j = 0; j < 4; j++)
                    {
                        bb.pointA[j] = br.ReadSingle();
                    }
                    for (int k = 0; k < 4; k++)
                    {
                        bb.pointB[k] = br.ReadSingle();
                    }

                    model.bb[i] = bb;
                }

                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < model.Quality[i].numMeshes; j++)
                    {
                        Mesh m = model.Quality[i].mesh[j];

                        m.setMeshData();

                        for (int k = 0; k < m.numBuffers; k++)
                        {
                            br.BaseStream.Seek(model.Quality[i].vertOffset + m.vertexDataOffsets[k], SeekOrigin.Begin);

                            MeshData md = new MeshData();
                            md.meshData = br.ReadBytes(m.vertexSizes[k] * m.numVerts);

                            m.meshData[k] = md;
                        }

                        br.BaseStream.Seek(model.Quality[i].indexOffset + (m.indexDataOffset * 2), SeekOrigin.Begin);

                        m.indexData = br.ReadBytes(2 * m.numIndex);
                    }
                }

                List <string> objBytes = new List <string>();

                int vertexs = 0, coordinates = 0, normals = 0;

                for (int i = 0; i < model.Quality[0].numMeshes; i++)
                {
                    objBytes.Clear();
                    Mesh m = model.Quality[0].mesh[i];

                    MeshInfo[] mi = model.Quality[0].meshInfoDict[i];

                    int c = 0;
                    foreach (var a in mi)
                    {
                        if (a.useType == 0)
                        {
                            vertexs = c;
                        }
                        else if (a.useType == 3)
                        {
                            normals = c;
                        }
                        else if (a.useType == 4)
                        {
                            coordinates = c;
                        }
                        c++;
                    }

                    using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[vertexs].dataArrayNum].meshData)))
                    {
                        for (int j = 0; j < m.numVerts; j++)
                        {
                            int offset1 = j * m.vertexSizes[mi[vertexs].dataArrayNum] + mi[vertexs].offset;
                            br1.BaseStream.Seek(offset1, SeekOrigin.Begin);

                            if (mi[vertexs].dataType == 13 || mi[vertexs].dataType == 14)
                            {
                                float f1, f2, f3;

                                Half h1 = Half.ToHalf((ushort)br1.ReadInt16());
                                Half h2 = Half.ToHalf((ushort)br1.ReadInt16());
                                Half h3 = Half.ToHalf((ushort)br1.ReadInt16());


                                f1 = HalfHelper.HalfToSingle(h1);
                                f2 = HalfHelper.HalfToSingle(h2);
                                f3 = HalfHelper.HalfToSingle(h3);

                                objBytes.Add("v " + f1.ToString() + " " + f2.ToString() + " " + f3.ToString() + " ");
                            }
                            else if (mi[vertexs].dataType == 2)
                            {
                                float f1, f2, f3;

                                f1 = br1.ReadSingle();
                                f2 = br1.ReadSingle();
                                f3 = br1.ReadSingle();

                                objBytes.Add("v " + f1.ToString() + " " + f2.ToString() + " " + f3.ToString() + " ");
                            }
                        }
                    }

                    using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[coordinates].dataArrayNum].meshData)))
                    {
                        for (int j = 0; j < m.numVerts; j++)
                        {
                            int offset1 = j * m.vertexSizes[mi[coordinates].dataArrayNum] + mi[coordinates].offset;

                            br1.BaseStream.Seek(offset1, SeekOrigin.Begin);

                            Half a1 = Half.ToHalf((ushort)br1.ReadInt16());
                            Half b1 = Half.ToHalf((ushort)br1.ReadInt16());

                            float a = HalfHelper.HalfToSingle(a1);
                            float b = (HalfHelper.HalfToSingle(b1));

                            objBytes.Add("vt " + a.ToString() + " " + b.ToString() + " ");
                        }
                    }

                    using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.meshData[mi[normals].dataArrayNum].meshData)))
                    {
                        for (int j = 0; j < m.numVerts; j++)
                        {
                            br1.BaseStream.Seek(j * m.vertexSizes[mi[normals].dataArrayNum] + mi[normals].offset, SeekOrigin.Begin);

                            Half h1 = Half.ToHalf((ushort)br1.ReadInt16());
                            Half h2 = Half.ToHalf((ushort)br1.ReadInt16());
                            Half h3 = Half.ToHalf((ushort)br1.ReadInt16());

                            objBytes.Add("vn " + HalfHelper.HalfToSingle(h1).ToString() + " " + HalfHelper.HalfToSingle(h2).ToString() + " " + HalfHelper.HalfToSingle(h3).ToString() + " ");
                        }
                    }

                    using (BinaryReader br1 = new BinaryReader(new MemoryStream(m.indexData)))
                    {
                        for (int j = 0; j < m.numIndex; j += 3)
                        {
                            int a1 = br1.ReadInt16() + 1;
                            int b1 = br1.ReadInt16() + 1;
                            int c1 = br1.ReadInt16() + 1;

                            objBytes.Add("f " + a1 + "/" + a1 + "/" + a1 + " " + b1 + "/" + b1 + "/" + b1 + " " + c1 + "/" + c1 + "/" + c1 + " ");
                        }
                    }

                    Directory.CreateDirectory(Properties.Settings.Default.SaveDir + "/" + parentNode + "/" + childNode);
                    File.WriteAllLines(Properties.Settings.Default.SaveDir + "/" + parentNode + "/" + childNode + "/Mesh_" + i + ".obj", objBytes.ToArray());
                }
            }
        }
예제 #31
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BoneList obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }