Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Map Hud

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-08-2009 21:30
so i'm building a maze. in many video games you can get a map of the building you're in that's displayed as a hud, i'm trying to figure out how to make that in sl, i was gonna use a prim to represent my avatar on the map, but figured it'd be better to use a texture. either way i go, i have no idea how to convert the avatar's position into a vector for offsetting the texture/prim. the rotation should be as simple as converting the rotation to a angle vector and using the Z rotation right?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-09-2009 01:11
matching the position to your map would be something like (SL distance from SW corner)/(SL distance from sw to ne corner) that should give you the center position offset on the map texture. (it's a percentage in 2 directions) then rotate it as you planned (you can either rotate the marker, or the map... rotating the map is more confusing to some people to read though, some people orientate ground static, others body static)
_____________________
|
| . "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...
| -
Aztral Aeon
Registered User
Join date: 22 Dec 2007
Posts: 34
07-09-2009 01:18
You might wanna try a test to see how it'll all work out...
Create a test prim of the same type you intend to use for your map, then just set the texture to the one you'll use for your AV. Test different offsets, rotations to see how they effect things.

These things really depend on which prim type you use, and which face you'll be texturing...which is why I say do some simple testing first to get a "feel" for things before coding. But ya..in theory you should be able to just offset/rotate the texture and get the result you want :)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-09-2009 02:02
yeah, the marker would be a transparent texture with a dot or some other shape in the center, and the map would be a background texture on a seperate prim. i guess though, once i have the offsetting worked out, it would work for either style (move the map, or move the marker) and each user could specify that. now my problem is, do i want to use region coordinates or specify some central point on the build so if the build is moved, rotated, the map will adapt?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-09-2009 03:09
From: Ruthven Willenov
yeah, the marker would be a transparent texture with a dot or some other shape in the center, and the map would be a background texture on a seperate prim. i guess though, once i have the offsetting worked out, it would work for either style (move the map, or move the marker) and each user could specify that. now my problem is, do i want to use region coordinates or specify some central point on the build so if the build is moved, rotated, the map will adapt?

I'd go with figuring out the center of your map, and getting the distance to the corners from there... then you can calulate avs distance from center, and rotation around it (use llAtan 2 or their x,y offset from center)... the only change for the map would be to ofset the texture by half.
_____________________
|
| . "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...
| -
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-09-2009 07:47
From: Void Singer
(use llAtan 2 or their x,y offset from center)

use what??
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Aztral Aeon
Registered User
Join date: 22 Dec 2007
Posts: 34
07-09-2009 08:06
You may wanna consider just breaking up the sim into 4x4 parcels (like pixels), then test which "pixel" your AV is in and move the dot accordingly. This way you only have to worry about 64x64 possible positions

I made a sim parcel permission map-thingy that uses this method (except i rez colored rects instead of using a texture).
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-09-2009 23:28
the following assumptions are made
the corners of your build are SW = < 0,0,0 >; NE = < 256,256,0 >;
(build center) BC = ( NE - SW ) / 2;

llDetectedPos on the av returns it's position (avPos)
relativePos = avPos - BC;

your texture offset is then
offset = relativePos /BC

your rotation is
textureDegrees = llAtan2( relativePos.x, relativePos.y ) * RAD_TO_DEG;

(at least I think the texture rotates from the center AFTER offset... if it's before the math is a little different)
_____________________
|
| . "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...
| -
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-10-2009 16:13
From: Void Singer
the following assumptions are made
the corners of your build are SW = < 0,0,0 >; NE = < 256,256,0 >;
(build center) BC = ( NE - SW ) / 2;

llDetectedPos on the av returns it's position (avPos)
relativePos = avPos - BC;

your texture offset is then
offset = relativePos /BC

your rotation is
textureDegrees = llAtan2( relativePos.x, relativePos.y ) * RAD_TO_DEG;

(at least I think the texture rotates from the center AFTER offset... if it's before the math is a little different)


i'm not in world at the moment, but i get what you mean....sorta, i read the lsl wiki and the regular wiki about atan2, still don't grasp it, i never took trigonometry. but i'll see if it works when i get a chance
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
07-10-2009 19:25
The pieces and parts for the math would be here in an old experiment of mine. Just ignore all of the z axis math if you want it to show the av at map level.
CODE

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Sensor Map Rezzor 1.0
// "Oct 17 2008", "20:42:17"
// Creator: Jesse Barnett
// Released into the Public Domain
//////////////////////////////////////////////////////////////////////////////////////////////////////

float mapSize = 6; //Set length of map side here
integer xyAxis = 256; //Set length of target area side here(simulator would be 256)
float maxHeight = 4.0; //Adjust rez height here (maximum 10)
list locList;
//Populate the locList however you want

///////////////////////////DO NOT CHANGE THESE///////////////////////////////////////////////
vector mapPos;
integer p;
integer locListLength;
list rezList;
integer rezListLength;
string avName;
float zScale;
string rezObj;

createList()
{
locListLength = llGetListLength(locList);
rezList =[];
for (p = 0; p < locListLength; ++p) {
vector rezPos = (vector) llList2String(locList, p);
rezPos = (rezPos - < 128, 128, 0 >) / (xyAxis / mapSize);
rezPos.z *= zScale;
if (rezPos.z > maxHeight) {
zScale = zScale * (maxHeight / rezPos.z);
createList();
return;
}
rezPos += mapPos;
float dist = llVecDist(rezPos, mapPos);
if (dist > 10) {
zScale = zScale * .998;
createList();
return;
}
rezList += rezPos;
++p;
rezList += llList2List(locList, p,p);
}
rezListLength = llGetListLength(rezList);
for (p = 0; p < rezListLength; ++p) {
integer key_chan = (integer) llFrand(-1000000) - 1000000;
llRezObject(rezObj, llList2Vector(rezList, p), ZERO_VECTOR, ZERO_ROTATION, key_chan);
p++;
llSleep(.25);
llRegionSay(key_chan, llList2String(rezList, p));
}
}

default {
touch_start(integer n) {
zScale = 1;
llSensorRepeat("", "", AGENT, 96, PI, 30);
mapPos = llGetPos();
rezObj = llGetInventoryName(INVENTORY_OBJECT, 0);
}
sensor(integer iNum) {
locList = [];
for (p = 0; p < iNum; ++p) {
vector avPos = llDetectedPos(p);
avName = llDetectedName(p);
locList += (list) avPos;
locList += (list) avName;
}
createList();
}
}
_____________________
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