예제 #1
0
        public Vector3 CalcVertexPosition(Md5Vertex v, Md5Joint[] joints)
        {
            Vector3 pos = Vector3.Zero;

            for (int i = v.WeightIndex; i < v.WeightIndex + v.WeightCount; ++i)
            {
                Md5Weight w = Weights[i];
                Md5Joint  j = joints[w.JointIndex];

                pos += w.Value * Transform(w.Position, j);
            }

            return(pos);
        }
예제 #2
0
 protected Matrix4 GetJointMatrix(Md5Joint j)
 {
     return(Matrix4Extensions.FromTranslation(j.Position) * Matrix4Extensions.FromQuaternion(j.Orientation));
 }
예제 #3
0
 protected Vector3 Transform(Vector3 v, Md5Joint j)
 {
     return(Vector3.Transform(v, GetJointMatrix(j)));
 }
예제 #4
0
 protected Vector3 Transform(Vector3 v, Md5Joint j)
 {
     return Vector3.Transform(v, GetJointMatrix(j));
 }
예제 #5
0
 protected Matrix4 GetJointMatrix(Md5Joint j)
 {
     return Matrix4Extensions.FromTranslation(j.Position) * Matrix4Extensions.FromQuaternion(j.Orientation);
 }
예제 #6
0
        public void CreateBuffers(Md5Joint[] joints,Md5Anim anim, float frame)
        {
            if (v == null)
                v=new VertexP3C4T2[Vertices.Length];
            for(int i=0;i<Vertices.Length;++i)
            {
                if(anim==null)
                    v[i].position = CalcVertexPosition(i,joints);
                else
                    //v[i].position=CalcVertexPosition(i,anim,frame)*0.12f;
                    v[i].position = CalcInterpolatedVertexPosition(i, anim, frame);
                v[i].color.r = 1;
                v[i].color.g=1;
                v[i].color.b=1;
                v[i].color.a=1;
                v[i].texture0.X=Vertices[i].TextureU;
                v[i].texture0.Y = Vertices[i].TextureV;
            }
            if(vb==null)
            {
                vb = Root.Instance.UserInterface.Renderer.CreateDynamicVertexBuffer(Vertices.Length * (3 + 4 + 2) * 4);
                vb.Format = VertexFormat.VF_P3C4T2;
            }
            ((DynamicVertexBuffer)vb).Update(v, Vertices.Length * (3 + 4 + 2) * 4);

            if (ib == null)
            {
                ib = new IndexBuffer();
                ib.buffer = new int[Triangles.Length * 3];
                for (int i = 0; i < Triangles.Length; ++i)
                {
                    ib.buffer[i * 3] = Triangles[i][0];
                    ib.buffer[i * 3 + 1] = Triangles[i][1];
                    ib.buffer[i * 3 + 2] = Triangles[i][2];
                }
            }
        }
예제 #7
0
        public Vector3 CalcVertexPosition(Md5Vertex v, Md5Joint[] joints)
        {
            Vector3 pos=Vector3.Zero;

            for (int i = v.WeightIndex; i < v.WeightIndex + v.WeightCount; ++i)
            {
                Md5Weight w = Weights[i];
                Md5Joint j = joints[w.JointIndex];

                pos += w.Value * Transform(w.Position, j);
            }

            return pos;
        }
예제 #8
0
 public Vector3 CalcVertexPosition(int index, Md5Joint[] joints)
 {
     Md5Vertex v = Vertices[index];
     return CalcVertexPosition(v, joints);
 }