![]() |
Looking to trace out at 45 degrees off the players center...
Trying to find a better and cheaper way to find what the 45 degree angles are of a player.
EX: \*******/* *\*****/** **\***/*** ***\*/**** ****P**** P = The player. The two 45 degree lines represent the tracelines I would like to make - but how do I find those angles cheaply?? I have one way to do it, but its VERY expensive. I keep thinking I'm missing something, and theres a faster way to find out this info. Help? |
Re: Looking to trace out at 45 degrees off the players center...
*edit* what I wrote applies as much to HL as to any other engine (such as RTCW)
Use the player's angles, flatten them if needed Code:
Vector v_myangles = pPlayerEdict->v.angles; Code:
v_myangles.y += 45; Code:
MAKE_VECTORS (v_myangles); Code:
TraceResult tr; That's it. If you want something faster than MAKE_VECTORS(), or if MAKE_VECTORS() is not available for your engine, well it can look like this: Code:
void BuildReferential (const Vector &v_angles) If you're using only the forward vector you can get rid of 60% of this function Code:
Vector BuildForwardVector (const Vector &v_angles) |
Re: Looking to trace out at 45 degrees off the players center...
I thought he was making a bot for RTCW..
|
Re: Looking to trace out at 45 degrees off the players center...
as far as I know, the current fpus support sin and cos support, therefore it's not taking to long to calculate them. Another possibility is using lookup tables for them, but since the fpu normally runs faster than your mem, I guess this is the way to go.
@pierre : why should your code be faster than those of the engine ? don't you think they just do the same ? and in terms of cache usage using the engines one might even be better ... just a thought |
Re: Looking to trace out at 45 degrees off the players center...
because engine facilities usually compute ALL THREE vectors... the last function I posted computes only the one we want :)
|
Re: Looking to trace out at 45 degrees off the players center...
:D that's true ...
|
Re: Looking to trace out at 45 degrees off the players center...
Thx for the info!
I'll give it a try later today when I have the time. btw: yes, RTCW does have a "make_vectors" function, but its called "AngleVectors", which works exactly the same way (finds the forward, right, up vectors of a client). |
Re: Looking to trace out at 45 degrees off the players center...
Hmm. gave it a quick try, but it created a traceline facing upwards at 45 degrees, instead of outward (forward). I'll play with it some more when I have time (should be leaving for work already!).
btw: heres what the code looks like in RTCW: Code:
vec3_t angles, forward, start; |
Re: Looking to trace out at 45 degrees off the players center...
Ugh - nevermind the above post or the posted code, in my hurray to leave for work, I made a TON of mistakes. I've got it working now just fine, thx for the help!
BTW: here is the correct code. :) Code:
VectorCopy(ent->s.angles, angles); |
Re: Looking to trace out at 45 degrees off the players center...
that looks very similar to HL code in fact... because our MAKE_VECTORS is actually a macro that calls AngleVectors()...
And Vector is a class to handle better the engine's vec3_t structure :) VERY similar. Very interesting for the United Bot... |
Re: Looking to trace out at 45 degrees off the players center...
HL is based on Quake1, and RTCW is based on Quake3 so that's why they are similar :) and Quake1, Quake2, Quake3, RTCW are all in C instead of C++.
"because our MAKE_VECTORS is actually a macro that calls AngleVectors()..." it doesn't call AngleVectors() but g_engfuncs.pfnMakeVectors() although they are actually the same thing :) |
Re: Looking to trace out at 45 degrees off the players center...
Pierre haven't you looked at Quake code yet? Please note that HL is based off Quake I and not Quake II. Also, make sure it is the QuakeWorld server code (unless you want client stuff).
In Quake I's mathlib.h: Code:
/* |
Re: Looking to trace out at 45 degrees off the players center...
Make sure that you can change that angle!!!
When your bots zoom in with a rifle, it WILL change their FOV. If you don't the bots will be able to see anything as if they were not zoomed in. |
Re: Looking to trace out at 45 degrees off the players center...
well, here's some more implementions of HL engine functions. Some of them are "crazily" optimized :D
I also inlined all of them to make them faster Code:
inline float UTIL_AngleMod(float a) |
Re: Looking to trace out at 45 degrees off the players center...
Hey look Quake I's mathlib.h is extremely similar to Half-life's mathlib.h.
|
Re: Looking to trace out at 45 degrees off the players center...
@Whistler: somehow these comments remind me of something, but I cant remember what ? I can swear I've seen them earlier......
the style looks like the comments I was making in the first RACC preview..... |
Re: Looking to trace out at 45 degrees off the players center...
Yes, that is your comments. Besides, I have changed "-180/+180" to "[-180, 180)".
|
All times are GMT +2. The time now is 15:34. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.