Rezzing object with certain rotation
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
08-13-2007 09:04
hi, trying to rez an object with certain rotation.
So far, it didn't work the way i wanted.
I got prim A and inside prim A there is prim B. If you click on prim A it rezes prim B. Prim B should have a certain rotation - let's say 0,90,0. I managed to do that, but after manually rotating prim A, prim B showed up in a weird rotation.
Is there a way to make prim B rez with a certain rotation, no matter what rotation prim A has?
Thanks for helping!
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
08-13-2007 09:24
Well...it depends on how you have the script set. The rez object command should rez whatever at the rotation you specify independant of the rotation of the rezzing prim. So unless you're basing the rez'd rotation of the prim off the rotation of the rezzing prim, then moving it shouldn't matter.
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
08-13-2007 09:39
I used this for setting the rotation...I guess it could be done easier...
vector modVec = <44, 344, 245>; // This is the rotation I want to set to PRIM B modVec *= DEG_TO_RAD; // Convert that to Radians rotation modRot = llEuler2Rot(modVec); // Convert the vector to a Quaternion rotation newRot= llGetRot() * modRot; // Combine it with the current rotation (combining two quaternions uses the * not +) llRezObject("PRIM B", llGetPos() + <0, 0, 0.91>, ZERO_VECTOR,newRot, 42);
This sets weird rotation to PRIM B, if PRIM A gets rotated before rezzing...
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
08-13-2007 09:48
From: someone This sets weird rotation to PRIM B, if PRIM A gets rotated before rezzing... Correct! In the example you posted, try using modRot instead. llRezObject takes a global (region relative) rotation, and it looks like you were expecting it to take a local (relative to rezzing object) rotation.
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
08-13-2007 10:21
In other words...remove the newRot line completely and just use the line: llRezObject("PRIM B", llGetPos() + <0, 0, 0.91>, ZERO_VECTOR,modRot, 42);
right now you're basing it off the rotation of the rezzing prim, which is why you see the changes you do when you move it.
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
08-13-2007 11:07
Thanks! It worked! Sad, it didn't solve my problem... I guess I need to work out a more advanced script. So let me explain, what causes trouble now. Prim A is linked to a cylinder. When the cylinder gets clicked, it sends a linked message to Prim A and Prim A rezes Prim B. The one and only need for Prim A is to get the correct position for Prim B. First I wanted to put Prim B into the cylinder and rez it with correct position and rotation when clicking on it. But it didn't work. Not to make it too complicated...here is exactly what I need to figure out: To rez a prim on the surface of a cylinder with a certain position and rotation. If I manually rotate or move the cylinder and then rez the prim, the position and rotation should be the same, but according to the new position and rotation of the cylinder. Its easy to imagine if you think about a prim linked to a cylinder. When you rotate or move the cylinder, the linked prim moves with it. Thats exactly what i want to do. Tell me, if this is explained to complicated  Thanks
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
08-13-2007 11:34
If the prim that calls llRezObject is the root prim:
llRezObject("PRIM B", llGetPos() + <0.0, 0.0, 0.91>, ZERO_VECTOR, llGetRot(), 42);
If the prim that calls llRezObject is not the root prim:
llRezObject("PRIM B", llGetPos() + llGetLocalPos() + <0.0, 0.0, 0.91>, ZERO_VECTOR, llGetRot(), 42);
Is this helpful?
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
08-13-2007 11:37
A tweak to that code will have your PRIM B oriented correctly against that same surface of the cylinder even if the cylinder is tilted around the region X or Y axes:
root prim version:
llRezObject("PRIM B", llGetPos() + llRot2Up(llGetRot()) * 0.91, ZERO_VECTOR, llGetRot(), 42);
child prim:
llRezObject("PRIM B", llGetPos() + llGetLocalPos() + llRot2Up(llGetRot()) * 0.91, ZERO_VECTOR, llGetRot(), 42);
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
08-13-2007 16:20
Thank you very much...now it works!!!
|
|
Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
|
08-14-2007 16:12
Another question about rezing with certain rotation..
I got a root prim and inside this root prim i got 2 prims. They are called "Prim Left" and "Prim Right". When I click the root prim, I want "Prim Left" to be rezzed 3 metres to the left of the root prim. The same with "Prim Right" to the right of the root prim. Is this possible?
I tried this line: llRezObject("Prim Left", llGetPos() + <3, 0.0, 0>, ZERO_VECTOR, llGetRot(), 42);
The problem is, that it works in the position the root prim is now, because 3 metres to the left is on x axis. So I used "<3,0,0>" for correct position. As soon as I rotate the root prim, let's say by 90 degrees, the prim still rezes on the x axis. I understand that, because thats what I told it to do. But, in order to rez 3 metres to the left of the root prim, it should now rez 3 metres on the y axis. Thats because of rotation.
Is there a way to rez a prim 3 metres to the left or right of a root prim, no matter what rotation the root prim has?
Any help appreciated. Thanks a lot!
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
08-14-2007 17:53
llRezObject("Prim Left", llGetPos() + llRot2Left(llGetRot()) * 3.0, ZERO_VECTOR, llGetRot(), 42); llRezObject("Prim Right", llGetPos() + llRot2Left(llGetRot()) * -3.0, ZERO_VECTOR, llGetRot(), 42);
|
|
Zen Zeddmore
3dprinter Enthusiast
Join date: 31 Jul 2006
Posts: 604
|
08-14-2007 23:51
To clarify, do you just want 'B' to appear on demand or is it's prior non-presence nessesary? Simply, would changing visibility work for you? If so use that. It's way less complex because your prims are pre-oriented exactly how you want them to be.
_____________________
A kilogram of programmable nanobots can lower the certainty of both death AND taxes.
|