Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

1 meter in front of camera view?

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 10:28
I'm trying to figure out how to put a prim 1 meter in front of the camera view, no matter what the camera rotation is at the time.

I was trying this, but no luck.

llGetCameraPos() + llVecNorm(llRot2Fwd( llGetCameraRot() )) * 1;

I can easily move/rez a prim at the camera location using just llGetCameraPos(), but I also have to take into account the angle of the camera too. I'm just not sure how to translate all that to get a vector coordinate to place the prim.

Appreciate it if anyone has any insight.
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
12-10-2006 10:37
Try this instead:

llGetCameraPos() + (llVecNorm(llRot2Fwd( llGetCameraRot() )) * 3);
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 10:59
hmm, no just making the prim off to 1 side or the other. not consistent.

how would I translate the rotation quaternions from llGetCamRot() into vector coordnates that can be used to place a prim?
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
12-10-2006 11:13
This is way I do it:

llGetCameraPos()+(<1,0,0>*llGetCameraRot())

I've just tested this with llRezObject() and it worked perfectly. I also tried your method and it worked fine. So I'm not sure what you're doing wrong. Are you rezzing an object made from several prims?

ps. don't forget to set the prims rotation too. Feed it with the Camera's rotation.
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 11:45
its a single prim. Im trying your example and it kinda works.

if I just zoom out from my avatar, w/ the mousewheel, then the prim rezzes right in front of me. However, if I rotate my camera so its not facing the avatar, the prim isn't appearing in front of the camera view.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-10-2006 11:50
Where are you rezzing the object from? There's a 10.0 meter limit, for reference.
_____________________
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
12-10-2006 11:52
Try this:

CODE

touch_start(integer total_number)
{
llRezObject("test",llGetCameraPos()+(<2,0,0>*llGetCameraRot()),<0,0,0>,llGetCameraRot(),1);
}
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-10-2006 11:54
From: 2k Suisei

llGetCameraPos()+(<1,0,0>*llGetCameraRot())

I can guarantee this works if location where the object will rez is within 10.0 meters of the rezzer.
_____________________
Mr Blackthorne
Registered User
Join date: 26 Oct 2006
Posts: 13
I'm looking for the same thing
12-10-2006 11:56
I was just wondering the same thing. I am also trying to get a prim to stay just in front of the camera.

Ive created a camera follower, from the script in the wiki library. By default, the scripted prim stays a bit above the camera position, so you cant see it. This works fine. I've changed the script so the prim is right on the camera position. This works too. But I cant get my prim to stay in front of the camera. There are options have the prim a certain distance X or Y from the camera position, but these are absolute sim x/y. So the prim is always north or east of the camera.

Isnt there some way to know where the camera is looking at. So you can take the position of the camera, the position of where it's looking, then place the prim in between?

Is this the approach your trying for, with the camera rotation question?
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
12-10-2006 11:57
From: Tyken Hightower
I can guarantee this works if location where the object will rez is within 10.0 meters of the rezzer.


Well I'm assuming he knows about that. But maybe I shouldn't :)
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 12:07
Yeah, Ive tried all the variations of this. Nothing seeming to work. The prim keeps appearing off to the side. Its like its not taking the rotation of the cam into account.
Mr Blackthorne
Registered User
Join date: 26 Oct 2006
Posts: 13
Spoke too soon
12-10-2006 12:07
Well, I spoke too soon.

Changing line 20 of the Camera Follower script from the wiki library to your suggestion
llGetCameraPos()+(<1,0,0>*llGetCameraRot())
Works just fine. Now I have a little sphere that hovers just in front of the camera, no matter where I put it.

Thanks for the help. I hope the original poster gets his issue settled too
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-10-2006 12:07
From: Mr Blackthorne
I was just wondering the same thing. I am also trying to get a prim to stay just in front of the camera.

Ive created a camera follower, from the script in the wiki library. By default, the scripted prim stays a bit above the camera position, so you cant see it. This works fine. I've changed the script so the prim is right on the camera position. This works too. But I cant get my prim to stay in front of the camera. There are options have the prim a certain distance X or Y from the camera position, but these are absolute sim x/y. So the prim is always north or east of the camera.

Isnt there some way to know where the camera is looking at. So you can take the position of the camera, the position of where it's looking, then place the prim in between?

Is this the approach your trying for, with the camera rotation question?

A location an arbitrary distance in front of the camera is llGetCameraPos() + <arbitrary_distance, 0, 0> * llGetCameraRot().
_____________________
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 12:08
its beyond 10 meters in some cases, but that shouldn't be a problem. The prim is appearing at the coordinates of the cam. Just not in front of it.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-10-2006 12:08
From: Geuis Dassin
Yeah, Ive tried all the variations of this. Nothing seeming to work. The prim keeps appearing off to the side. Its like its not taking the rotation of the cam into account.

Did you request permission to track the camera? Otherwise, not sure right now.
_____________________
Mr Blackthorne
Registered User
Join date: 26 Oct 2006
Posts: 13
12-10-2006 12:11
Geuis, are you in-world right now?

Its working for me. I can drop a copy for you, if you want. Ive just modifed the wiki's cam follower script, so the permissions and everything are already written.
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 12:16
From: Tyken Hightower
Did you request permission to track the camera? Otherwise, not sure right now.


yeah, thats all taken care of. only problem is figuring out the right way to:

camera position + camera rotation = region coordinates for prim
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
12-10-2006 13:05
The wiki cam follower doesn't do the trick. It doesn't take into account where the camera is pointing. The prim in that example floats 1 meter above the cam position, not in front of where the cam is pointing.
Mr Blackthorne
Registered User
Join date: 26 Oct 2006
Posts: 13
12-10-2006 13:09
It stays in front of the cam if you modify line 20 to use
llGetCameraPos()+(<1,0,0>*llGetCameraRot())

Now I'm trying to figure out how to get my prim to rotate with the cam. So, if were a tube, you'd always be looking down it, like a telescope.
Elsewhere Essex
Registered User
Join date: 8 Sep 2006
Posts: 50
12-10-2006 13:46
From: Mr Blackthorne
It stays in front of the cam if you modify line 20 to use
llGetCameraPos()+(<1,0,0>*llGetCameraRot())

Now I'm trying to figure out how to get my prim to rotate with the cam. So, if were a tube, you'd always be looking down it, like a telescope.



try
CODE

state_entry() {
llSetTimerEvent(0.05);
}
timer() {
llSetPos(llGetCameraPos() + <1,0,0>);
llSetRot(llGetCameraRot());
}


or
CODE

state_entry() {
llSetTimerEvent(0.05);
}
timer() {
llSetPrimitiveParams([PRIM_POSITION,(llGetCameraPos() + <1,0,0>),PRIM_ROTATION, llGetCameraRot()]);
}


using that in a pointer/chat relay tool i sell
the later of the do would work more smoothly in fact, only one script sleep penalty raher than 2. and i've noticed that llSetPrimitiveParams() executes all the changes in one step rather than 2 seperate changes.
Mr Blackthorne
Registered User
Join date: 26 Oct 2006
Posts: 13
12-10-2006 15:24
Thanks, Elsewhere. It's working great. It's floating .5 meter in front of the camera, at all times, and pointing at the camera target (matching the camera rotation)

I ended up using llRotLookAt, because the CameraFollower script from the wiki makes the prim physical and uses llMoveToTarget.

Of course, this means my camera follower is bumping into things. I'll try to use the llSetPrimParams and set my object to non-phys, phantom.

Now I'm having problems with it following my camera when I alt-zoom across Sim borders, but that's not a big deal to me right now. I've also noticed that it doesnt telport with me, so I've already left it behind, only to autoreturn to me later.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-16-2006 18:47
From: Tyken Hightower
A location an arbitrary distance in front of the camera is llGetCameraPos() + <arbitrary_distance, 0, 0> * llGetCameraRot().


Would that mean that, in general, for an object X,

X.position + <a,b,c>*X.rotation

will be a point offset by a, b, and c in the direction X is facing? Or does it only work for <a,0,0> which is straight ahead?
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-16-2006 21:40
From: Lee Ponzu
Would that mean that, in general, for an object X,

X.position + <a,b,c>*X.rotation

will be a point offset by a, b, and c in the direction X is facing?

I do believe so.
_____________________
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
12-17-2006 09:55
From: Tyken Hightower
I do believe so.


I verified this by experiment.