Ooops
March 08, 2021, 04:33:22 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Maths
»
[bb] See if an Entity is in View by Berbank [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] See if an Entity is in View by Berbank [ 1+ years ago ] (Read 605 times)
BlitzBot
Jr. Member
Posts: 1
[bb] See if an Entity is in View by Berbank [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
See if an Entity is in View
Author :
Berbank
Posted :
1+ years ago
Description :
Haven't properly checked this yet, but it seems to work.
There are other code fragments out there that do similar things but couldn't find anything that did this in such a specific way. Simply use like this:
If InView(EntityA,EntityB,ViewAngle,RangeValue)
debuglog("A can see B)
else
debuglog("A can't see B)
endif
This is for 2D worlds and make sure the objects have zero pitch and Roll (are not rotated on the X or Z axis).
Does not take into account occluding objects.
Code :
Code: BlitzBasic
Function
InView
(
a,b,Angle#=
90
,range#=
10000
)
; a is the entity looking
; b is the entity being looked for
; Angle# is the view angle in degrees.
; range is the distance the entity can see
If
EntityDistance
(
a,b
)
> range#
Then
Return
False
dx# =
EntityX
(
a,
1
)
-
EntityX
(
b,
1
)
dz# =
EntityZ
(
a,
1
)
-
EntityZ
(
b,
1
)
TFormNormal
dx#,
0
,dz#,
0
,
0
nx# =
TFormedX
(
)
nz# =
TFormedZ
(
)
TFormNormal
0
,
0
,
1
,a,
0
hx# =
TFormedX
(
)
hz# =
TFormedZ
(
)
dot# =
(
nx# * hx#
)
+
(
nz# * hz#
)
If
ACos
(
dot#
)
<
(
180
-
(
Angle#/
2
)
)
Return
False
Else
Return
True
EndIf
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Maths
»
[bb] See if an Entity is in View by Berbank [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal