Jump to content

Camera problem


Phil Deakins
 Share

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

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

Recommended Posts

I'm writing a camera script, for my own use, but I'm having a problem.

Basically, it's a HUD object that puts up menus in which I can choose which view I want to see. There are no objects involved, other than the one on my HUD.

I first did it in such a way that each view was set up by me going to each cam position that I wanted, and also to a place where I wanted the cam to focus. I got my own position at both places - not the cam's positions - which isn't exactly accurate for where I want the cam.

That was a long-winded way of setting up a view, so I'm changing it. I can move my cam to the view I want, and I can save the cam's position and rotation. I can also give the view a name, and add it all to the list of views. I can also select a view from the list (via menus) and I can move the camera to the correct position. What I haven't found a way of doing is setting the camera's rotation. There is no llSetCameraRot(). The camera moves ok, but it remains focussed on the spot it was focussed on before the move.

I've examined the camera function pages in LL's LSL wiki and also in LSL Wiki, but I can't see any way to set the camera's rotation. In fact, the only use of the camera rotation is in LL's wiki example for llGetCameraRot(), and it doesn't appear to help me.

I just want to get the camera position and rotation, after using my cam controls to find a suitable view, and later view that same position and rotation on the click of a button. If anyone can tell me how to set the rotation, I'd very much appreciate it.

I could use the focus parameter by moving the cam to what I want it to look at, and collect its position there, but that does seem a bit long-winded when I only need to set the rotation that I've already got. It's also not nearly as good as being able to set the camera in the position I want and the angle it views, both at the same time.

Link to comment
Share on other sites

How?

ETA: I was modifying my OP when you posted yours,Qie. At the end, I did mention that I could use the focus parameter by moving the cam and getting another position for the focus. If I can do it without that extra move, it would much better.

It may be that that's the only way, and I'll have to do it that way. It just seems odd that I can't simply set the rotation.

Link to comment
Share on other sites

There is an easy way to get a look-at from the camera rotation, see this example
It is all in this line:

llSetLinkCamera( LINK_THIS, cam_pos, cam_pos + llRot2Fwd(cam_rot));

 The last parameter is the look-at parameter computed from the cam-position and cam-rotation

The above example is referenced in the wiki here

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

lol. I've just spent time changing to the 2 separate position approach - 1 for the position and the other for the focus. But time is something that I have in abundance so I'm happy to scrap the time used if your suggestion works, Qie. Not tonight though (it's after 9 p.m. here), but tomorrow.

And thank you for it :) I'll post here tomorrow to let you know how it worked out.

The silly thing in all of this is that I no longer have an editable copy of my original script because I made the changes to it when I was changing to the new method. The only working copy of the original is owned by my alt, and I passed it without changing the perms, so she can't edit it, and passing it back won't allow me to edit it either. It doesn't matter though, I want it to work the new way so I'll make it do it. It works now using 2 positions, but I just don't like doing that when I can get the position and rotation in 1 step.

Link to comment
Share on other sites


Qie Niangao wrote:

Right, but this is a HUD script, so it's not the prim params that are being changed, it's the cam of the wearer, i.e., the one who granted permission. (Your llRot2Fwd is less ugly than my unit-vector rotation, though.)

But the 2-position method is uglier than either of them :D

Link to comment
Share on other sites


Phil Deakins wrote:

Yes, I saw that when I was studying the LL pages, Dora, but, as Qie said, there are no prims involved except the one on the HUD. I appreciate you posting it though.

The line I quoted is out of context, but the parameters are exactly the same you would use in llSetCameraParams()

Link to comment
Share on other sites

I don't get it, Dora. This is the line you suggested:-

 

llSetLinkCamera( LINK_THIS, cam_pos, cam_pos + llRot2Fwd(cam_rot));

 cam_pos and cam_pos + llRot2Fwd(cam_rot) are the parameters.

Using llSetCameraParams() it's easy to see that cam_pos is used with the CAMERA_POSITION parameter, but what parameter can use cam_pos + llRot2Fwd(cam_rot) ?

Would it be CAMERA_FOCUS? I just re-read your post and you refer to is a "look at". That suggests the focus.

Link to comment
Share on other sites

Right, that would be the CAMERA_FOCUS parameter.

What's going on here is that the camera "sees" in the direction of its X axis, so you want to focus 1m from the cameera in that "forward" direction. You get that using either Dora's llRot2Fwd() or my rotation of the X unit vector; they should be equivalent.

Link to comment
Share on other sites

Brilliant! Thank you both!

I used Dora's suggestion because, as you said, Qie, it's more elegant :)

I've never come across llRot2Fwd() before but then I studiously avoid rotations whenever possible, because my brain gets to feel flummoxed with them. If you don't know what flummoxed means, it means what it sounds like :) It's quaternions that do it. I've never grasped them and, since I usually have no need to grasp them, I don't try.

Thank you both for your help. It works perfectly now, and it's so much easier than having to take a second forward location for the focus.

Link to comment
Share on other sites

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