Jump to content

Setting Camera


EnCore Mayne
 Share

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

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

Recommended Posts

i'd like to know if there is any way to change the camera position and focus once it's been established. i've got a sit pose that uses llSetCameraEyeOffset, and llSetCameraAtOffset setting the camera on sit. all good. problem is i'd like to have 2 other viewpoints in the same script, or another. is there any way to reset those functions to another position/focus without reseating?

Link to comment
Share on other sites

25 minutes ago, Quistessa said:

It's slightly more complicated, but if you request camera permissions from the seated avatar (which IIRC are automatically granted without annoying the sitter.) you can use LlSetCameraParams() to change the camera position.

just finished "trying" all that. hours later, here i am. i eventually got close but when i had to raise the Z height or Y distance (world axes) it shot below me a couple of hundred meters.

i've made it work fine and have products on the Marketplace with it. if the camera is following a moving avatar, all good. one that is sitting (with camera set) is a whole new bag a poo. excuse my profanity....

if anyone's made llsetcameraparams work under my use case condition i'd sure like to know how.

Link to comment
Share on other sites

EnCore, might be that you're not locking the camera when you change its position. When we don't lock then the camera will apply the change and then go back to the original settings

example of switching between sitting camera views

( a caveat with camera positions is that agent can move their camera independently and when so then the scripted camera doesn't apply to them until they press ESC )
 

integer toggle;

default
{
    state_entry()
    {
        llSitTarget(<0.5,0.0,0.5>, ZERO_ROTATION);    
    }


    touch_start(integer total_number)
    {
        key k = llAvatarOnSitTarget();
        if (k == llDetectedKey(0))
            llRequestPermissions(k, PERMISSION_CONTROL_CAMERA);
    }
    
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            toggle = 0;
            key k = llAvatarOnSitTarget();
            if (k)
               llRequestPermissions(k, PERMISSION_CONTROL_CAMERA);
        } 
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA)
        {
            llClearCameraParams();
            if (toggle = !toggle)
            {   // behind
                    llSetCameraParams([
                    CAMERA_ACTIVE, 1,
                    CAMERA_FOCUS, llGetPos(),
                    CAMERA_POSITION, llGetPos() + <5.0, 0.0, 1.0>,
                    CAMERA_POSITION_LOCKED, TRUE 
                ]);
            }
            else
            {    // infront
                llSetCameraParams([
                    CAMERA_ACTIVE, 1, 
                    CAMERA_FOCUS, llGetPos(),
                    CAMERA_POSITION, llGetPos() + <-5.0, 0.0, 1.0>,
                    CAMERA_POSITION_LOCKED, TRUE 
                ]);                
            }
        }       
    }
}

 

Link to comment
Share on other sites

5 hours ago, Mollymews said:

EnCore, might be that you're not locking the camera when you change its position. When we don't lock then the camera will apply the change and then go back to the original settings

example of switching between sitting camera views

( a caveat with camera positions is that agent can move their camera independently and when so then the scripted camera doesn't apply to them until they press ESC )
 



            {   // behind
                    llSetCameraParams([
                    CAMERA_ACTIVE, 1,
                    CAMERA_FOCUS, llGetPos(),
                    CAMERA_POSITION, llGetPos() + <5.0, 0.0, 1.0>,
                    CAMERA_POSITION_LOCKED, TRUE 
                ]);

 

well, that worked a treat Molly. i hadn't put in the llGetPos() + onto the coordinates i was trying, and yes, i had the LOCKED to FALSE. not sure if NOT having a llSitTarget in the HUD that sets the camera had any affect (the initial sit position is from the seat script) but i threw that in too. on tweaking those coordinates, it doesn't seem to have any affect on, off, or altered.

another question that might help my ignorance/avoidance of learning the fundamentals.  instead of my trial and error process, what does the llGetPos() actually refer to? the position of the script affecting the camera positioning?

since that script is in a HUD, i've fiddled with the HUD's X coordinates (inout) but doing that doesn't change the camera's placement inworld.

Edited by EnCore Mayne
Link to comment
Share on other sites

3 hours ago, EnCore Mayne said:

another question that might help my ignorance/avoidance of learning the fundamentals.  instead of my trial and error process, what does the llGetPos() actually refer to? the position of the script affecting the camera positioning?

since that script is in a HUD, i've fiddled with the HUD's X coordinates (inout) but doing that doesn't change the camera's placement inworld.

yes llGetPos is the position of the script

when the camera is in a HUD worn by the agent, and the agent is sitting then we times the offset by the rotation of the agent then add it to llGetPos

example:

integer toggle;

default
{
    touch_start(integer total_number)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_CONTROL_CAMERA);
    }
    

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA)
        {
            llClearCameraParams();
            if (toggle = !toggle)
            {   // behind
                llSetCameraParams([
                    CAMERA_ACTIVE, 1,
                    CAMERA_FOCUS, llGetPos(),
                    CAMERA_POSITION, llGetPos() + (<-3.0, 0.0, 0.5> * llGetRot()),
                    CAMERA_POSITION_LOCKED, TRUE
                ]);
            }
            else
            {    // infront
                llSetCameraParams([
                    CAMERA_ACTIVE, 1,
                    CAMERA_FOCUS, llGetPos(),
                    CAMERA_POSITION, llGetPos() + (<3.0, 0.0, 0.5> * llGetRot()),
                    CAMERA_POSITION_LOCKED, TRUE
                ]);                
            }
        }       
    }
}

 

just have to remember that when the agent stands then we should unlock the camera, as the camera script being attached to the avatar is still active, unlike when the script is in the chair
      

 

 

Link to comment
Share on other sites

Hey all, kind of on the same topic but a bit different problem I'm hoping someone can help with.  I hate that look down on yourself view that the default camera is set on in FS.  I've reset it and made a preset view.  Problem is, if I have to cam in on something or look down to position something on my land properly, the camera setting goes back to the default and I have to reset it on my preset.  In other words it won't hold the settings I've put in.  Is there some way to fix this? 

Link to comment
Share on other sites

10 minutes ago, Quistessa said:

If you save your view as a preset, you /should/ go back to that view every time you hit escape or move around. If that's not happening yell at the firestorm people to fix their viewer.

that's the problem.  It won't hold it, unless I'm doing something wrong when I save it.  I have a preset that I made and when I zoom in or out, when I click on the rear view on my camera controls, it goes back to the default rear view

 

Link to comment
Share on other sites

18 hours ago, Mollymews said:

yes llGetPos is the position of the script

when the camera is in a HUD worn by the agent, and the agent is sitting then we times the offset by the rotation of the agent then add it to llGetPos

...

just have to remember that when the agent stands then we should unlock the camera, as the camera script being attached to the avatar is still active, unlike when the script is in the chair   

okay, so llGetPos() refers to the avatar's position since the script is attached to them?

now here's the kicker. i puttered about getting the camera views as accurate down to nano particle precision. then, when i relocated the chair to a different place and orientation everything's gone wonky. is there some script voodoo that allows the code for one place to work everywhere?

Link to comment
Share on other sites

12 hours ago, RowanRiverSong said:

that's the problem.  It won't hold it, unless I'm doing something wrong when I save it.  I have a preset that I made and when I zoom in or out, when I click on the rear view on my camera controls, it goes back to the default rear view

When you save your preset, check 'Replace a preset' and replace the one that says 'Rear View'. or when you name the preset be careful to name it Rear View, both words spelled correctly an both capitalized.

Link to comment
Share on other sites

5 hours ago, EnCore Mayne said:

now here's the kicker. i puttered about getting the camera views as accurate down to nano particle precision. then, when i relocated the chair to a different place and orientation everything's gone wonky. is there some script voodoo that allows the code for one place to work everywhere?

As far as I can tell Molly's code should do that, unless the code needs rotation division instead of multiplication:

CAMERA_POSITION, llGetPos() + (<-3.0, 0.0, 0.5> / llGetRot()),

I can never remember when you need one or the other, rotations are confusing.

Link to comment
Share on other sites

18 hours ago, EnCore Mayne said:

now here's the kicker. i puttered about getting the camera views as accurate down to nano particle precision. then, when i relocated the chair to a different place and orientation everything's gone wonky. is there some script voodoo that allows the code for one place to work everywhere?

is difficult to work out what is causing your issue, without seeing some code

llGetPos and llGetRot will always get the global pos and rot of the script

pos + (offset * rot) or pos + (offset / rot) should always result in the camera being relative to the script's rotation/orientation

 

Edited by Mollymews
Link to comment
Share on other sites

well...near as i can figure from my extreme lack of spacial orientations my mind conceived of all sorts of evil coding anomolies in the setup i have at present. so to simplify the problem i coded a standalone HUD (no attachment scripting [the one i'm building has some wonky workaround Perm situations]), sat the avatar on a plain jane no camera settings stand (no AVSit scripts), oriented the stand to world axes orientation and it still doesn't make any mathematical sense.

i've only got CAMERA_POSITION, and CAMERA_FOCUS set by the HUD. <0.0, 0.5, 1.1> and <0.0, 0.0, 1.1> respectively. my tiny brain assumes that those coordinates would put the camera half a meter away from my right shoulder ( positive Y local and world axes) and pointing to the right side of my face. of course, with that being said, it's nothing like that in practice. i have no idea why the camera goes where it goes and why it's pointing where it is. the numbers just don't make any sense. i set the stand to a round numbers location, and as far as i'd like to believe, the camera should be offset from there by the coordinate amounts i plugged in.

as i'm gradually losing my mind plugging in coordinates i'm assuming are relevant to my desired outcome there's really no way to sufficiently describe what's happening. at this point in taming the beast (i'm committed to making this work AND make sense) i'm building a setup so i can SHOW what's going on.  from the ignorant to the wise kinda illustration. should be fun for everyone.

Link to comment
Share on other sites

as far as i've observed over the span of time i've played with Second Life, we're all very lucky that anything works.

cameraoffset.thumb.jpg.7c8f753617c1e7f8c25a8e230c05d6b9.jpg

with that being said, i coded up this little setup where my HUD changed the coordinate values of llSetCameraParams([CAMERA_POSITION]) to what appears above the white sorta cone thingies. can anyone tell me just why it is that the apparent calculated camera center is off by 0.951 on the X axis and 0.369 on the Y? there was no OFFSET input. CAMERA_FOCUS was constant at <0,0,1.1>. which reminds me, i never calculated the Z offset in the picture since i don't know where its origin is. 1.1 from the inworld positions would make it 163.197. the avatar center? i forgot to measure the height above the stand her center was.

nonetheless, i'll keep plugging in some numbers to get a consistent placement. and then, i swear, it'll be completely backwards for no apparent reason whatsoever. don't ask me how i know.

Link to comment
Share on other sites

2 hours ago, EnCore Mayne said:

it's not possible? someone tell me it aint so

it ain't so :)

 

if we want the camera to look at us (the agent) then we/agent are the focus of the camera

when the camera script is in a HUD then

our agent position llGetPos()) is what we want the camera to focus on (to look at): CAMERA_FOCUS, llGetPos()

then we want to position the camera; some vector <distance> from the 'focus' of the camera. CAMERA_POSITION, focus + <distance>

and because it is a HUD then we want to position the camera relative to our agent rotation ( rot = llGetRot )  CAMERA_POSITION, focus + <distance> * <rot>

a example quick HUD showing a way to do this

// example HUD pose camera
// stick in a prim and attach to your HUD
// Touch to start

list cameras = [
   "Clear", 
   "Front",         "Back",           "Left",          "Right", 
   <3.2, 0.0, 1.1>, <-3.2, 0.0, 1.1>, <0.0, 3.2, 1.1>, <0.0, -3.2, 1.1>
   // X = 3.2 metres in front of agent
   // X = -3.2 metres behind agent
   // Y = 3.2 metres to left of agent
   // Y = -3.2 meters to right of right
   // Z = 1.1 meter up from agent center
   // change to suit as you like 

];

integer index;

default
{
    state_entry()
    {
        llListen(-61616, "", llGetOwner(), "");    
    }

    touch_start(integer total_number)
    {
        llDialog(llGetOwner(), "Cameras:", llList2List(cameras, 0, 4), -61616);
    }
    
    listen(integer channel, string name, key id, string text)
    {
        index = llListFindList(cameras, [text]);
        if (~index) 
            llRequestPermissions(id, PERMISSION_CONTROL_CAMERA);
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_CONTROL_CAMERA)
        {
            llClearCameraParams();
            if (index > 0)
            { 
                vector focus = llGetPos();
                vector offset = llList2Vector(cameras, 4 + index);                             
                llSetCameraParams([
                    CAMERA_ACTIVE, 1, 
                    CAMERA_FOCUS, focus,
                    CAMERA_POSITION, focus + offset * llGetRot(),
                    CAMERA_POSITION_LOCKED, TRUE
                ]);                 
            }
           // llOwnerSay(llList2String(cameras, index));
            llDialog(llGetOwner(), "Cameras:", llList2List(cameras, 0, 4), -61616);         
        }       
    }
}

 

 

Link to comment
Share on other sites

here's something unusual not found in any documentation:

in my llSetCameraParams() for my HUD i've got ALL the listed rules coded. as in, whether i thought they were in use (like CAMERA_BEHINDNESS_ANGLE or CAMERA_BEHINDNESS_LAG) they were there if i needed to tweak them. i zeroed all those non used ones and went on with my day. UNTIL i decided to comment out all the ones not being used.

whoa! that changed everything. i don't know why, but the precise and repeatable views i've been sweating blood over to get were no more. removing the commenting slashes allowing those seemingly unused rules to be read put things right again.

sheesh. i tell ya, what a game, what a game.

Link to comment
Share on other sites

5 hours ago, EnCore Mayne said:

in my llSetCameraParams() for my HUD i've got ALL the listed rules coded. as in, whether i thought they were in use (like CAMERA_BEHINDNESS_ANGLE or CAMERA_BEHINDNESS_LAG) they were there if i needed to tweak them. i zeroed all those non used ones and went on with my day. UNTIL i decided to comment out all the ones not being used.

you are on to it. Use only the params needed for the particular use case

when we want a multi-purpose camera HUD then suggest that on the dialog add a Mode button, which switches between Follow camera mode and Fixed camera mode. Compartmentalising like this can help us to visualise what we need to code for each of the use cases (modes)

Link to comment
Share on other sites

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