|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
06-30-2008 05:03
Hi, I am trying to make a HUD that includes a pointer. The pointer should point at a heading that comes from a call to llDetectedPos(..). Here are the problems I am having: * This is a linked set * Since the pointer is on a HUD, I am orienting it so that North (or straight-ahead) is Up, and South (or behind you) is down. * I have tried lots of different ways to rotate the prim but cannot convert the angle between the HUD wearer and llDetectedPos(..) from horizontal to vertical. * I can rotate the prim now on the horizontal axis, but that does not work to well on a HUD  * Rotating the child prim is not a problem - but it could become one if the pointer has two parts - any advice if this is possible? I actually just need help with the second and third points. I was thinking of tapering and flattening a cube to represent the arrow/pointer. Thanks -2fast
|
|
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
|
06-30-2008 07:32
Hmmm... For a HUD, instead of rotating prims, I would rather suggest using textures on flat boxes. This way, you can rotate a complex shape without the hassle of having to try to rotate several prims. That's what I use for my HUD radar. Now, let's assume you follow my advice. Here is the function I use: float kbAngle(vector their_pos) { vector norm_target = llVecNorm(their_pos - llGetRootPosition()); norm_target.z = 0.0; vector angle = llRot2Euler( llRotBetween(<1.0, 0.0, 0.0>, norm_target) ); return angle.z; } The sensor is in the root prim so llGetRootPosition() is the position of the avatar wearing the HUD and I transmit the float value kbAngle(llDetectedPos(x)) through a link message to the pointer prim where I just use: llRotateTexture(4, transmitted_angle); If neither the root prim nor the pointer prim are rotated, the visible face of the pointer prim (a box) on a HUD will be number 4. This will work also directly with a face of the root prim. VoilĂ ! Play a little with this function and come back if you need more... 
|
|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
Super
06-30-2008 08:31
Oh cool...that works really well! I actually found a bug in my HUD with this. Solves both of my problems! Thanks 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-30-2008 11:47
However, you can do what you wanted too. What you want is a local rotation applied to the object in addition to a base rotation that shows a top view on the HUD.
Imagine standing upright and facing due east in-world (this is the orientation that ZERO_ROTATION represents). Which way do you want your HUD pointer to face in this situation? Imaging rotating it from x-forward, y-left, z-up to that orientation. For example, if you want the pointer to point to the right in this case (x-axis to the right on your screen that is), you might tilt it back toward you (-90 degrees about the y-axis), then clockwise on the screen (-90 degrees about the object's local z-axis). This would be a rotation of (remember that local rotations go first):
rotation baseRot = llAxisAngle2Rot(<0.0, 0.0, 1.0>, -PI_BY_TWO)*llAxisAngle2Rot(<0.0, 1.0, 0.0>, -PI_BY_TWO);
With that rotation, the object's x-axis points to the right, and the object's z-axis points toward you. Now you will want another local rotation equal to the avatar's rotation in-world. I.e. as the avatar rotates counter-clockwise about the z-axis, your object rotates counter-clockwise about its local z-axis (counter-clockwise on your screen):
rotation objectRot = llGetRot()*baseRot;
Again the local rotation has been applied on the right.
|