Jump to content

tilting camera orbit


kari1sl
 Share

You are about to reply to a thread that has been inactive for 3610 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi.

I'm stuck.

My script works when z=0 (waist or body level) but i can't control the height.

I'd like to circle at face level - FaceCircle - but my code makes the camera follow a tilted orbit - as if the center isn't centred.
Any suggestion why it doesn't work up the z-axis? Or how to fix it?

Thanks

 

    integer CHANNEL; // dialog channel
list MENU_MAIN = ["Me", "Waist", "WaistCircle", "BodyCircle", "FaceCircle", "More...", "Cam ON", "Cam OFF"]; // the main menu
list MENU_2 = ["More...", "...Back"]; // menu 2
integer on = FALSE;
integer trap = 0;

take_camera_control(key agent)
{
    llOwnerSay("take_camera_control"); // say function name for debugging
    llOwnerSay( (string)agent);
    llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);
    llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive
    on = TRUE;
}

release_camera_control(key agent)
{
    llOwnerSay("release_camera_control"); // say function name for debugging
    llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive
    llReleaseCamera(agent);
    on = FALSE;
}
me000()
{
    llOwnerSay("ME_0,0,0"); // say function name for debugging
      llClearCameraParams(); // reset camera to default
    vector here = llGetPos();
    llSetCameraParams([
        CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
        CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
        CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
        CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
        CAMERA_FOCUS, here, // region relative position
        CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
        CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
        CAMERA_PITCH, 0.0, // (-45 to 80) degrees
        CAMERA_POSITION, here + <0,0,0>, //REGION RELATIVE POSITION
        CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
        CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
        CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <X0,X0,X0> to <10,10,10> meters
    ]);
 llSleep(0.002);
}

me010()
{
    llOwnerSay("Waist"); // say function name for debugging
      llClearCameraParams(); // reset camera to default
    vector here = llGetPos();
    llSetCameraParams([
        CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
        CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
        CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
        CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
        CAMERA_FOCUS, here, // region relative position
        CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
        CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
        CAMERA_PITCH, 0.0, // (-45 to 80) degrees
        CAMERA_POSITION, here + <0,1,0>, //REGION RELATIVE POSITION
        CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
        CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
        CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <X0,X0,X0> to <10,10,10> meters
    ]);
 llSleep(0.002);
}


WaistCircle()
{
llOwnerSay("WaistCircle"); // say function name for debugging
llClearCameraParams(); // reset camera to default
float i; 
for (i = 0; i < TWO_PI; i+=0.01)
{
vector xyz = 1.0*< llCos(i), llSin(i), 0>;
vector here = llGetPos();
vector there = llGetPos() + xyz;
llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
CAMERA_FOCUS, here,
CAMERA_POSITION, there,  
CAMERA_POSITION_LAG, 3.0, // (0 to 3) seconds
CAMERA_POSITION_LOCKED, TRUE
]);
}
 llSleep(0.002);
}

BodyCircle()
{
llOwnerSay("BodyCircle"); // say function name for debugging
llClearCameraParams(); // reset camera to default
float i; 
for (i = 0; i < TWO_PI; i+=0.01)
{
vector xyz = 3*< llCos(i), llSin(i), 0>;
vector here = llGetPos();
vector there = llGetPos() + xyz;
llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
CAMERA_FOCUS, here,
CAMERA_POSITION, there,  
CAMERA_POSITION_LAG, 3.0, // (0 to 3) seconds
CAMERA_POSITION_LOCKED, TRUE
]);
}
 llSleep(0.002);
}

FaceCircle()
{
llOwnerSay("FaceCircle"); // say function name for debugging
llClearCameraParams(); // reset camera to default
float i; 
for (i = 0; i < TWO_PI; i+=0.01)
{
vector xyz = < llCos(i), llSin(i), 0>;//orbit equation
vector here = llGetPos() + <0,0,1>;//stare at top of head (+1)
vector there =llGetPos() + xyz + <0,0,1>;//as camera follows this orbit
llSetCameraParams([
CAMERA_ACTIVE, 1,
CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees
CAMERA_FOCUS, here,
CAMERA_POSITION, there , //REGION RELATIVE POSITION
CAMERA_POSITION_LAG, 3.0, // (0 to 3) seconds
CAMERA_POSITION_LOCKED, TRUE
]);
}
 llSleep(0.002);
} 
setup_listen()
{
    llListenRemove(1);
    CHANNEL = llRound(llFrand(1) * 100000);
    integer x = llListen(CHANNEL, "", "", ""); // listen for dialog answers
}

default
{
    state_entry()
    {
        setup_listen();
        llSetTimerEvent(2);
    }
   
    touch_start(integer total_number)
    {
integer perm = llGetPermissions();
if (perm & PERMISSION_DEBIT)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_DEBIT perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_TAKE_CONTROLS)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_TAKE_CONTROLS perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_TRIGGER_ANIMATION)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_TRIGGER_ANIMATION perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_ATTACH)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_ATTACH perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_CHANGE_LINKS)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_CHANGE_LINKS perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_TRACK_CAMERA)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_TRACK_CAMERA perms for "+(string)llGetPermissionsKey()); }
if (perm & PERMISSION_CONTROL_CAMERA)
{ llOwnerSay(llGetScriptName() + " has PERMISSION_CONTROL_CAMERA perms for "+(string)llGetPermissionsKey()); }
if (perm == 0)
{ llOwnerSay(llGetScriptName() + " has NO perms for "+(string)llGetPermissionsKey()); }

        llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
    }
   
    listen(integer channel, string name, key id, string message)
    {
        if (llListFindList(MENU_MAIN + MENU_2, [message]) != -1)  // verify dialog choice
//        if (llListFindList(MENU_MAIN, [message]) != X)  // verify dialog choice
        {
//            llOwnerSay(name + " picked the option '" + message + "'."); // output the answer
            if (message == "More...")
                llDialog(id, "Pick an option!", MENU_2, CHANNEL); // present submenu on request
            else if (message == "...Back")
                llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present main menu on request to go back

    else if (message == "Cam ON")
    {
        take_camera_control(id);
    }

    else if (message == "Cam OFF")
    {
        release_camera_control(id);
    }
        else if (message == "Me")
    {
        me000();
    }
    else if (message == "Waist")
    {
        me010();
    }
    else if (message == "WaistCircle")
    {
        WaistCircle();
    }
    else if (message == "BodyCircle")
    {
        BodyCircle();
    }
    else if (message == "FaceCircle")
    {
        FaceCircle();
    }

    else if (message == "Trap Toggle")
    {
        trap = !trap;
        if (trap == 1) {
            llOwnerSay("trap is on");
        }
        else {
            llOwnerSay("trap is off");
        }       
    }

        } else
            llOwnerSay(name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice
    }

    run_time_permissions(integer perm) {
        if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA) {
            llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive
            llOwnerSay("Camera permissions have been taken");
        }
    }
   
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (agent)
            {
                setup_listen();
                llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);
            }
        }
    }
   
    attach(key agent)
    {
        if (agent != NULL_KEY)
        {
            setup_listen();
            llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);
        }
    }
   
    timer()
    {
        if (trap == 1)
        {
            me000();
        }       
    }
   
}    

 

Link to comment
Share on other sites

  • 1 month later...


Thanks, Azwaldo, for the suggestion but it doesn't help.
The problem is close to the face - the best part for camera work.
I'm thinking that my geometry is wrong.

Type into public chat the command
"c"
 followed by RADIUS,
 then camera HEIGHT and
 camera FOCUS
(otherwise they will be zero)
with respect to the avatar's center (standing).
You have to touch the avatar to get it going. (Don't know why)

I've worked through a series of 1 meter orbits - first pointing to the avatar's center  (third value is zero).
Starting at ground, c 1 - 1 0, is good
the waist at c 1 0 0 is also good
another meter up at c 1 1 0 things look OK, but of course the focus is on the belly (at 0, the center), so naturally I want to look squarely in the face at ~1 meter above center.
Try c 1 1 1. It's way over head, a couple meters.
So, I decide to try 1 0 1 and thise wobbles around.Not along the avatar's Z-axis at all.

Strange

integer Pchannel(string salt){    string setint = (string)((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) * llStringLength(salt) * llCeil(llLog(llStringLength(salt)))); return (integer)llGetSubString(setint, 0, 7);}//KAMERA v10//removed max, min, high, low and simplifiedinteger on = FALSE;integer Handle;integer trap = 0;integer CHANNEL; // dialog channelfloat inc = 0.01 ;//increments from zerofloat revs = 2.0; //revolutionsfloat distance = 0; //declarefloat height =0; //declarefloat delta = 0;//declare float DELTA = 0;//declare   float deltabit = 0;//declare  float DIS = 0;//declare  take_camera_control(key agent){    llOwnerSay("take_camera_control"); // say function name for debugging    llOwnerSay( (string)agent);    llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);    llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive    on = TRUE;}release_camera_control(key agent){    llOwnerSay("release_camera_control"); // say function name for debugging    llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive    llReleaseCamera(agent);    on = FALSE;}setup_listen(){llListenRemove(1);CHANNEL =0;integer x = llListen(CHANNEL, "", "", ""); // listen for dialog answers} default{state_entry(){setup_listen();llSetTimerEvent(2);}   run_time_permissions(integer perm){    integer perm = llGetPermissions();    if (perm & PERMISSION_TRACK_CAMERA)    {        llOwnerSay(llGetScriptName() + " has PERMISSION_TRACK_CAMERA perms for "+(string)llGetPermissionsKey());         }if (perm & PERMISSION_CONTROL_CAMERA){    llOwnerSay(llGetScriptName() + " has PERMISSION_CONTROL_CAMERA perms for "+(string)llGetPermissionsKey());     }if (perm == 0){ llOwnerSay(llGetScriptName() + " has NO perms for "+(string)llGetPermissionsKey()); }}listen(integer channel, string name, key id, string message){list input = llParseString2List(message, [" "], []);string action = llList2String(input, 0); float dis = llList2Float(input, 1);float zthere= llList2Float(input, 2);float zhere= llList2Float(input, 3);float zthere2= llList2Float(input, 4);if (action == "off"){    llListenControl(Handle, FALSE); llSetScriptState(llGetScriptName(),FALSE);    } else if (action == "help"){llSay(0, "Type into public chat the command \n (\"CIRCLE\" or \"circle\" or \"c\") or (\"HELIXUP\" or \"helixup\" or \"hup\") or (\"HELIXDOWN\" or \"helixdown\" or \"hdown\") \n followed by RADIUS, \n then camera HEIGHT and \n camera FOCUS \n otherwise they will be zero. ");llSay(0, "CIRCLE: try these values (face = \"c 1 1.3 1\", ass&crotch = \"c -0.7 0 0\") ");}                else if (action == "reset"){    llSay (0, "Resetting script."); llResetScript();}else if (action == "CIRCLE" || action == "circle" || action == "c") //plus dis, zthere &zhere{llOwnerSay("Circle");llClearCameraParams();vector here = llGetPos() + <0.0, 0.0, zhere >;vector there = llGetPos() + <0.0, 0.0, zthere >;float i; for (i = 0; i < revs*TWO_PI; i+=inc){vector xyz = <dis*llCos(i),dis* llSin(i), 0.0>;vector there =here + xyz+ <0.0, 0.0, zthere >;llSetCameraParams([CAMERA_ACTIVE, 1, CAMERA_FOCUS, here, CAMERA_POSITION, there, CAMERA_POSITION_LOCKED, TRUE]);}llSleep(0.002);}}changed(integer change){if (change & CHANGED_LINK){key agent = llAvatarOnSitTarget();if (agent){setup_listen();llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);}}}   attach(key agent){if (agent != NULL_KEY){setup_listen();llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA);}}   timer(){if (trap == 1){//center();}   }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3610 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...