About Store Forum Documentation Contact



Post Reply 
Camera Pos Dir
Author Message
Kiekos Offline
Member

Post: #1
Camera Pos Dir
Hey!

I can't figure out camera handling after going through the tutorials. I want my camera during fighting to be set next to the player looking at a certain spot next to the monster he is battling.

I've experimented with something like this:
Code:
Vec pos = (50,30,50);
Vec dir = (0,0,0);

Cam.setPosDir(pos, dir);

I thought it was gonna set the camera in position x=50, y=30, z=50 and looking at point (0,0,0) on the map.

Apparently it doesn't and I'm having problems setting camera height (y coordinate), it doesn't seem to work.

Could anyone also explain "Vec up" of the Cam.setPosDir() function? I have no idea what it's responsible for as the only thing I figured out is it tilts the camera to the right...

Thanks,
Kiekos
10-23-2013 11:25 AM
Find all posts by this user Quote this message in a reply
Pherael Offline
Member

Post: #2
RE: Camera Pos Dir
Dir is not position that camere looking at, but direction of camera rotations.

You can use something like this:
Vec pos = (50,30,50);
Vec target = (0,0,0);

Vec dir = pos-target; // or target-pos pfft can't remeber, too lazy to check
dir.normalize();
Cam.setPosDir(pos, dir);

Also there is Cam.setFromAt() function, that should do that what you want.
(This post was last modified: 10-23-2013 11:36 AM by Pherael.)
10-23-2013 11:36 AM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #3
RE: Camera Pos Dir
target-pos
10-23-2013 12:47 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #4
RE: Camera Pos Dir
Thanks for the quick feedback! It seems like Cam.setFromAt() should do the trick but it doesn't work because why would it work at the very first attempt? It never does... -.-

Code:
Vec pos    = (0,30,0 );
Vec target = (20,0,20);

Cam.setFromAt(pos, target);
Cam.updateVelocities().set();

So... As far as I know... It should set the camera to position (0,0) at height = 30 and make it look at point (20,20) at height = 0, right?

Well, the only thing that works is the position of the camera (0,0). Its height always equals zero (I cannot modify it, idk why) and it's not looking at the point I want it to.

Damn it...
10-23-2013 02:16 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Camera Pos Dir
Vec pos(0, 30, 0);
or Vec pos=Vec(0, 30, 0);
You're initializing it wrong wink
10-23-2013 09:58 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #6
RE: Camera Pos Dir
Oh well, damn it grin Works fine now!

I knew it was something trivial...
10-23-2013 10:52 PM
Find all posts by this user Quote this message in a reply
Post Reply