Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
entity's view #381516
08/29/11 08:19
08/29/11 08:19
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline OP
Member
tzw  Offline OP
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
hi~ maybe some of you think it's useful:
/////////////////////////////////////////////////////////////
//IN:
//from_ent: scanner
//target_ent: target
//view_dist:viewdistance
//angle_diff: the half angle of the view
//*******************
//OUT:
// true scanner can see ;
//false--can't
var Tsee_ent(ENTITY* form_ent, ENTITY* target_ent,var view_dist,var angle_diff)
{
//for performance reason, we first check the dist
if(vec_dist(form_ent.x,target_ent.x)<view_dist)
{
VECTOR view_dist_vec,my_angle_vec;
vec_set(view_dist_vec.x,form_ent.x);
vec_set(my_angle_vec.x,form_ent.x);
vec_diff(view_dist_vec,target_ent.x,form_ent.x)
vec_for_angle(my_angle_vec,form_ent.pan);
var result_ang = acosv(vec_dot(view_dist_vec,my_angle_vec)/(vec_length(view_dist_vec)*vec_length(my_angle_vec)));
if(result_ang<angle_diff)
{
if(c_trace(form_ent.x,target_ent.x, IGNORE_ME | IGNORE_PASSABLE )> 0 &&you==target_ent)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}


PS:the function only use c_trace,and vector caculation , so it may run faster a lot than normally using c_scan combine c_trace


uhh..the comments are chinese ,so i delete them.........sorry for my english..



Full of my eyes are class struggles.....
Re: entity's view [Re: tzw] #381521
08/29/11 09:02
08/29/11 09:02
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
I guess this code is to check if an entity can see another depending on the distance and the view angle? If yes, this is nice and useful laugh

Re: entity's view [Re: PadMalcom] #381522
08/29/11 09:03
08/29/11 09:03
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline OP
Member
tzw  Offline OP
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
yes


Full of my eyes are class struggles.....

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1