Autor Beitrag
_Joe_ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Arch Linux/XP
VS2008 Prof.,Codeblocks
BeitragVerfasst: Do 12.03.09 20:51 
Ich hab mir mal den Code von GLScene angeschaut aber schlau wird man dabei auch nicht. Vielleicht fällt mir noch was ein *hoff*
_Joe_ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47

Arch Linux/XP
VS2008 Prof.,Codeblocks
BeitragVerfasst: Do 19.03.09 17:39 
ich hab das ganze nochmal überarbeitet aber funktionieren tuts trotzdem nicht :-/

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
        public Plane(Point3D p0, Point3D p1, Point3D p2)
        {
            //Ebene 
            Vector3D e1 = p1 - p0;
            Vector3D e2 = p2 - p1;
            this.normal = Vector3D.CrossProduct(e1, e2);
            Vector3D n = normal/normal.Length;
            this.d = Vector3D.DotProduct(e1, n); 

        }

        public Point[] MapTextureCoordinates(Point3D[] vertices, Vector3D max, Vector3D min)
        {
            Vector3D size = max - min;
            Plane plane = new Plane(vertices[0], vertices[2], vertices[1]);

            double cross_X = Vector3D.DotProduct(plane.Normal, new Vector3D(100));
            double cross_Y = Vector3D.DotProduct(plane.Normal, new Vector3D(010));
            double cross_Z = Vector3D.DotProduct(plane.Normal, new Vector3D(001));

            Point[] tmp = new Point[3];
            if ((Math.Abs(cross_X) > Math.Abs(cross_Y)) && (Math.Abs(cross_X) > Math.Abs(cross_Z)))
            {
                for (int i = 0; i < 3; i++)
                {
                    tmp[i].X = ((vertices[i].Z - max.Z) / size.Z);
                    tmp[i].Y = ((vertices[i].Y - min.Y) / size.Y);
                }
            }
            if ((Math.Abs(cross_Y) > Math.Abs(cross_X)) && (Math.Abs(cross_Y) > Math.Abs(cross_Z)))
            {
                for (int i = 0; i < 3; i++)
                {
                    tmp[i].X = ((vertices[i].X - max.X) / size.X);
                    tmp[i].Y = ((vertices[i].Z - min.Z) / size.Z);
                }
            }
            if ((Math.Abs(cross_Z) > Math.Abs(cross_X)) && (Math.Abs(cross_Z) > Math.Abs(cross_Y)))
            {
                for (int i = 0; i < 3; i++)
                {
                    tmp[i].X = ((vertices[i].X - max.X) / size.X);
                    tmp[i].Y = ((vertices[i].Y - min.Y) / size.Y);
                }
            }
            return tmp;
        }


findet jemand den Fehler?