Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

see which side of the object has been hit

Para Actor
Registered User
Join date: 15 May 2009
Posts: 12
05-17-2009 10:42
Hello

I am working with collision
I am trying to make an object avoid another object while it is going twoards another object
I made by object physical
I am trying to make it avoid an object
I am using collision_start
when collision_start is triggered I can obtain the boundingbox of the object I hit and therefore the size vector but I don't know if I hit the size with the length equal to the x component of this vector or the size equal to the y component of this vector

to better explain
suppose this is the object i hit
________
|_______| and this

__
|_| is my object now they could either collide like this:
________
|_______|
|_|

or like this:
__
| |
| |
| |
| |
|_|
|_|

how can I tell which of these 2 situations I am in?
does anyone know?
thank you in advance
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-17-2009 10:59
See my comment in this thread:

/54/02/320982/1.html#post2431123
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-17-2009 11:07
The bounding box is in the coordinate frame of the object root prim, I believe. Therefore you should be able to figure it out if you also determine the rotation of the colliding object. That's about as detailed as you are going to get though. If you REALLY want to avoid a collision, use half the diagonal of the bounding box as the radius of a sphere approximating the shape of the obstacle (and the same for your moving object).
Para Actor
Registered User
Join date: 15 May 2009
Posts: 12
05-17-2009 23:18
From: Hewee Zetkin
The bounding box is in the coordinate frame of the object root prim, I believe. Therefore you should be able to figure it out if you also determine the rotation of the colliding object. That's about as detailed as you are going to get though. If you REALLY want to avoid a collision, use half the diagonal of the bounding box as the radius of a sphere approximating the shape of the obstacle (and the same for your moving object).


I don't understand ... how do I create this sphere and what do I do with the sphere afterwards?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-18-2009 03:08
simply?
vector size = llGetScale();
float sphere = size.x;
if (sphere < size.y){
sphere = size.y;
}
if (sphere < size.z){
sphere = size.z;
}
sphere /= 2;
point = llGetPos();

test = llVecDist(
if (llVecDist( position_to_move_to, point ) <= sphere){
//-- we're inside the bounding sphere
}else{
//-- we're safe
}

(all calculated as if you were inside the obstacle, because i'm mean and ain't doing your homework for you, but the formulas are sound)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-18-2009 08:12
I was thinking more along the lines of:

CODE

vector bounds = llGetBoundingBox(objectKey);
vector sphereCenter = 0.5*(bounds[0]+bounds[1]);
float sphereRadius = 0.5*llVecMag(bounds[1]-bounds[0]);


If you imagine a box that is the size of the bounding box, you'll see there can be a line segment intersecting the box that is larger than the box's maximum bounding box component, but it cannot be larger than (twice) the radius found above.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
05-18-2009 08:28
I did it a different way and posted the full script in the light source thread. But this part works fine in world:

robotPos = llGetPos();
list bBox = llGetBoundingBox(llDetectedKey(0));
vector bBoxPos = llDetectedPos(0);
vector bBoxMin = bBoxPos + llList2Vector(bBox, 0);
vector bBoxMax = bBoxPos + llList2Vector(bBox, 1);
// This tells which was is the closest, left or right
if (llVecDist(bBoxMin, robotPos) <= llVecDist(bBoxMax, robotPos))
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-18-2009 11:01
From: Hewee Zetkin
I was thinking more along the lines of:

CODE

vector bounds = llGetBoundingBox(objectKey);
vector sphereCenter = 0.5*(bounds[0]+bounds[1]);
float sphereRadius = 0.5*llVecMag(bounds[1]-bounds[0]);


If you imagine a box that is the size of the bounding box, you'll see there can be a line segment intersecting the box that is larger than the box's maximum bounding box component, but it cannot be larger than (twice) the radius found above.

bounds[0] ? =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
05-18-2009 16:07
llWhyPutBracketsInALanguageWhenIncrediblyLongFunctionNamesWillDo(0);
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-18-2009 23:24
From: Viktoria Dovgal
llWhyPutBracketsInALanguageWhenIncrediblyLongFunctionNamesWillDo(0);

lol Tori, it is funny.. I often what to address lists (and even vectors and rots) in array style... it'd be SO much easier.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-18-2009 23:52
From: Void Singer
bounds[0] ? =)

LOL. Oops. That's what I get for switching back to LSL boards right after editing a bunch of Python scripts. (I messed up the type of 'bounds' as well.) Sorry about that. Here we go:

CODE

list bounds = llGetBoundingBox(objectKey);
vector minBounds = llList2Vector(bounds, 0);
vector maxBounds = llList2Vector(bounds, 1);
vector sphereCenter = 0.5*(minBounds+maxBounds);
float sphereRadius = 0.5*llVecMag(maxBounds-minBounds);