예제 #1
0
파일: Drawer.cs 프로젝트: rollend/LevelUp
 //������Ƥ�ϵĶ���
 public static void DrawVertex(Graphics g, Vertex v, int width, int height)
 {
     Vector2D pt = v.GetTransformedPositon();
     DrawPoint(g, pt, width, height);
 }
예제 #2
0
        private void PrepareData()
        {
            //����Ǽ�
            root = new Skeleton(new Bone("root"), null);
            root.Bone.RefPosition = new Vector2D(0.5, 0.5);
            root.Bone.SetLocalMatrix(Matrix.Transform2D(0.5, 0.5));

            c00 = new Skeleton(new Bone("c00"), root);
            c00.Bone.RefPosition = new Vector2D(0.5, 0.5);

            c10 = new Skeleton(new Bone("c10"), c00);
            c10.Bone.RefPosition = new Vector2D(0.5, 0.35);

            c20 = new Skeleton(new Bone("c20"), c10);
            c20.Bone.RefPosition = new Vector2D(0.5, 0.2);

            IList<Bone> bones = new List<Bone>();
            bones.Add(c00.Bone);
            bones.Add(c10.Bone);
            bones.Add(c20.Bone);

            IList<double> weights;

            double w0, w1, w2, totalw;

            //������Ƥ
            //����������Ƥ�����ߣ�Ȩ�ؾ���Ϊ������ƽ��
            verts = new List<Vertex>();
            for(int i = 0; i < 48; ++i)
            {
                Vector2D posl = new Vector2D(0.49, 0.51 - i * 0.01);
                Vector2D posr = new Vector2D(0.51, 0.51 - i * 0.01);

                weights = new List<double>();

                w0 = 1.0 / Vector2D.Subtract(posl, c00.Bone.RefPosition).GetLengthSquared();
                w1 = 1.0 / Vector2D.Subtract(posl, c10.Bone.RefPosition).GetLengthSquared();
                w2 = 1.0 / Vector2D.Subtract(posl, c20.Bone.RefPosition).GetLengthSquared();

                totalw = w0 + w1 + w2;
                w0 /= totalw;
                w1 /= totalw;
                w2 /= totalw;

                weights.Add(w0);
                weights.Add(w1);
                weights.Add(w2);

                Vertex vertl = new Vertex(posl, bones, weights);
                Vertex vertr = new Vertex(posr, bones, weights);

                verts.Add(vertl);
                verts.Add(vertr);
            }
        }