These forums are CLOSED. Please visit the new forums HERE
World Axis Scale |
|
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-30-2008 12:21
I need to find a prim's size on the world axis; that is, for example, how much space it's taking up on the sim's X axis, regardless of its rotation.
_____________________
Help find a missing child.
|
Void Singer
Int vSelf = Sing(void);
![]() Join date: 24 Sep 2005
Posts: 6,973
|
12-30-2008 12:38
at which z height relative to objects center? or for that matter y depth... never mind possible shapes. even flattened and using the largest dimensions it's going to be difficult to code for all shapes.
_____________________
|
| . "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... | - |
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-30-2008 12:58
Well, basically I'm just trying to figure out how to factor rotation into the scale. I'm not terribly concerned about the shape. On an un-rotated cube, I can use llGetPos and llGetScale to find out, for example where the East edge is: pos.x + (scale.x / 2.0). That is, the point at which the X axis intersects the prim. I'd like to get the same information for a rotated prim.
_____________________
Help find a missing child.
|
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-30-2008 13:52
I believe I've got it:
llFabs(llGetScale() * llRot2Fwd(llGetRot()) using llRot2Left and llRot2Up for Y and Z, of course. I really have no idea what I'm doing here; I'm just trying different things and seeing what they do. I'm going to go try it in my application and see how it does, but if anyone can offer an explanation of why this is or is not a good solution, it would be greatly appreciated -- I really like to know what I'm doing! ![]() _____________________
Help find a missing child.
|
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-30-2008 16:09
:
![]() ![]() Any other suggestions? _____________________
Help find a missing child.
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
12-30-2008 18:23
Not really up to any deep thought now until 2009 but I suspect that using llGetBoundingBox instead of llGetScale() is at least a good part of the way to the answer.
_____________________
http://slurl.com/secondlife/Together
|
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-30-2008 19:08
Unfortunately, llGetBoundingBox is hosed: http://jira.secondlife.com/browse/SVC-2741 Anyway, I'd still have to factor in rotation, and it's essentially the same data anyway -- it's simple to get bounding box from scale, and vice versa.
Edit: OK, not so simple. For a box it's simple: (<scale> * -1.0) / 2.0 , <scale> / 2.0 For other shapes, not so simple. _____________________
Help find a missing child.
|
Void Singer
Int vSelf = Sing(void);
![]() Join date: 24 Sep 2005
Posts: 6,973
|
12-30-2008 20:11
well it would seem you are looking at flattening, which makes it a matter of limits, rather than one of a single ray, but the shape issue is still going to get you.
a rotated cube is one thing, but try the same trick with a cylinder, cone, torus or other shape and the math's all different, that's the poin I was trying to make for a edge to point structure (cubes, rectilinears, pyramids, diamonds etc) it's mostly easy, calculate all the corners as offsets, apply the rotation to the offsets, then keep the highest and lowest x values, and get the difference between them, that's your flattened absolute bounds for the x axis at least spheres are easy... assuming they aren't contorted into ellipsoids. _____________________
|
| . "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
|
12-31-2008 10:35
I'd definitely say llGetBoundingBox() as well. That it's broken just means we need to vote for it and get it fixed. I have scripts that depend on its proper function myself, and I'm sure there are plenty more out there. Now if you were just interested in the rough SIZE of the prim along one of the axes, you could figure out where the corners of the bounding box are:
CODE
Then you could transform each corner into world coordinate offsets and track the min and max x-coordinate values: CODE
If you really wanted where the global x-axis "intersects" the bounding box, you're going to have to decide what that means. Where a line in the x-direction through the root prim's position intersects? Where a line through the center of the bounding box intersects? What? Once you figure that out, it's probably going to take some ray tracing to figure out where the line you want intersects each face of the cube. In any case, it's still not going to be exact because a bounding box is just that. If you really, REALLY want an exact answer, you're going to have to recreate the mathematical geometry SL uses to create object meshes based on primitive parameters. |
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
12-31-2008 10:41
Alternately, take the practical approach. Rez a small prim, move it physically along the line you are interested in (slowly) and see where it is on 'collision_start' with your object. Maybe turn your main object physical also and use llVolumeDetect() on the feeler prim to make sure other obstacles don't get in the way.
|
Siann Beck
Beauty & Braiiiiinsss!
![]() Join date: 14 Jul 2007
Posts: 140
|
12-31-2008 20:06
OK, with the help of a friend I got the rotation part figured out: just rotate the scale. Simple enough that I even understand it! I just may get the hang of this spatial stuff yet.
I'm still using llGetScale, and it works well enough for what I need now. I'm going to see if I can figure out a workaround for the bounding box bug and if so I'll switch to that, or otherwise wait until it's fixed. _____________________
Help find a missing child.
|