Archived

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

Basiror

Surface calculation .MAP compiler :)

Recommended Posts

ok to make it short i am writing a compiler which creates entity lists and stores the faces of a brush with the plane equation in a tree now i am working on the calculation of the convex surface and i have read something about 3 plane cutting instead of cuttin every plane with all possible combinations per brush i would like to use the 3 plane clipping i think it works the way that you calculate the cut line of 2 planes and then you calculate where this line cuts the 3rd plane am i right??

Share this post


Link to post
Share on other sites
Here's some code to do just that:


int Intersectionof3RawbrushPlanes (RawBrushPlane3d *planei, RawBrushPlane3d *planej, RawBrushPlane3d *planek, Vector3d &intersection)
{

Vector3d temp1;
Vector3d temp2;
Vector3d temp3;

double denom;


temp1=CrossProduct(&planej->PlaneNormal,&planek->PlaneNormal);


denom= DotProduct(&planei->PlaneNormal,&temp1);

if (denom==0)
return 0;


temp1=CrossProduct(&planej->PlaneNormal,&planek->PlaneNormal);
temp2=CrossProduct(&planek->PlaneNormal,&planei->PlaneNormal);
temp3=CrossProduct(&planei->PlaneNormal,&planej->PlaneNormal);



temp1.x*=-planei->dist;
temp1.y*=-planei->dist;
temp1.z*=-planei->dist;

temp2.x*=planej->dist;
temp2.y*=planej->dist;
temp2.z*=planej->dist;

temp3.x*=planek->dist;
temp3.y*=planek->dist;
temp3.z*=planek->dist;


temp1.x=temp1.x-temp2.x;
temp1.y=temp1.y-temp2.y;
temp1.z=temp1.z-temp2.z;

temp1.x=temp1.x-temp3.x;
temp1.y=temp1.y-temp3.y;
temp1.z=temp1.z-temp3.z;


intersection.x=temp1.x/denom;
intersection.y=temp1.y/denom;
intersection.z=temp1.z/denom;

return 1;
}


[edited by - Megahertz on March 24, 2002 12:19:11 PM]

Share this post


Link to post
Share on other sites
thats the way i want to do it
the carry component are the coordinates of a point on theplane and the dir1 and dir2 are the direction vectors who create the plane

i know that there isn t a check if it is idetical to the other plane yet but i know how to do it this is just for the other cases

i think it should work that way
do you agree with me??

i know that here isn t the best way codewise but it is a secure way so i have choosen it






bool CSurfaceCompiler::CalcIntersections(face_t a,face_t b,face_t c)
{


/*x=a.carry+a.dir1+a.dir2;
x=b.carry+b.dir1+b.dir2;
x=c.carry+c.dir1+c.dir2;*/
vec3_t u[6];
//a geschnitten b
u[0][0]=(b.carry[0] + b.dir1[0] + b.dir2[0] - a.carry[0])/a.dir1[0];
u[0][1]=(b.carry[1] + b.dir1[1] + b.dir2[1] - a.carry[1])/a.dir1[1];
u[0][2]=(b.carry[2] + b.dir1[2] + b.dir2[2] - a.carry[2])/a.dir1[2];
u[1][0]=(b.carry[0] + b.dir1[0] + b.dir2[0] - a.carry[0])/a.dir2[0];
u[1][1]=(b.carry[1] + b.dir1[1] + b.dir2[1] - a.carry[1])/a.dir2[1];
u[1][2]=(b.carry[2] + b.dir1[2] + b.dir2[2] - a.carry[2])/a.dir2[2];
//a geschnitten c
u[2][0]=(c.carry[0] + c.dir1[0] + c.dir2[0] - a.carry[0])/a.dir1[0];
u[2][1]=(c.carry[1] + c.dir1[1] + c.dir2[1] - a.carry[1])/a.dir1[1];
u[2][2]=(c.carry[2] + c.dir1[2] + c.dir2[2] - a.carry[2])/a.dir1[2];
u[3][0]=(c.carry[0] + c.dir1[0] + c.dir2[0] - a.carry[0])/a.dir2[0];
u[3][1]=(c.carry[1] + c.dir1[1] + c.dir2[1] - a.carry[1])/a.dir2[1];
u[3][2]=(c.carry[2] + c.dir1[2] + c.dir2[2] - a.carry[2])/a.dir2[2];
//c geschnitten b
u[4][0]=(b.carry[0] + b.dir1[0] + b.dir2[0] - c.carry[0])/c.dir1[0];
u[4][1]=(b.carry[1] + b.dir1[1] + b.dir2[1] - c.carry[1])/c.dir1[1];
u[4][2]=(b.carry[2] + b.dir1[2] + b.dir2[2] - c.carry[2])/c.dir1[2];
u[5][0]=(b.carry[0] + b.dir1[0] + b.dir2[0] - c.carry[0])/c.dir2[0];
u[5][1]=(b.carry[1] + b.dir1[1] + b.dir2[1] - c.carry[1])/c.dir2[1];
u[5][2]=(b.carry[2] + b.dir1[2] + b.dir2[2] - c.carry[2])/c.dir2[2];

for(int i=0;i<6;i++)
{
for(int s=0;s<6;s++)
{
for(int t=0;t<6;t++)
{
if(u and u[s] and u[t] are equal)
return true;
}
}
}
}

Share this post


Link to post
Share on other sites
for the case that the braket or a dir vector is zero i just check if the carry is in the other plane and if the non zero dir vector is coplanar to the ones of the other plane

Share this post


Link to post
Share on other sites
Yeah, i justwrote a compiler. it turns the map into a linked list of brushes with Vertex, plane, UV and other great information, except i have run into a blocking stone of sorts..

i can''t get the UV calculations to work right. for polygons facing north/south it is fine, but any other, the V coordinates all come up as the same! oh well, dunno why
to calc is
Vertex.Dot(TexNormal)/TexWidth/TexScale + TexOffset/TexWidth

so i dunno why it isn''t working

Share this post


Link to post
Share on other sites
Yeah, i justwrote a compiler. it turns the map into a linked list of brushes with Vertex, plane, UV and other great information, except i have run into a blocking stone of sorts..

i can''t get the UV calculations to work right. for polygons facing north/south it is fine, but any other, the V coordinates all come up as the same! oh well, dunno why
to calc is
Vertex.Dot(TexNormal)/TexWidth/TexScale + TexOffset/TexWidth

so i dunno why it isn''t working

Share this post


Link to post
Share on other sites
Yeah, i justwrote a compiler. it turns the map into a linked list of brushes with Vertex, plane, UV and other great information, except i have run into a blocking stone of sorts..

i can''t get the UV calculations to work right. for polygons facing north/south it is fine, but any other, the V coordinates all come up as the same! oh well, dunno why
to calc is
Vertex.Dot(TexNormal)/TexWidth/TexScale + TexOffset/TexWidth

so i dunno why it isn''t working

Share this post


Link to post
Share on other sites
triple post

well there are 4 parameter and that 2 times one in the left and one in the right []
the right braket is absolute waste of memory because on the right you get the texture axis already so you don t need the others

you just take the uv coordiated from the first braket

[0100][waste]011
the 11 are the uv scale

but what i don t know is
0100
x1 x2 y1 y2??

can you help me on this ?

[edited by - Basiror on March 24, 2002 5:02:31 PM]

Share this post


Link to post
Share on other sites