|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
06-14-2009 02:06
I'm playing wth bounding boxes.
Given the result of llGetBoundingBox() that gives the BB in local coordinates, and the rotation of a prim I can examine the rotate eight corners of the BB and determine the BB in world coordinates.
My problem is with linksets. The BB is still in local coordinates but I can't understand which rotation should I use. Neither llGetRot() or llGetRootRotation() seem to work.
I could go through all the prims in the linkset, calculate the rotate BB for each prim and "sum" them to get the global BB. It seems rather slow and cumbersome!
Is there any other way?
Thanks,
RD
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
06-14-2009 05:18
not sure you can get the individual parts of an object (both wikis seem to suggest that requesting one gets you the whole set), which would seem to me that you'd use llGetRot, or any of the equivalents.
but you say those aren't working, so have you checked that the bounding box as returned is still locally oriented for multiprim objects? (perhaps it's already in region coordinates?)
and if that's not the case it may be a variety of the linked object problem which returns one of the child prim rotations for the local value of the linkset. (in which case you may well be screwed)
_____________________
| | . "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... | - 
|
|
Rael Delcon
Registered User
Join date: 23 Nov 2006
Posts: 86
|
06-14-2009 06:52
From: Void Singer (in which case you may well be screwed) It seems that I'm screwed anyway....  Bounding boxes for objects like toruses with revoluions are very very crude! The returned BB is in coordinates local to the root prim (or the only prim) but for twisted prims it's way larger than the object itself! As a side note, it seems the same BB used for colliisions (which seems reasonably to me). Since all the prims calculations are necessarily done in the SL engine for rendering and physics purpose, I can't understand why they don't expose a more precise prim geometry in LSL! Thanks anyway
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
06-14-2009 07:16
Here's something I've used to turn the linkset's pos and bounding box into a region-relative bounding box (with a new pos representing the center)
SrsBox(vector pos, rotation rot, list bounds) { vector min_corner = llList2Vector(bounds, 0); vector max_corner = llList2Vector(bounds, 1); vector pos_from_corner = -min_corner; vector center_from_corner = (max_corner - min_corner) / 2.0; vector center_from_pos = center_from_corner - pos_from_corner;
vector out_pos = pos + (center_from_pos * rot); vector out_scale = (max_corner - min_corner) + <0.25, 0.25, 0.25>;
llSetPrimitiveParams([PRIM_POSITION, out_pos, PRIM_SIZE, out_scale, PRIM_ROTATION, rot]); }
Of course the bounding box is still rotated so it's not parellel to the ground and stuff... If you need to check whether a point's within the box, you can rotate the point's position relative to the box:
integer WithinArea(vector pos) { vector min_from_pos = bbox_min - pos; vector max_from_pos = bbox_max - pos; min_from_pos /= bbox_rot; max_from_pos /= bbox_rot; if(min_from_pos.x < 0 && max_from_pos.x > 0) { if(min_from_pos.y < 0 && max_from_pos.y > 0) { if(min_from_pos.z < 0 && max_from_pos.z > 0) { return TRUE; } } } return FALSE; }
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
06-14-2009 09:28
From: Rael Delcon Since all the prims calculations are necessarily done in the SL engine for rendering and physics purpose, I can't understand why they don't expose a more precise prim geometry in LSL! the function only returns the first phase bounding box IIRC... the physics engine uses two phases: one with rough figures, one with finer figures (to speed filtering of collisions).
_____________________
| | . "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... | - 
|