Request: ChaseCamera rotation

Mostly @nehon I guess. :wink:



Would it be possible to have a setRotation(Quaternion q) or similar? I’m asking because when I switch from one view to the other I’d like to bring things the way they were when switching back to a previous view. Up to now all is fine except for the chase camera who’s always looking in the same direction independently of how I have set up spatials or the camera from which it’s built from.



It would be much appreciated.



Also, having this kind of method would be nice if, for example, someone wanted to do some kind of “animation” to show something to the player. Like, rotating the chase cam to “lookAt” something behind the spatial the chase cam is attached to.



This is giving me an idea. Let’s say I could give the option to the player to “lock” the cam on the enemy ship. So by using a rotation method I could simply use update to do that and the chase cam would follow on whatever it is locked on. I guess I could force that by faking mouse movement (triggering OnAction/OnAnalog), but meh.

Hello!



I think the tools to do this are already implemented into ChaseCamera. The Methods you’d need to concern yourself with are the horizontal and vertical rotations, and possibly the distance from the object… I think. Maybe the camera position too. You can set the horizontal and vertical rotations as well, and of course the distance from the object being chased by the camera. Using all 3 of these together should allow you plenty of control over it. In other words, you can lock onto an object and spin the camera all through code if you’d like; no biggy.



It’s been a while, but I know that I used the horizontal rotation to keep the camera at 90 degree intervals of the player in something I’ve written, and it worked quite well. Limiting the horizontal and vertical rotations can also be useful if you’re trying to keep the camera from getting into certain situations.



EDIT: And actually, if you absolutely need to do this with quaternions and such: Remember that ChaseCamera has the Camera object and is just manipulating it. You could grab the camera in your application and get where it’s looking, it’s position, etc etc.



Cheers!

~FlaH

1 Like

Well thanks @theflah that pretty much it.



You can use setDefaultHorizontalRotation and setDefaultVerticalRotation. and you can get actual rotations by using getVerticalRotation and getHorizontalRotation

those methods use and return angles in radians.

Thanks for the reply @tehflah



I was aware of those methods and I was intending to use them, but I was only requesting to have that kind of control over the ChaseCamera built-in. I think I’m not the only one who would use it.



Still worth a +1 imo though. :smiley:

mhh I don’t get it

you prefer to use quaternions than angles? that’s it?

Basically, and in the best of worlds, I’d like to do something like:



[java]

Quaternion oldRotation = oldChaseCam.getRotation();

[… then use that field elsewhere in the program where the chase cam is made …]

newChaseCam.setRotation(oldRotation);

[/java]



Here I’m using getRotation() and setRotation() but it could be anything of course. Just a name like that.



And as @tehflah and you said, I can use the methods already in the class to get the distance, horizontal and vertical “rotation” and set the new chase cam with those. I just think it would be easier to have one that does that.

yeah…but the rotations used in the chase cam are not really the rotations of the cam.

Those are the rotation of the cam in the targeted spatial space.



Why not make your own class? some kind of ChaseCamState with a saveState(chaseCam) and a restoreState(chaseCam).

you’ll just have to save the vertical and horizontal rotation and maybe the distance etc…

Yeah. Bad choice of words. My mistake.



I was juggling the idea of using a “state” class to keep track of things actually. Something I could also use to fix my viewport problem at the same time. But unsure if that would be the right place to do that.



Anyway. Like I said, it’s not a necessity. I’ll manage very well without it. :slight_smile:

I’d like to know other users opinion about it, I see how this feature would be useful to you, but I don’t think it’s the general case.

Maybe I’m wrong though, I’d like to know other users opinion



So fellow monkeys, speak your mind out loud!!!

setDefaultHorizontalRotation and setDefaultVerticalRotation can be used to actually apply the rotation in that frame? not just set them for when application starts or resets?

does setDefaultDistance also work this way?

also, is there a way to set the zoom amount with code as well? …all i found in the javadoc was a setting for the triggers or the sensitivity (or is 3rd person zoom the same as the distance from target spatial?).



as for your last question, (if i understand correctly) i think having a ‘focus’ object to allow chasecamera to lock onto while still pivoting around its target spatial is a welcome feature, if not too much hassle.

@Decoy

Using setDefaulDistance will put the view at said distance from where the chase cam is attached to. If you want to use it as a “zoom” I guess you could although I have never tried it to do that. When I used it it was just to set it at the “start”. My guess is it should work.



As for the zoom amount yeah, there’s a method for that. Check the source, it’s included. :wink: Sources is like 10x the Javadoc when javadoc is not entirely written and/or updated. So at this point, browse the source, you’ll find much info in there. Also I know that … huh… whoever it is, tries to keep the wiki up to date, but there’s so much one man can do.