Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Flip vector to rez based on object position

2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
06-06-2009 07:27
Hi,

I am working on a map that displays a region's map image on a prim. I add some points of interest in some vectors and rez markers on the map.

Everything works perfectly, as long as the rotation of the map texture on the prim matches the map texture as it is as a result of getting it from submova.com/secondlife/map.php.

I need the map to work so that I can rotate the texture and still have the markers on the map rez at right places.

Here's the code I use to rez markers on the map:


vector scale = llGetScale(); //get prim size

vector targetPos = <100,10,0>; // location of the marker in-world

float xpos = (targetPos * scale.x) - (scale.x / 2.0); // convert x to relative coordinate on prim
float ypos = (targetPos * scale.y) - (scale.y / 2.0); // convert y to relative coordinate on prim

vector rezAt = llGetPos() + <xpos, ypos, 0.0> * llGetRot()); // current pos of prim + marker pos * current rotation


Obviously I need to do *something* with the rotation in the last line, but I have no idea what to do.

For simplicity and for now, I just want to flip the texture horizontally and vertically, so I guess I need to reverse the rotation.

Any suggestions?

Thanks -2fast
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 15:08
rotating the offsets as you do should work for basic rotations, if you're flipping the image you'll nee to invert the offset direction (such as -x to flip from left to right).

also you math for the positions doesn't look right, if you're using inworld coordinates I think what you want is
targetPos = (targetPos / 256 * scale) - (<0.5, 0.5, 0.0> * scale);

you may also want a z offset in there, or you can cancel it out, or code it for the scale of the map height (so the rez position isn't potentially embedded in the map)
_____________________
|
| . "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...
| -
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
06-07-2009 11:22
Cool - thanks Void! I also didn't realize that negating the x,y coordinates would revers them altogether - works really well :)