[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - A+B+C+D=0 from vector + dist

A+B+C+D=0 from vector + dist

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

A+B+C+D=0 from vector + dist

Postby Baker » Tue Jan 20, 2015 5:31 am

How can I get the A+B+C+D=0 plane formula from a Quake mplane_t normal and dist?

I am assuming the mplane_t normal vectors are perpendicular to the plane as one would expect.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: A+B+C+D=0 from vector + dist

Postby Barnes » Tue Jan 20, 2015 11:04 am

A+B+C= -D ?
User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow

Re: A+B+C+D=0 from vector + dist

Postby Spike » Tue Jan 20, 2015 11:14 am

its best expressed as A*x + B*y + C*z - D = 0

some useful formulas:
distfromplane = DotProduct (plane->normal, point) - plane->dist;
plane->dist = DotProduct(plane->normal, pointonplane);
pointonplane = point - (distfromplane*plane->normal);
isinfront = distfromplane>0;
isbehind = distfromplane<0;
isfloatingpointprecisionmiraclethatyouhavetosomehowrollintoonesideyetstillallowsplayerstofallthroughcracks = distfromplane==0;

note that the distance is negated relative to more standard plane notation. in mathematics, the plane is generally two-sided. in quake, the normal faces directly forwards into empty space (unless the surface has SURF_PLANEBACK set, in which case the normal faces backwards - all 4 values are logically negated (or in the case of nodes, the two children are pre-swapped, avoiding the need for the engine to do anything special). note that the plane normals in a quake bsp are arranged to be primarily positive, reducing the total number of planes needed, and facilitating axial lookups).
for surfaces, the two tangents are normally available via the texture vector values, but note that these vectors are not kept strictly perpedicular to the normal, nor are they always normalized. because quake is weird and has annoying texture mapping, as well as texture scaling.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: A+B+C+D=0 from vector + dist

Postby Baker » Tue Jan 20, 2015 7:20 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: A+B+C+D=0 from vector + dist

Postby Spike » Tue Jan 20, 2015 8:20 pm

the problem with drawing a plane is that a plane is infinitely long.

if you make a guess at a tangent (rotate the axis or just hardcode something), you can crossproduct it with the normal and normalize for a real tangent. and then do it again for some bitangent too. of course, these vectors have no relation to any texturing, but hey...
then you can generate a quad by moving '0 0 0' along the plane's normal onto the plane then extend sideways to find your four points.

alternatively you can figure out which axis is the most significant for the plane, pick a set of 4 points aligned on that axis, and then push them to match the plane.

if you're drawing a brush, once you have a quad you can then clip that quad by the other planes (retaining only the stuff on the inside of the brush). the resulting clipped polygon is your brush's face.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: A+B+C+D=0 from vector + dist

Postby Baker » Wed Feb 21, 2018 1:01 am

Just want to say thanks to Spike for help with these kinds of things over the years.

I did some plane/point tests today and this reminded me of how I struggled with this kind of thing in the past.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: A+B+C+D=0 from vector + dist

Postby toneddu2000 » Wed Feb 21, 2018 6:29 pm

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: A+B+C+D=0 from vector + dist

Postby Baker » Mon Mar 05, 2018 1:11 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: A+B+C+D=0 from vector + dist

Postby toneddu2000 » Tue Mar 06, 2018 8:43 am

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest