Exemplo n.º 1
0
 public MeleeJointNode(DatJOBJ jobj)
 {
     ImageKey         = "bone";
     SelectedImageKey = "bone";
     this.JOBJ        = jobj;
     RefreshDisplay();
 }
Exemplo n.º 2
0
        public Animation GetAnimation(DatJOBJ Base = null)
        {
            Animation a = new Animation("PathAnimation");

            a.FrameCount = (int)Path.Duration;

            string name = ParentBone;// ((MeleeJointNode)Parent).RenderBone.Parent.Text;

            DatJOBJ ParentJOBJ = Base;

            if (!ParentBone.Equals(""))
            {
                name = ParentBone;
            }
            else
            {
                ParentJOBJ = ((MeleeJointNode)Parent).JOBJ;
                name       = ((MeleeJointNode)Parent).RenderBone.Text;
            }

            Animation.KeyNode kn = new Animation.KeyNode(name);
            a.Bones.Add(kn);
            kn.XPOS = new Animation.KeyGroup();
            kn.YPOS = new Animation.KeyGroup();
            kn.ZPOS = new Animation.KeyGroup();

            for (int i = 0; i < Path.PathPoints.Count; i++)
            {
                {
                    Animation.KeyFrame kf = new Animation.KeyFrame();
                    kf.Frame     = Path.PathPoints[i].Time * Path.Duration;
                    kf.Value     = Path.PathPoints[i].X + (ParentJOBJ != null ? ParentJOBJ.TX : 0) * -1;
                    kf.InterType = Animation.InterpolationType.LINEAR;
                    kn.XPOS.Keys.Add(kf);
                }
                {
                    Animation.KeyFrame kf = new Animation.KeyFrame();
                    kf.Frame     = Path.PathPoints[i].Time * Path.Duration;
                    kf.Value     = (ParentJOBJ != null ? ParentJOBJ.TY : 0) * -1 + Path.PathPoints[i].Y;
                    kf.InterType = Animation.InterpolationType.LINEAR;
                    kn.YPOS.Keys.Add(kf);
                }
                {
                    Animation.KeyFrame kf = new Animation.KeyFrame();
                    kf.Frame     = Path.PathPoints[i].Time * Path.Duration;
                    kf.Value     = (ParentJOBJ != null ? ParentJOBJ.TZ : 0) + Path.PathPoints[i].Z;
                    kf.InterType = Animation.InterpolationType.LINEAR;
                    kn.ZPOS.Keys.Add(kf);
                }
            }

            return(a);
        }
Exemplo n.º 3
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            Smd smd = new Smd(ModelSrc);

            DatJOBJ[] Bones       = DOBJ.GetRoot().Root.GetJOBJinOrder();
            VBN       RenderBones = DOBJ.GetRoot().RenderBones;

            RenderBones.reset();
            RenderBones.update();
            VBN ImportedBones = smd.bones;

            GXAttribGroup AttrGroup = null;

            if (listBox1.SelectedIndex != -1)
            {
                AttrGroup = DOBJ.GetRoot().Root.Attributes[listBox1.SelectedIndex];
            }
            else
            {
                MessageBox.Show("Please select an attribute group");
                return;
            }

            DOBJ.ClearPolygons(null, null);

            int Flags = 0x8000;

            if (comboBoxBoneType.SelectedIndex == 0)
            {
                MessageBox.Show("Warning: no binds");
            }
            if (comboBoxBoneType.SelectedIndex == 1)
            {
                Flags = 0xA001;
            }
            if (comboBoxBoneType.SelectedIndex == 2) // Rigged - needs to create bonelist
            {
                Flags = 0xA001;
            }

            DatPolygon p = new DatPolygon();

            p.AttributeGroup = AttrGroup;
            p.Flags          = Flags;
            p.ParentDOBJ     = DOBJ.DOBJ;

            DOBJ.VertsToImport = new List <GXVertex[]>();
            List <GXVertex> vert   = new List <GXVertex>();
            DatJOBJ         parent = DOBJ.DOBJ.Parent;

            if (comboBoxBoneType.SelectedIndex == 1)
            {
                ImportedBones = RenderBones;
            }
            foreach (SmdTriangle t in smd.triangles)
            {
                if (comboBoxBoneType.SelectedIndex == 1)
                {
                    // single bind
                    t.v1.bones   = new int[] { CBBone.SelectedIndex };
                    t.v1.weights = new float[] { 1 };
                    t.v2.bones   = new int[] { CBBone.SelectedIndex };
                    t.v2.weights = new float[] { 1 };
                    t.v3.bones   = new int[] { CBBone.SelectedIndex };
                    t.v3.weights = new float[] { 1 };
                }
                List <DatBoneWeight> bwl1 = CreateWeightList(t.v1.bones, t.v1.weights, Bones, ImportedBones);
                List <DatBoneWeight> bwl2 = CreateWeightList(t.v2.bones, t.v2.weights, Bones, ImportedBones);
                List <DatBoneWeight> bwl3 = CreateWeightList(t.v3.bones, t.v3.weights, Bones, ImportedBones);
                int bid1 = GetWeightListIndex(p.BoneWeightList, bwl1);
                int bid2 = GetWeightListIndex(p.BoneWeightList, bwl2);
                int bid3 = GetWeightListIndex(p.BoneWeightList, bwl3);

                int wc = p.BoneWeightList.Count;
                if (bid1 == -1)
                {
                    wc++;
                }
                if (bid2 == -1)
                {
                    wc++;
                }
                if (bid3 == -1)
                {
                    wc++;
                }
                if (wc >= 10) // need new polygon
                {
                    DOBJ.VertsToImport.Add(vert.ToArray());
                    vert.Clear();
                    p = new DatPolygon();
                    p.AttributeGroup = AttrGroup;
                    p.Flags          = Flags;
                    p.ParentDOBJ     = DOBJ.DOBJ;
                }

                bid1 = GetWeightListIndex(p.BoneWeightList, bwl1);
                bid2 = GetWeightListIndex(p.BoneWeightList, bwl2);
                bid3 = GetWeightListIndex(p.BoneWeightList, bwl3);
                if (bid1 == -1)
                {
                    p.BoneWeightList.Add(bwl1);
                }
                if (bid2 == -1)
                {
                    p.BoneWeightList.Add(bwl2);
                }
                if (bid3 == -1)
                {
                    p.BoneWeightList.Add(bwl3);
                }
                bid1 = GetWeightListIndex(p.BoneWeightList, bwl1);
                bid2 = GetWeightListIndex(p.BoneWeightList, bwl2);
                bid3 = GetWeightListIndex(p.BoneWeightList, bwl3);

                GXVertex v = SMDVertexToGXVertex(t.v1);
                v.PMXID = GetWeightListIndex(p.BoneWeightList, bwl1);
                RigVertex(ref v, RenderBones, p.BoneWeightList[v.PMXID / 3], Bones, parent);

                GXVertex v2 = SMDVertexToGXVertex(t.v2);
                v2.PMXID = GetWeightListIndex(p.BoneWeightList, CreateWeightList(t.v2.bones, t.v2.weights, Bones, ImportedBones));
                RigVertex(ref v2, RenderBones, p.BoneWeightList[v2.PMXID / 3], Bones, parent);

                GXVertex v3 = SMDVertexToGXVertex(t.v3);
                v3.PMXID = GetWeightListIndex(p.BoneWeightList, CreateWeightList(t.v3.bones, t.v3.weights, Bones, ImportedBones));
                RigVertex(ref v3, RenderBones, p.BoneWeightList[v3.PMXID / 3], Bones, parent);

                vert.Add(v);
                vert.Add(v2);
                vert.Add(v3);
            }

            DOBJ.VertsToImport.Add(vert.ToArray());

            exitStatus = ExitStatus.Opened;
            Close();
        }
Exemplo n.º 4
0
 public BoneNode(DatJOBJ j)
 {
     JOBJ = j;
 }
Exemplo n.º 5
0
 private void RigVertex(ref GXVertex P, VBN RenderBones, List <DatBoneWeight> Weight, DatJOBJ[] jobjs, DatJOBJ Parent = null)
 {
     if (Weight.Count == 1)
     {
         int i;
         for (i = 0; i < jobjs.Length; i++)
         {
             if (jobjs[i] == Weight[0].jobj)
             {
                 break;
             }
         }
         Vector3 NewP = Vector3.TransformPosition(new Vector3(P.Pos.X, P.Pos.Y, P.Pos.Z), RenderBones.bones[i].transform.Inverted());
         P.Pos.X = NewP.X; P.Pos.Y = NewP.Y; P.Pos.Z = NewP.Z;
         NewP    = Vector3.TransformNormal(new Vector3(P.Nrm.X, P.Nrm.Y, P.Nrm.Z), RenderBones.bones[i].transform.Inverted());
         P.Nrm.X = NewP.X; P.Nrm.Y = NewP.Y; P.Nrm.Z = NewP.Z;
     }
     if (Weight.Count == 0 && Parent != null)
     {
         int i;
         for (i = 0; i < jobjs.Length; i++)
         {
             if (jobjs[i] == Parent)
             {
                 break;
             }
         }
         Vector3 NewP = Vector3.TransformPosition(new Vector3(P.Pos.X, P.Pos.Y, P.Pos.Z), RenderBones.bones[i].transform.Inverted());
         P.Pos.X = NewP.X; P.Pos.Y = NewP.Y; P.Pos.Z = NewP.Z;
         NewP    = Vector3.TransformNormal(new Vector3(P.Nrm.X, P.Nrm.Y, P.Nrm.Z), RenderBones.bones[i].transform.Inverted());
         P.Nrm.X = NewP.X; P.Nrm.Y = NewP.Y; P.Nrm.Z = NewP.Z;
     }
 }