Jump to content

rotation help!


dk201
 Share

You are about to reply to a thread that has been inactive for 2198 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Greetings everyone,

I am working on a voodoo doll and need some help on rotation. The idea is that when you click the doll, the doll will rez an nail at the touch position. However my issue is that the nail is always rezzed with same rotation. I tried to play with rotation to make nails rezzed according to its relative position to the doll. but i never got good result. Anyone can help me to understand rotation in SL a little bit more? thanks,

 

 

Link to comment
Share on other sites

I still don't understand rotations/quarternions fully and don't expect I ever will, but I have learned the mathematical rules and I have worked a lot with them
Now I can do most things I want with rotations even though sometimes I need to rewrite several times before I get it right:smileyembarrassed:

My advise is: Work with it, read examples an make them work, give yourself problems and solve them

It takes time but there is no shortcut for normal people

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

Dora is right that you are most likely to learn if you just keep banging your head against the wall.  The more you play with rotation/position problems, the more you gradually develop a feel for them.  Ultimately, the only way that you truly understand them is to take the time to learn how to use matrix algebra to make 3D transformations.  You can get a start by digesting http://wiki.secondlife.com/wiki/Rotation .

In this particular case, you may be able to shortcut things quite a bit by using llDetectedTouchPos to get the region position where you touch the doll, and then correct that to get a local position.  Then use llRotBetween to rotate your nail to llDetectedTouchNormal at that spot.

Link to comment
Share on other sites

Just in case: This doll isn't an attachment, right? (It's not possible to make the rotation, nor even the position, of a separately rezzed object relate precisely to that of an attachment, at least not without very restrictive assumptions about the avatar's detailed shape and animation.)

Otherwise, yeah, learning rotations is a case of torturing it until it confesses.

Link to comment
Share on other sites

here's a script I came across in this forum (or the old forum?) years ago. I even tested on sculpties at the time, and it works wonderfully. As you the attachment reference, I wonder if you could attach a number of nails that would be hidden, and move them to the local position

ETA: here's the link to the post. Wow, that was a while ago! 

http://forums-archive.secondlife.com/54/89/334263/1.html

vector offset = <0,0,0.1>;default{    touch_start(integer total_number)        {            vector tchnorm = llDetectedTouchNormal(0);            vector tchpos = llDetectedTouchPos(0);            vector rezpos = tchpos + offset*llAxes2Rot(<0,0,0>,<0,0,0>,tchnorm);            rotation rezrot = llAxes2Rot(ZERO_VECTOR,ZERO_VECTOR,-tchnorm);            llOwnerSay("Touched.");            llRezObject("Object",rezpos,ZERO_VECTOR,rezrot,0);        }}

 

Link to comment
Share on other sites


dk201 wrote:

Thanks Rolly, those function you listed is what i need. I actually failed to define my question correctly, I just want to find a way to align an object along the Normal line. Thanks for help~~

You're welcome.  llRotBetween ought to do the trick.  To make it more logical, normalize the result of llDetectedTouchNormal before you compare it to the long axis of your pin (<0.0,0.0,1.0)> maybe?) so you are comparing unit vectors.

BTW, I am Rolig. (Ask Dora.) ;)

Link to comment
Share on other sites

Thanks everyone. I have following code to detect click normal and then figure out rotation before item rez. Works pretty good for me.

vector clickPos = llDetectedTouchPos(0);vector normal = llDetectedTouchNormal(0);            rotation rot = llRotBetween(<0, 0, 1>, normal);string itemName = "voodoonail";llRezObject(itemName, clickPos, ZERO_VECTOR, rot, 0);
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2198 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...