Avatar Rotations: Mouse Gestures
|
Memory Hax
Registered User
Join date: 30 May 2009
Posts: 5
|
07-23-2009 19:22
Hello SL Forums, I have recently been working on a project that would require some form of mouse gestures to use. Basically, I would want something where I could "click and swish" my mouse to change from one mode to another. I thought I would be able to do this with an HUD attachment and llGetRot. But the rotations that were regurgitated by the script were not governed in any way I expected. Maybe I'm just being stupid, but I expected avatars to only rotate on two axises. So say Z for up down and X for left right. I found that up-down could be achieved by using llRot2Up through trial and error, but I still cannot understand how to get left-right. I understand that in side to side there is a full 360 degrees of motion, but I was planning to have a limit, say 50 degrees to the left/right until it hits the roof. I hope I explained myself clearly, so can anyone help me with this? I'm not asking for a full script (But if you want, you're more than welcome to.  ), but maybe some code snippets or some helpful pointers to push me in the right track?  Thanks for taking the time to read this!
|
Cerise Sorbet
Registered User
Join date: 8 Jun 2008
Posts: 254
|
07-23-2009 20:05
Hi Memory! How did the rotation monster find you? Do you use llDetectedGrab? It is the devil on a HUD! The new ones like llDetectedTouchST are so much more simple. They can reference the prim and not the world.
|
Memory Hax
Registered User
Join date: 30 May 2009
Posts: 5
|
07-23-2009 20:09
From: Cerise Sorbet Hi Memory! How did the rotation monster find you? Do you use llDetectedGrab? It is the devil on a HUD! The new ones like llDetectedTouchST are so much more simple. They can reference the prim and not the world. Woah, I didn't know there was an llDetectedTouchST. I tried something with llDetectedGrab months ago, and I remember that didn't work too well on an HUD. I will give that a shot, because them darned rotations are driving me up a wall.  EDIT: But it doesn't seem like you can click and drag? Or can you, and I'm just a silly person?
|
Cerise Sorbet
Registered User
Join date: 8 Jun 2008
Posts: 254
|
07-23-2009 21:58
Compare coordinates during touch event or between touch_start and touch_end?
|
Cerise Sorbet
Registered User
Join date: 8 Jun 2008
Posts: 254
|
07-23-2009 23:17
// this is a mouse compass. it says what direction you drag. it is not optimized.
// it is good to check the detected face. make sure it is the same and is not a bad face. // this script is dumb, it assumes the face is good because i am tired.
// mouse start point vector gStartST;
default {
touch_start(integer detected) { llOwnerSay("face " + (string)llDetectedTouchFace(0)); // start position gStartST = llDetectedTouchST(0); llOwnerSay("start " + (string)gStartST); } touch_end(integer detected) { // end position vector endST = llDetectedTouchST(0); llOwnerSay("end " + (string)endST);
// how far, maybe you want to discard small drags vector dragRelative = endST - gStartST; float dragMag = llVecMag(dragRelative); llOwnerSay("magnitude " + (string)dragMag);
// direction.z is drag direction as degrees, 0 is right, +90 is up -90 is down, +/- 180 is left vector direction = llRot2Euler(llRotBetween(< 1,0,0 >, llVecNorm(dragRelative))) * RAD_TO_DEG; llOwnerSay("direction " + (string)direction);
float directionAbs = llFabs(direction.z);
// make the angle into 1 of 8 compass directions or none string compass;
// did the mouse fall off the end? if (endST == TOUCH_INVALID_TEXCOORD) { compass = "- drag too far -"; } else if (dragMag < 0.01) { compass = "- none -"; } else if (directionAbs < 22.5) { compass = "E"; } else if (directionAbs < 67.5) { if (direction.z > 0.) compass = "NE"; else compass = "SE"; } else if (directionAbs < 112.5) { if (direction.z > 0.) compass = "N"; else compass = "S"; } else if (directionAbs < 157.5) { if (direction.z > 0.) compass = "NW"; else compass = "SW"; } else { compass = "W"; } // end if llOwnerSay("direction " + compass + "\n======="); } }
|
Memory Hax
Registered User
Join date: 30 May 2009
Posts: 5
|
07-24-2009 11:26
Oh-my-god. You are my hero.
|
Memory Hax
Registered User
Join date: 30 May 2009
Posts: 5
|
07-25-2009 01:36
But as much as I love the previous script posted, my system could do alot better without the giant prim on the mouselook screen. It creates more problems than it solves. Does anyone have any other suggestions?
|
Nexii Malthus
[Cubitar]Mothership
Join date: 24 Apr 2006
Posts: 400
|
07-25-2009 04:34
Possible trick, touch_start change size? You might need to ignore the start of the touches because the coordinates will jump around as the size changes.
Use touch event for your data, touch_end for last data point and go small again.
_____________________
 Geometric Library, for all your 3D maths needs. https://wiki.secondlife.com/wiki/Geometric Creator of the Vertical Life Client
|
Cerise Sorbet
Registered User
Join date: 8 Jun 2008
Posts: 254
|
08-01-2009 16:23
Hi! Yes it is hard to make this work if you want the gesture to work on the whole screen. It is very hard to use a touch event on a gesture, it is throttled at 0.1 second and it is worse with lag. I used touch_start and touch_end because touch was too slow.
|