[slscripters] Birdcage rotations (Ferd Frederix)

Timeless Prototype timelessprototype at gmail.com
Sat Sep 3 15:12:13 PDT 2011


Hello Ferd

As I read your e-mail it really tugged at my heart because I remember
the pain of learning about rotations in Second Life.

This code will work with a linked (child) prim in a link set. Maybe
there's an idea in there to be had?:
llSetPrimitiveParams([ PRIM_POSITION, pos, PRIM_ROTATION, ZERO_ROTATION
* rot / llGetRootRotation()]);

I have other examples of the hardest rotations I've ever had to do in SL
here for all to use, feel free to explore:
http://www.timelessguru.com/downloads

If you're still stuck by tomorrow, let the list know.

regards
Timeless Prototype


On Sat, 2011-09-03 at 16:04 -0500, Fred Beckhusen wrote:
> Ref: Birdcage rotations
> 
> Hello fellow scripters and Kelly Linden.   I made a really cute birdcage 
> with 4 birds that fly around and position themselves in the cage at a 
> bunch of rotated places, but there is a problem that is driving me 
> crazy.  It seems to be caused by an essential rotation that they need:  
> the birds must be rotated when they are sitting by <0.0, -90.0, 180.0> 
> in order to sit and then fly away correctly.  This is because of the 
> way  llLookat() works and other construction details, where llLookAt 
> points the Z at the destination instead of the X.  I have been unable to 
> find away around the need for this rotation.   But with the rotation, my 
> script only works when I set the cage rotation to <0,0,0>.
> 
> The birds can be seen flying correctly at this link:  
> http://www.vimeo.com/28494042  (Caution, major cuteness)   But if I 
> rotate the cage around any axis, they do not position themselves 
> properly inside the cage.
> 
> I made a greatly simplified test script to show the problem.   The 
> script requires an object named 'Object' in the test prim.   Make an 
> elongated box named "Object' and color each side and set it to be a TEMP 
> prim.   Take it back to inventory and place it inside a cube with the 
> test script.  Orient the cube to a rotation of <0,0,0>. Each time you 
> touch the prim, a box appears at a different position.   The coordinates 
> in the script make a directional  pointer bar, and X's raised up 1 
> meter.  These coordinates are made for my bird cage using other scripts 
> and they represent different relative bird positions and orientations to 
> the root prim.  Then rotate the box any way you want, and click it 
> multiple times and you will see that it is broken.
> 
> If you un-comment this in the script to make a ZERO_ROTATION as in 
> <0,0,0,1>:
> 
> // NOTE this line will fix it so it works.
> //rot2Add = llEuler2Rot(<0.0, 0.0, 0.0> * DEG_TO_RAD);
> 
> then it eliminates the final < 0.0, -90.0, 180.0> rotation that my birds 
> need.    It then properly positions and rotates the Object prim when the 
> root is rotated.  But In the actual cage, the birds will be pointing 
> backwards  and upside down!
> 
> An image showing the test script working correctly, with the above line 
> executing to set the final rotation to 0, is at this dropbox link:
> http://dl.dropbox.com/u/31305726/without%20rotation%20compiled%20in%20does%20work.png 
> 
> 
> The root prim on the right is rotated 45 degrees, and the test objects 
> are correctly rotated, identical to the object and test prims on the left.
> 
> Another image with the final rotation I need compiled in is shown at 
> this dropbox link:
> http://dl.dropbox.com/u/31305726/with%20rotation%20compiled%20in%20does%20not%20work.png
> 
> The one on the right should look like the one on the left, only rotated 
> 45 degrees. But looks like the boxes (or me)  have been drinking again.
> 
> Obviously the positioning of the boxes and birds is working, but the 
> final line of code where I set the final rotation is not correct.
> 
> rotation rezRot = relativeRot * myRot * rot2Add ; // this is wrong
> 
> 
> Anybody got any ideas?
> 
> Want one?   Send me a notecard in world with your SL name asking for a cage (so we don't spam the list) and I'll send a
> cage full of cuties when I get this working and the birds and I sober up.
> 
> 
> 
> Ferd Frederix
> 
> fred.b at mitsi.com
> 
> 
> 
> The test script:
> ////////////////////////
> 
> list vectors ;
> 
> integer index = 0;
> 
> default
> {
>      state_entry()
>      {
>         vectors +=<0.00000, 0.00000, 0.00000>;		// first click is the same as the root box
>         vectors +=<0.00000, 0.00000, 0.00000>;
> 
>         vectors +=<0.00000, 0.00000, 1.00000>;		// move up in Z
>         vectors +=<0.00000, 0.00000, 0.00000>;
> 
>         vectors +=<1.00000, 0.00000, 1.00000>;		
>         vectors +=<0.00000, 0.00000, 0.00000>;
> 
>         vectors +=<-1.00000, 0.00000, 1.00000>;
>         vectors +=<0.00000, 0.00000, 0.00000>;
> 
>         vectors +=<0.00000, 0.00000, 1.00000>;
>         vectors +=<0.00000, 0.00000, -45.00000>;
> 
>         vectors +=<1.00000, 0.00000, 1.00000>;
>         vectors +=<0.00000, 0.00000, -45.00000>;
> 
>         vectors +=<-1.00000, 0.00000, 1.00000>;
>         vectors +=<0.00000, 0.00000, -45.00000>;
>      }
> 
>      touch_start(integer total_number)
>      {
>          // fetch the pair of vectors and rotations
>          vector relativePosOffset = llList2Vector(vectors,index);
>          index++;
>          rotation relativeRot = llEuler2Rot( llList2Vector(vectors,index)  * DEG_TO_RAD );
>          index++;
> 	
>          if (index>  llGetListLength(vectors))
>              index = 0;
> 
> 	// the above code plucks a relative pos and a rot from the master list of cage positions
> 
>          vector myPos = llGetPos();
>          rotation myRot = llGetRot();	
> 
>           // MUST rotate it, but this screws it up dangnabbit
>          rotation rot2Add = llEuler2Rot(<0.0, -90.0, 180.0>  * DEG_TO_RAD);
> 
>          // NOTE uncomment this line will fix it so it works, but the birds will sit weird.
> 	 //rot2Add = llEuler2Rot(<0.0, 0.0, 0.0>  * DEG_TO_RAD);
> 
>          vector rezPos = myPos+relativePosOffset*myRot;	// add to root the offset and rotate it to new position
> 
>          rotation rezRot = relativeRot * myRot * rot2Add ; // this is wrong
> 
>          llRezObject("Object",rezPos,<0,0,0>,rezRot,0);
> 
>      }
> }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters




More information about the secondlifescripters mailing list