These forums are CLOSED. Please visit the new forums HERE
determine if Line-of-Sight exists between two objects? |
|
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-11-2008 16:21
I need to determine whether an uninterrupted line of sight exists between two objects. I was thinking I would just fire an invisible object from one to the other and see if it collides with anything on the way, but is there a more efficient way?
|
|
Imnotgoing Sideways
Can't outlaw cute! =^-^=
Join date: 17 Nov 2007
Posts: 4,694
|
12-11-2008 16:54
Crank your draw distance. Anchor your camera on object A, pivot your camera to object B? (^_^)
_____________________
Somewhere in this world; there is someone having some good clean fun doing the one thing you hate the most. (^_^)y
![]() http://slurl.com/secondlife/Ferguson/54/237/94 |
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
12-11-2008 17:25
There's no way that doesn't involve one of the following: a sensor or sensor array and perhaps some calculation per each object, flinging things as mentioned, or a client modification to do a raycast on command (which isn't guaranteed to work anyway as not all objects may be in view).
_____________________
![]() |
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-11-2008 17:26
and then what, write some machine vision artificial intelligence in Linden Script?
![]() |
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-11-2008 17:28
sorry, that reply was @sideways.
@Tyken, that's what I'm asking - can this be done with sensors alone? |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-11-2008 17:49
sorry, that reply was @sideways. @Tyken, that's what I'm asking - can this be done with sensors alone? Sensor, narrow range (like a beam), just as long as it is within 96 meters should work. EDIT: No it wouldn't because of a sensor caveat(especially when you figure in mega prims): "sensors detect objects only if their center falls in the detection cone (see below). This makes it harder to use sensors for pathfinding, especially avoiding big objects like walls." So it sounds like your original idea is the best one. _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
12-11-2008 17:55
Does object A already know the position vector of object B? If so, I'm thinking object A could run a sensor with a very small angle pointed directly at object B, then do some math on llDetectedPos (knowing the positions of both A and B) on any other objects detected to determine if they are closer or further away than B. Anything closer impedes line of sight.
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously.
![]() http://slurl.com/secondlife/Brownlee/203/110/109/ ![]() |
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-11-2008 18:04
since this sensor geometry is a cone and not a cylinder, it doesn't matter how narrow I make the range, over a large enough distance it's going to detect things that are not directly in the line of sight. also, as far as I can tell, at least in the case of llSensor(), you can only detect objects and avatars, not land. so their might not be any avatars in the way, but there could still be a great big mountain.
so I started working on having my object rez an invisible "bullet" to fling at the other thing. i'll put collision detectors on the bullet eventually to see what it comes across on the way. BUT it appears you cannot set the velocity of an object that isn't physical. but then on the other hand, if I make the thing physical, it's going to travel on a parabola, not a line, due to gravity. aaargh.... |
|
icktoofay Kamachi
Registered User
Join date: 10 Nov 2007
Posts: 17
|
12-11-2008 18:19
if I make the thing physical, it's going to travel on a parabola, not a line, due to gravity. aaargh.... Try llSetBuoyancy(1); http://wiki.secondlife.com/wiki/LlSetBuoyancy |
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
12-11-2008 18:20
Good thought about land, I was thinking within the 96 meter sensor limit that a usably narrow cone would be possible. And Jesse found the real clinker in her edit. Good luck!
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously.
![]() http://slurl.com/secondlife/Brownlee/203/110/109/ ![]() |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
12-11-2008 23:25
Unfortunately I believe sensors also only detect objects whose CENTERS are within the sensor cone, so it wouldn't quite be like a full ray-casting solution. The projectile collision detection might be the best option available unfortunately.
|
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-12-2008 11:17
ooh, buoyancy will help a lot, but then there's this problem: "Wind can cause the prim to drift." if you just use llSetPos(), will the object get collision events on the way? will it follow a straight line?
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
12-12-2008 12:41
so I started working on having my object rez an invisible "bullet" to fling at the other thing. i'll put collision detectors on the bullet eventually to see what it comes across on the way. |
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
12-12-2008 13:22
ooh, buoyancy will help a lot, but then there's this problem: "Wind can cause the prim to drift." if you just use llSetPos(), will the object get collision events on the way? will it follow a straight line? I wouldn't worry about wind, you'll never notice it. _____________________
![]() |
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-12-2008 17:52
current nearly-working solution is to rez the "bullet" and in on_rez call llSensor() to search the thing the bullet is supposed to aim at. then in the sensor() callback, I call llMoveToTarget(). (this is with a physical bullet now.) this works and the collision detection works on the way (land_collision works too.) now I just have to work around the fact that llMoveToTarget() is limited to 60m. cuz it wouldn't be Second Life if things actually did what I need them to and in a simple way.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
12-12-2008 20:00
current nearly-working solution is to rez the "bullet" and in on_rez call llSensor() to search the thing the bullet is supposed to aim at. then in the sensor() callback, I call llMoveToTarget(). (this is with a physical bullet now.) this works and the collision detection works on the way (land_collision works too.) now I just have to work around the fact that llMoveToTarget() is limited to 60m. cuz it wouldn't be Second Life if things actually did what I need them to and in a simple way. Sounds like the right (only) approach to me. |
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-12-2008 20:24
now I just have to work around the fact that llMoveToTarget() is limited to 60m. cuz it wouldn't be Second Life if things actually did what I need them to and in a simple way. |
|
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
|
12-13-2008 04:24
Just rez a bullet towards target at a constant velocity, there is just absolutely no need to do llMoveToTarget..
In fact, I did the exact same thing with tracing a ray via a invisible bullet. Just sensor object B, rez bullet towards it at a constant velocity, when it hits something, make it tell key of what it hit, so object A can compare it against object B's key. _____________________
![]() Geometric Library, for all your 3D maths needs. https://wiki.secondlife.com/wiki/Geometric Creator of the Vertical Life Client |
|
Waffle Projects
Registered User
Join date: 9 Aug 2006
Posts: 38
|
12-15-2008 15:39
the suggested user funciton on LSL wiki doesn't seem to work. it just sends the bullet drifting in a random direction.
@Nexii - If you use that technique, how do you get the bullet to move on a straight line? the velocity parameter in llRezObject is only used if the object is physical, but if the object is physical and all you do is give it an initial velocity, the wind is going to blow it around and gravity is going to pull it down. |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
12-15-2008 16:09
the suggested user funciton on LSL wiki doesn't seem to work. it just sends the bullet drifting in a random direction. @Nexii - If you use that technique, how do you get the bullet to move on a straight line? the velocity parameter in llRezObject is only used if the object is physical, but if the object is physical and all you do is give it an initial velocity, the wind is going to blow it around and gravity is going to pull it down. Wind has no effect on objects in Second Life (exceot for flexi-prim effects). Gravity does have an effect, but llSetBuoyancy() or llSetForce() can be used to counteract it. |