Beispiel #1
0
        public MeshDef mapBones()
        {
            Dictionary <int, KeyValuePair <mat44, List <PointData> > > bdp = new Dictionary <int, KeyValuePair <mat44, List <PointData> > >();

            for (int i = 0; i < bones.Count; ++i)
            {
                int parent = bones[i].parent;
                bones[i].index = i;
                if (bones[i].hasParent)
                {
                    bones[i].parentBone = bones[parent];
                    bones[i].parentBone.childs.Add(bones[i]);
                }

                Bone  bone = bones[i];
                mat44 m    = new MatrixHelper(mat44.Identity).Translate(-bone.pos).Rotate(-bone.rot).mat44;
                bdp.Add(i, new KeyValuePair <mat44, List <PointData> >(m, new List <PointData>()));
            }

            foreach (PointData pd in points)
            {
                if (pd.boneid == -1)
                {
                    continue;
                }
                Bone bone = bones[pd.boneid];
                bdp[pd.boneid].Value.Add(pd);
            }

            foreach (KeyValuePair <int, KeyValuePair <mat44, List <PointData> > > k in bdp)
            {
                Bone  bone = bones[k.Key];
                mat44 m    = mat44.Identity;
                for (Bone b = bone; b != null; b = b.parentBone)
                {
                    m *= bdp[b.index].Key;
                }

                foreach (PointData pd in k.Value.Value)
                {
                    pd.location = m * pd.location;
                }
            }


            return(this);
        }
Beispiel #2
0
 public MatrixHelper mult(mat44 m)
 {
     mat = mat * m;
     return(this);
 }
Beispiel #3
0
 private static float multsum(mat44 a, vec3 b, int row)
 {
     return(a[row, 0] * b[0] + a[row, 1] * b[1] + a[row, 2] * b[2] + a[row, 3] * 1);
 }
Beispiel #4
0
 public MatrixHelper(mat44 mat)
 {
     this.mat = mat;
 }
Beispiel #5
0
 private static float multsum(mat44 a, mat44 b, int row, int col)
 {
     return(a[row, 0] * b[0, col] + a[row, 1] * b[1, col] + a[row, 2] * b[2, col] + a[row, 3] * b[3, col]);
 }