single-axis llRotLookAt
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-13-2006 20:17
I'm trying to get llRotLookAt to work on only 1 axis but the code from Christopher Omega and Blind Wanderer isn't working (see the comments). How can I get something to always stay level (x and y axes) but letting it rotate any direction on vertical/up/z axis? I want to make something stay horizontal but rotate on the vertical axis freely.
|
|
Fenrir Reitveld
Crazy? Don't mind if I do
Join date: 20 Apr 2005
Posts: 459
|
02-13-2006 21:08
llSetStatus (STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE) ; This will prevent X/Y rotations. However, these flags don't seem to ALWAYS work, especially if an object is going in/out of physics mode. Or, if you want to do the math yourself, just calculate the angle needed to point towards the object along X-forward and use that for Z...
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-13-2006 21:38
Read the comments on that page please...
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
02-14-2006 01:57
vector looking_direction = <blah, blah, blah> - llGetPos(); // direction you want your object to look at
looking_from.z = 0.0; llRotLookAt(llRotBetween(<1, 0, 0>, looking_direction), 0.2, 0.5);
Change z to y or x if you need to rotate around other axises. Change the <1,0,0> to whatever local axis of your object you want to point in the desired direction 
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-14-2006 02:03
What is looking_from? Commenting that line out, or renaming it to looking_direction, the object is still constrained to 3 axes...
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-16-2006 13:22
bump
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-16-2006 13:23
Anyone? Anyone? Beuler? Beuler?
|
|
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
|
02-16-2006 15:15
llRot2Euler() will work, but i could also see myself playing with code like this  { ....
float halfAngle = theta / 2.0; llRotLookAt( < 0.0, 0.0, llSin( halfAngle ), llCos( halfAngle ) >, strength, damping ); .... }
Edit: I got my sine and cosine backwards -- oopsie!  Fixed.
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-16-2006 23:03
This doesn't work either. I tried PI and TWO_PI for theta but it doesn't matter; the object still has ALL axes locked.
People, PLEASE test your scripts before posting them here! If you don't understand what I want (don't know how else to explain it), DON'T POST A SCRIPT UNTIL YOU UNDERSTAND THE PROBLEM! Sheesh...
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
02-17-2006 01:40
rotation zero_xy(rotation a) { vector b = <1,0,0> * a; b.z = 0; return llRotBetween(<1,0,0>,llVecNorm(b)); }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Eep Quirk
Absolutely Relative
Join date: 15 Dec 2004
Posts: 1,211
|
02-17-2006 01:51
That doesn't constrain the axis/axes at all, Strife... Again, I want to ONLY allow rotation on the Z/UP/VERTICAL/BLUE axis while keeping the X/Y (horizontal) axes fixed.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
02-17-2006 03:02
Okay, let's get this straight. What exactly are you trying to achieve? What is your input, how should the object behave given that input? Why do you want to look llRotLookAt in the first place?
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
02-17-2006 05:14
sorry there was a typo and i got my rot between backwords. Oh and it works.
And if you give it a gimble locked rotation it will not work properly.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
|
02-17-2006 19:11
From: Eep Quirk This doesn't work either. I tried PI and TWO_PI for theta but it doesn't matter; the object still has ALL axes locked.
People, PLEASE test your scripts before posting them here! If you don't understand what I want (don't know how else to explain it), DON'T POST A SCRIPT UNTIL YOU UNDERSTAND THE PROBLEM! Sheesh... Oh? Create a box. Put this script in it. Touch the box. // The THETA is PI / 3.0. float THETA = 1.04719;
rotation currRot;
default { state_entry() { llSetStatus( STATUS_PHYSICS, FALSE );
// Make sure we're not sitting on the ground llSetPos( llGetPos() + < 0.0, 0.0, 1.0 > );
// Make sure we're able to freely rotate on all axes llSetStatus( STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE );
// Make sure we're not starting at some weird rotation llSetRot( ZERO_ROTATION );
// Make sure we don't bump into anything when we rotate llSetStatus( STATUS_PHANTOM, TRUE );
// Make sure we're physics-enabled so llRotLookAt() will work. llSetStatus( STATUS_PHYSICS, TRUE );
// Freeze mid-air llStopMoveToTarget(); llMoveToTarget( llGetPos(), 0.1 );
currRot = llGetRot(); }
touch_start( integer total_num ) { // Apply the rotation to our current rotation // Note: this is basically the SAME EXACT THING as my earlier post float halfAngle = THETA / 2.0; currRot = < 0.0, 0.0, llSin( halfAngle ), llCos( halfAngle ) > * currRot;
// Look in the new direction llRotLookAt( currRot, 0.4, 0.2 ); } }
|
|
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
|
02-17-2006 19:59
Create another box. Put this script in it. Stay within ten meters of the box -- you don't even have to touch it. This is my understanding of what you're looking for. // Looks at the target at newTarget by only turning about the Z axis lookAtTargetOnZ( vector newTarget ) { vector lookDir = newTarget - llGetPos(); float halfAngle;
if(( lookDir.x == 0.0 ) && ( lookDir.y == 0.0 )) return;
// The SAME EXACT CODE that i posted earlier halfAngle = llAtan2( lookDir.y, lookDir.x ) / 2.0; llRotLookAt( < 0.0, 0.0, llSin( halfAngle ), llCos( halfAngle ) >, 0.4, 0.2 ); }
default { state_entry() { llSetStatus( STATUS_PHYSICS, FALSE ); llSetPos( llGetPos() + < 0.0, 0.0, 1.0 > ); llSetStatus( STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE ); llSetRot( ZERO_ROTATION ); llSetStatus( STATUS_PHANTOM, TRUE ); llSetStatus( STATUS_PHYSICS, TRUE ); llStopMoveToTarget(); llMoveToTarget( llGetPos(), 0.1 );
llSensorRepeat( "", llGetOwner(), AGENT, 10.0, PI, 1.0 ); }
sensor( integer total_num ) { lookAtTargetOnZ( llDetectedPos( 0 )); } }
|