Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prim rotation

Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
05-07-2007 20:17
llSetPrimitiveParams([PRIM_ROTATION, <180, 0, 0, 1>]);

Doesn't alway rotate the prim to where I want. It's attached to an on/off switch where off rotates the prim. Fifty percent of the time the prim rotates in the wrong direction untill I hit the off switch again, then it will rotate properly. The other fifty percent is rotates perfectly.
Why am I getting these hit or miss type results?
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
05-07-2007 20:45
If I'm not mistaken, using llSetPrimitiveParams() like you are only defines what endpoint you want the prim to have, not necessarily the direction to use. The way it is now, it's probably taking the shortest route.

If you want to specifically rotate a prim in a given direction at a given speed, you need to use something else.

I think what you need is llRotLookAt().
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
05-07-2007 21:39
From: Jacques Groshomme
If I'm not mistaken, using llSetPrimitiveParams() like you are only defines what endpoint you want the prim to have, not necessarily the direction to use. The way it is now, it's probably taking the shortest route.

If you want to specifically rotate a prim in a given direction at a given speed, you need to use something else.

I think what you need is llRotLookAt().


The endpoint is the only thing I'm concerned about. I have a prim set that moves (rotates around) for a reason, then when its done its job I hit the "off" switch and it rotates to look straight down, like putting it to sleep.
Again, it works 50%, or even higher than that, just not every time unless I hit the off switch one more time, then it always looks straight down.

Here is the on/off script I made (hacked). It's controled by another script in a remote prim.
CODE

integer chan = -27296;




default{
state_entry(){
llListen(chan, "", NULL_KEY, "");

}

listen( integer channel, string name, key id, string message ){
if ( message == "On" )
{
llSensorRepeat("",NULL_KEY,AGENT,10,PI,.1);
}
else if ( message == "Off" )
{
llSensorRemove();
llSetPrimitiveParams([PRIM_ROTATION, <180, 0, 0, 1>]);


}
}

sensor(integer det)
{
vector pos = llDetectedPos(0);
llLookAt(pos,1,1);
}
}
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
05-07-2007 23:48
<180, 0, 0, 1> does not look like a valid quaternian to me.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
05-08-2007 04:14
Quaternions have a value range from 0 to 1.0

rotation q = llEuler2Rot(<180,0,0>*DEG_TO_RAD);

this will convert angular values (0-360°) to a proper quaternion.
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
05-08-2007 04:59
From: Ed Gobo
<180, 0, 0, 1> does not look like a valid quaternian to me.

I dont get any errors with this and it works better than values of 0 to 1.0. 180 seems to always point the thing straight down perfectly (eventually) and no other values do, even tried negative numbers from 0 to -1.
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
05-08-2007 05:11
Hey, why we are at this, How can I get this to target who ever I want instead of the nearest avatar with a remote input? I was working with this script which I have shouting on a channel the name of the avatar picked.
I assume AGENT would have to be changed to the name shouted? Or the UUID of the avatar?

CODE

// Configurable Settings
float Range = 64; // 10 meters
float Rate = 5; // in seconds


// Detected list variables
list detected_list;
list detected_names;

// Dialog Handler
integer Listening;
integer ListenChannel;

key owner = NULL_KEY;

// Functions
UpdateListen(key id)
{
CancelListen();
Listening = llListen(ListenChannel,"",id,"");
llSetTimerEvent(30);
}

CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}

// Owner Conversation Dialog
StartConversation(key id)
{

string text = "Target?";
ListenChannel = (integer)llFrand(2147483646) + 1;
list AVList;
// Simple version - put AV names directly on Buttons
integer len = llGetListLength(detected_list);
if(len == 0)
{
text += "\n\nNo one here to target!";
}
else
{
if(len > 12)len = 12;
AVList = llList2List(detected_names,0,len - 1);
}

llDialog(id,text,AVList,ListenChannel);
UpdateListen(id);
}


default
{
state_entry()
{
owner = llGetOwner();
llSensorRepeat("", "", AGENT, Range , PI, Rate);
}

on_rez(integer num) { llResetScript();
}

changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_OWNER)
{
llResetScript();
}

}


no_sensor()
{
detected_list = [];
detected_names = [];
}

sensor( integer number_detected )
{
integer i;
string name;
detected_list = [];
detected_names = [];
for( i = 0; i < number_detected; i++ )
{
key id = llDetectedKey( i ) ;

{
// Limit name to 24 Characters
name = llGetSubString(llDetectedName( i ), 0 , 24);;

detected_list += id;
detected_names += name;
}
}
}

timer()
{
CancelListen();
}

touch_start(integer total_number)
{
// Owner
key id = llDetectedKey(0);
if( (id == owner))
{
StartConversation(id);
}

}
listen( integer channel, string name, key id, string message )
{
integer index = llListFindList(detected_names, [ message ] );
if(index >= 0)
{
llShout(-27296,llList2String(detected_names,index));

}
}
}