[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/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 - orientation of trace_plane_normal

orientation of trace_plane_normal

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

orientation of trace_plane_normal

Postby toneddu2000 » Sun Feb 17, 2019 11:53 am

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

Re: orientation of trace_plane_normal

Postby Spike » Sun Feb 17, 2019 1:53 pm

So you have a forward, right, up value of your object, and you have a plane_normal that you want to rotate it around.
(those vectors need to be perpendicular to each other, you can use crossproducts if you know two of them. if you have three arbitrary points, forward=b-a;up=crossproduct(forward,c-a);right=crossproduct(forward,up); should get you three perpendicular vectors(remember to normalize as needed), but this does still impose a specific pair of points to give primary direction with the tertiary point only for roll angles, so you might want to use the midpoint between b and c instead of b if its not three points of a quad)

so if the plane's normal is to end up as your new 'up' vector, then the new forward vector is:
newforward = oldforward - dot(oldforward*plane_normal)*plane_normal;
(note: plane_normal points outwards, so you should read this as 'push into the plane by as much as the vector currently points away', meaning the resulting vector travels along the plane. you will have a singularity if oldforward points exactly towards the plane)
(also note: scaling that dot product by 2 will cause it to 'bounce' instead, with perfect energy conservation - values between 1 and 2 will bounce more normally)
you can do the same maths with the right vector too, but probably you'll find that term will just drop from your equations.
to turn that into angles, you can just use vectoangles(newforward,plane_normal), the plane_normal is of course your newup vector, and the newright vector isn't even relevant on account of it being known to be perpendicular and thus orientation can come from the forward vector with the up vector providing purely the roll angle.

note that none of this includes logic for the centre of gravity, so nothing will topple, so expect weirdness from steep slopes.
also note that the result of the maths is an exact value, there is no room for interpolation in its formula, which means you will likely want to somehow add your own smoothing if its a dynamic entity.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: orientation of trace_plane_normal

Postby toneddu2000 » Mon Feb 18, 2019 8:38 am

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

Re: orientation of trace_plane_normal

Postby Spike » Mon Feb 18, 2019 9:58 am

regarding that huge part in a parenthasis in the first paragraph of my previous post:
you said a tripod. tripods are defined in terms of three legs, or more specifically by 3 feet(not the unit), aka 3 points.
or if its a model then you can just use makevectors, obviously, and skip trying to calculate an orientation from arbitrary points. although if its animated you could possibly use gettaginfo to get the three points from three bones, or getsurface* to get three points from a brushmodel, but sounds like just makevectors will do.

fte has a couple of rotatevectorsby* builtins if you want to do basic forward kinematics, but there's no translations there which limits its usefulness. its nothing that you couldn't also do in qc, just with the maths hidden (and in native code).
as to additional utility functions, QC is limited in terms of arguments to builtins. You cannot simply pass a couple of matricies to the engine, which makes orientation stuff messy. one option would be to use quats (especially if you want to interpolate stuff, but that's its own kind of mess), or to use pointers-to-4x3-matricies (where pointers-to-locals cannot really be supported, so encouraging that would be bad, and half the time you can drop one of the axis anyway), and using just eular angles results in non-linear motion etc. remember that stuff gets more messy when you have translations and scale values too, with skew.
so yeah, I've no idea what aproach to take, so I've taken none.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: orientation of trace_plane_normal

Postby toneddu2000 » Mon Feb 18, 2019 1:09 pm

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


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest