Archived

This topic is now archived and is closed to further replies.

Muhammad Haggag

Plane - Plane intersection (3 verts each) for .map files loading (worldcraft)

Recommended Posts

Hi there, Problem statement : Worldcraft stores .map files in a special way, each brush consists of a number of faces, each face consisting of 4 vertices. They''re however, represented by planes in the .map file, each plane is represented by 3 vertices only. So I have to get the 4th one for each face. Example Brush : { ( -64 128 224 ) ( 448 128 224 ) ( 448 -448 224 ) AAATRIGGER 0 0 0 1.000000 1.000000 ( -64 128 224 ) ( -64 -448 224 ) ( -64 -448 -1024 ) AAATRIGGER 0 0 0 1.000000 1.000000 ( 448 128 -1024 ) ( 448 -448 -1024 ) ( 448 -448 224 ) AAATRIGGER 0 0 0 1.000000 1.000000 ( 448 128 224 ) ( -64 128 224 ) ( -64 128 -1024 ) AAATRIGGER 0 0 0 1.000000 1.000000 ( 448 -448 -1024 ) ( -64 -448 -1024 ) ( -64 -448 224 ) AAATRIGGER 0 0 0 1.000000 1.000000 ( 256 64 -704 ) ( 256 192 -704 ) ( 128 192 -704 ) AAATRIGGER 0 0 0 1.000000 1.000000 } The 3 ordered pairs in each line represent a plane of one of the faces. Now I''m supposed to get the 4th vertex for each face. I assumed that the 4th vertex for any plane exists somewhere in the 3 vertices of other planes (i.e it''s a point along the line of intersection of this plane with other plane(s) ) So I created a plane from the first 3 vertices, searched for a vertex that satisfies Plane.A * Vertex.X + Plane.B * Vertex.Y + Plane.C * Vertex.Z + Plane.D = 0 This worked sometimes, but many times it won''t. Is there any way to get the intersection of planes through their eqns only??? (A,B,C,D form) Has anybody loaded .map files before? Sorry if this post seems off the topic of math a little, I think it''s some sort of hybrid.

Share this post


Link to post
Share on other sites
The cross product of their normals points in the direction of the line of intersection. So all you need is a point on the line. You get that by finding the intersection of both planes with the xy, xz or yz planes, i.e. set one component to zero. The intersections are lines and that gives you two equations of two lines and their intersection is a point on the line of intersection of the two planes. So if you had x-y+z=1 and x+y+z=1 then x-y=1 is one line and x+y=1 is the other, adding the two equations gives 2x=2 or x=1 and 1-y=1 so y=0 and a point on the line is (1,0,0). If you set y=0 instead you would get x+z=1 and x+z=1 or 0=0 which doesn''t tell you anything because the line of intersection is parallel to the xz plane.

Share this post


Link to post
Share on other sites