Raised This Month: $ Target: $400
 0% 

[1 solution found] Calculating an entities mins/maxs according to the entityangles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-28-2007 , 12:47   [1 solution found] Calculating an entities mins/maxs according to the entityangles
Reply With Quote #1

Code:
// Here the angles are read
ent_angles[ent_count][0] = str_to_float(str_value[0]);
ent_angles[ent_count][1] = str_to_float(str_value[1]);
ent_angles[ent_count][2] = str_to_float(str_value[2]);

// And here the entities angles is set
set_pev(ent, pev_angles, ent_angles[ent_count]);
This mins/maxs are correct for this angle: (0.0, 270.0, 0.0)
Code:
new Float:mins[3] = {-11.0, -2.0, 27.0};
new Float:maxs[3] = {11.0, 2.0, 71.0};
engfunc(EngFunc_SetSize, ent, mins, maxs);
ent_count++;
But if the angle is like this: (0.0, 90.0, 0.0) the mins/maxs are not correct.
I have no skills in 3D math so the only thing i could do is hardcode the mins/maxs for nearly every angle...*omg*

Does anyone know a function to calc the mins/maxs corresponding to the angles?

Thanks in advance
regalis
__________________

Last edited by regalis; 05-28-2007 at 14:06. Reason: *smile*
regalis is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-28-2007 , 13:01   Re: Calculating an entities mins/maxs according to the entityangles
Reply With Quote #2

Just out of curiosity, why would you need to calculate an entities size based on their angles? Just never heard of it being done before.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-28-2007 , 13:11   Re: Calculating an entities mins/maxs according to the entityangles
Reply With Quote #3

For my Health/Armor Stations plugin...
When you place a station on the wall it have an angle...
Now the entity size have to be as big as the model to get the entID through get_user_aiming()
(because if the entity is too small you have to search for it "inside" the model)
Also the main problem: the entity have to be solid to get the ID through aiming..

Thats why i need a function which translates the coordinates of the size according to the angle the model have..
Or does anyone know how to get the entID through get_user_aiming() if the entity is not solid?
__________________
regalis is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 05-28-2007 , 14:00   Re: Calculating an entities mins/maxs according to the entityangles
Reply With Quote #4

Try this out. It runs EngFunc_FindEntityInSphere on where you aim, and return's the ent's id if found.

PHP Code:
stock get_aim_radius(indexFloat:radius
{
 static 
Float:start[3], Float:view_ofs[3]
 
pev(indexpev_originstart)
 
pev(indexpev_view_ofsview_ofs)
 
xs_vec_add(startview_ofsstart)
 
 static 
Float:dest[3]
 
pev(indexpev_v_angledest)
 
engfunc(EngFunc_MakeVectorsdest)
 
global_get(glb_v_forwarddest)
 
 
xs_vec_mul_scalar(dest9999.0dest)
 
xs_vec_add(startdestdest)
 
 
engfunc(EngFunc_TraceLinestartdest0index0)
 
 static 
Float:origin[3]
 
get_tr2(0TR_vecEndPosorigin)
 
 new 
ent = -1
 
while((ent engfunc(EngFunc_FindEntityInSphereentoriginradius)) != 0)
  return 
ent
 
return 0

__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 05-30-2007 at 01:29.
Cheap_Suit is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-28-2007 , 14:05   Re: Calculating an entities mins/maxs according to the entityangles
Reply With Quote #5

OMG !!!!
I'm so dumb *hitting my head on the plate*

Thank you very much for this idea!

Thats it...no complicated math *hrhr*

(But if anyone got bored and would like to tell us the solution...feel free...i'm though interested in how to calculate that..0o)

greetz regalis
__________________

Last edited by regalis; 05-28-2007 at 18:08.
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-31-2007 , 03:05   Re: [1 solution found] Calculating an entities mins/maxs according to the entityangle
Reply With Quote #6

I didn't get two things: why not solid and why sphere? Isn't it should be solid parallelepiped?
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-31-2007 , 09:43   Re: [1 solution found] Calculating an entities mins/maxs according to the entityangle
Reply With Quote #7

Quote:
Originally Posted by VEN View Post
I didn't get two things: why not solid and why sphere? Isn't it should be solid parallelepiped?
no no, the entity have to be solid that i can get its ID by get_user_aiming() function (to remove it)

Why not sphere? It works realy got with find_ent_in_sphere()...do you suggest using a other function?
The only thing other i can think of is ent_distance()...

Quote:
Isn't it should be solid parallelepiped?
Don't know what you mean...has this to do with 3D math !?


Btw.: i found functions to rotate a point around a axis...but it doesn't work
Code:
stock rotate_point_by_angle(const Float:angle[3],Float:point[3])
{
    log_amx("before point : %f - %f - %f", point[0], point[1], point[2]);
    point[0] = (point[0] * floatcos(angle[1], degrees)) - (point[1] * floatsin(angle[1], degrees));
    point[1] = (point[1] * floatcos(angle[1], degrees)) + (point[0] * floatsin(angle[1], degrees));
    log_amx("after1 point : %f - %f - %f", point[0], point[1], point[2]);
    point[0] = (point[0] * floatcos(angle[2], degrees)) - (point[2] * floatsin(angle[2], degrees));
    point[2] = (point[2] * floatcos(angle[2], degrees)) + (point[0] * floatsin(angle[2], degrees));
    log_amx("after2 point : %f - %f - %f", point[0], point[1], point[2]);
    point[1] = (point[1] * floatcos(angle[0], degrees)) - (point[2] * floatsin(angle[0], degrees));
    point[2] = (point[2] * floatcos(angle[0], degrees)) + (point[1] * floatsin(angle[0], degrees));
    log_amx("after3 point : %f - %f - %f", point[0], point[1], point[2]);
    return 1;
}
I get weird server crashes... got an error window "backward mins/maxs"
Does anyone know what i did wrong?
I found out that floatcos()/floatsin() need a flag with degrees otherwise it returns radians..0o
But that also crashes the server...

Thanks VEN for responding!
greetz regalis
__________________
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-31-2007 , 14:26   Re: [1 solution found] Calculating an entities mins/maxs according to the entityangle
Reply With Quote #8

I think you didn't get my point.

Quote:
For my Health/Armor Stations plugin...
When you place a station on the wall
......
if the entity is not solid?
I thought that Health/Armor Station should be solid and it isn't spherical but simple box (parallelepiped)? Why do you trying to check sphere? Why station isn't solid? I'm confused...
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-31-2007 , 14:48   Re: [1 solution found] Calculating an entities mins/maxs according to the entityangle
Reply With Quote #9

Right it should be solid and it is solid. But unfortunately i can only create a small entity in the middle of the model.
Because if the angle of the model changes the entity keeps its angle which is set by the mins/maxs
Therefore i try to rotate the mins/maxs that i can fill the whole model with the entity to make it real solid.

i can post a little screenshot if my explanation is to confusing ;)
[IMG]http://img523.**************/img523/8641/screenierx5.th.jpg[/IMG]
__________________

Last edited by regalis; 05-31-2007 at 14:58.
regalis is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 09-26-2007 , 06:14   Re: [1 solution found] Calculating an entities mins/maxs according to the entityangle
Reply With Quote #10

regalis, did you ever find a solution to this, I'm wanting to do something similar and not recalling what to do to get the mins/maxs to shift with different angles.
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode