|
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
|
05-17-2008 16:09
I have the following code that im trying to make work. i have a 2x2 meter prim, its a miniture representation of a sim. the code im trying to make will move a marker from 0,0, <NOT USING Z> to a point i spesifie, here is the tricky part, i want to convert Real world values <EG use a landmark and get the X+Y from it> so for example if i told it the x and y were x128 y128 then my marker would be in the center of my miniture sim map but my code just wont work, any help will be apreciated. demo() {
vector AvatarPosition=<128,128,321>; //This is my Real World Cordanates vector MapPosition=llGetPos(); // Get the current position of the marker vector MarkerPosition=llVecNorm(<AvatarPosition.x,AvatarPosition.y,0>);
MapPosition.x=MapPosition.x-1; //Subtrackt 1M from both x and y so we end up at MapPosition.y=MapPosition.y-1; //Miniture map's <0,0,0> MarkerPosition = MarkerPosition * 2; //Times marker position so that we tell it that its 2 meter by 2 meters MarkerPosition = MarkerPosition + MapPosition; //That should have automatically corrected the Z, too. llSetPos(MarkerPosition); } default { state_entry() { demo(); }
}
This code just likes to put it at a random position please help!! 
|
|
WarKirby Magojiro
Registered User
Join date: 24 Oct 2006
Posts: 49
|
05-17-2008 18:13
This should do the trick. Untested, so can't be 100% sure. This accepts the avatar position as the input, and returns a position in region coordinates. Set the marker position to that exactly. This allows for a variable size base. Declare a global variable at the top with the size you want. It's a float, and it assumes x and y are the same. In your case, this will be 2.0 vector calc_pos(vector AvatarPosition) { vector MapPosition=llGetPos(); // Get the current position of the marker rotation MapRotation = llGetRot();
vector MarkerPosition=<AvatarPosition.x,AvatarPosition.y,0>; MarkerPosition = MarkerPosition - <128.0, 128.0, 0>; MarkerPosition = MarkerPosition / 128; return MapPosition + ((MapScale/2)*MarkerPosition)*MapRotation); //MapScale should be a global variable. A float value }
|