Jump to content

Using llTakeControls(...,TRUE,FALSE) and avoiding camera auto-movement


Stickman Ingmann
 Share

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

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

Recommended Posts

I've written up a quick script that lets me "scroll" through a linkset with the movement controls. Forward/back changes the prim number up and down, left/right changes the current face.

Basic functionality is great, with one problem: The camera reverts back to "over the shoulder" every time I press a control button.

I've looked around and cannot find a simple solution to this problem. Everything involves special camera controls and equipment. I would like to be able to use this tool without attaching or sitting on a special object, simply by accepting control permission.

My question is: In this situation, what is the easiest way to prevent the alt-camera from reverting position? Be it simple or not simple.

A simplified version of the script I'm using is below:

 

integer giPrimCurrent;
integer giFaceCurrent;

selectFace(integer iPrim, integer iFace) {
    llSetLinkColor(iPrim,<1.0,0.2,0.2>,iFace);
}

unselectFace(integer iPrim, integer iFace) {
    llSetLinkColor(iPrim,<1.0,1.0,1.0>,iFace);
}

default {
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
    }

    control(key id, integer held, integer change) {
        integer iPrimCount = llGetNumberOfPrims();
        integer iFaceCount = llGetLinkNumberOfSides(giPrimCurrent);
        integer iStart = held & change;
        if (iStart) {
            unselectFace(giPrimCurrent, giFaceCurrent);
        }
        if (iStart & CONTROL_FWD) {
            giPrimCurrent++;
            if (iPrimCount == 1) {
                giPrimCurrent = 0;
            }
            else if (giPrimCurrent > iPrimCount) {
                giPrimCurrent = 1;
            }
            giFaceCurrent = ALL_SIDES;
        }
        if (iStart & CONTROL_BACK) {
            giPrimCurrent--;
            if (iPrimCount == 1) {
                giPrimCurrent = 0;
            }
            else if (giPrimCurrent < 1) {
                giPrimCurrent = iPrimCount;
            }
            giFaceCurrent = ALL_SIDES;
        }
        if (iStart & CONTROL_ROT_LEFT) {
            if (giFaceCurrent == ALL_SIDES) {
                giFaceCurrent = iFaceCount-1;
            }
            else {
                giFaceCurrent--;
                if (giFaceCurrent < 0) {
                    giFaceCurrent = ALL_SIDES;
                }
            }
        }
        if (iStart & CONTROL_ROT_RIGHT) {
            if (giFaceCurrent == ALL_SIDES) {
                giFaceCurrent = 0;
            }
            else {
                giFaceCurrent++;
                if (giFaceCurrent >= iFaceCount) {
                    giFaceCurrent = ALL_SIDES;
                }
            }
        }

        if (iStart) {
            selectFace(giPrimCurrent, giFaceCurrent);
            llOwnerSay("Prim "+(string)giPrimCurrent+" and Side "+(string)giFaceCurrent+" selected.");
        }
    }

    run_time_permissions(integer p) {
        if (p & PERMISSION_TAKE_CONTROLS) {
            llTakeControls( CONTROL_FWD |
                            CONTROL_BACK |
                            CONTROL_ROT_LEFT |
                            CONTROL_ROT_RIGHT |
                            CONTROL_UP |
                            CONTROL_DOWN,
                            TRUE, FALSE);
        }
    }
}

 Thank you for any help you can offer.

Link to comment
Share on other sites

Right, but the OP says he doesn't want to have to sit on or attach anything, just take controls, and cam permissions are only granted to attachments and sat-upon objects.

I know no way around the problem. The cam position and control keys behave as if deeply linked in the viewer, requiring extraordinary measures (scripted cam control) to de-link them. To be honest, I've never been completely satisfied with the result even when I do take both camera and controls permissions: it works great right up until I release the cam at which point it moves to some position only vaguely similar to where it was when I took it.

[Edit: Forgot to mention that taking key controls is a fairly intrusive thing to do--seems to me at least as intrusive as taking the cam--so I'm not sure why cam permission is limited to attached and sat-upon objects and key control permission isn't. In any case, be sure to have an obvious way for the user to use the script to release key control; the viewer override is fairly well hidden these days and has nasty side-effects such as detaching everything that has taken controls.]

  • Like 1
Link to comment
Share on other sites

The way to do it without extra scripts and prims inworld is using 'Joystick flycam'
Joystick flycam takes full control of the camera and the camera is not released until you press Esc
Joystick flycam works entirely in the viewer
People who has a "Space navigator"(like me) use it all the time

joystick menu.png

:smileysurprised::):smileyvery-happy:

  • Like 1
Link to comment
Share on other sites

Thank you for the information, everyone!

Regarding some worries, this is not an item intended to be publicly released, but is a creation tool used for configuring values another script uses. As such, the intended audience is very limited, competent builders, and in direct contact with me. I'm more concerned with convenience and workflow. Sitting and attaching breaks intended workflow and can complicate things

Dora's solution sounds like the best option for the situation. It doesn't involve writing extra scripts that need to be managed and maintained and tied into this one.

If anyone has additional ideas or suggestions, feel free to provide, but I believe I have my answer. Thank you!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3998 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...