Jump to content
Sign in to follow this  
dk201

rotation help!

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,

 

 

Share this post


Link to post
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:

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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~~

Share this post


Link to post
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.

Share this post


Link to post
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);        }}

 

Share this post


Link to post
Share on other sites

Yes that is a miracle.

  1. The conditions for llAxes2Rot() are not fullfilled: "All three vectors must be mutually orthogonal unit vectors."
  2. It can not work on attachments as metioned bye Qui

:smileysurprised::):smileyvery-happy:

Share this post


Link to post
Share on other sites

Dora Gustafson wrote:
  1. The conditions for llAxes2Rot() are not fullfilled: "All three vectors must be mutually orthogonal unit vectors."

:smileysurprised:
:)
:smileyvery-happy:

I don't know what that means, I don't know much about 3D math, expecially rotations, but I do know it works for me

Share this post


Link to post
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.) ;)

Share this post


Link to post
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);

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...