Quick camera questions

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jimmyfo
Posts: 12
Joined: Sun Dec 25, 2011 7:27 pm

Quick camera questions

Post by jimmyfo »

Is there a particular reason that the camera controls for the FPS camera are located in the CharacterControllerInput.cs class instead of in the Camera class? The Free and Offset camera input are located in the Camera class, but not for the CharacterController - just wondering if there is a reason such as threading, or if it is safe to move the Camera logic into the Camera class from the CharacterController class.

Also, I notice you calculate your world matrix for the camera (using yaw, pitch, and position), then get the view using "ViewMatrix = Matrix.Invert(WorldMatrix)". If I were to create a ViewMatrix first (for the purposes of a chase camera, using CreateLookAt in XNA), could I get the camera WorldMatrix by using "WorldMatrix = Matrix.Invert(ViewMatrix)"? I've done some research and it seems Matrices are mutually invertable like that. Do you think that would make sense? Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Quick camera questions

Post by Norbo »

Is there a particular reason that the camera controls for the FPS camera are located in the CharacterControllerInput.cs class instead of in the Camera class? The Free and Offset camera input are located in the Camera class, but not for the CharacterController - just wondering if there is a reason such as threading, or if it is safe to move the Camera logic into the Camera class from the CharacterController class.
The reason for the camera control distribution is that the demos have been built up incrementally over multiple years and sometimes things get put in weird places. (If I spent the 10 minutes to redo the demos camera handling, I'd probably pull the camera controls out of the camera itself, separating control from supporting systems.)

Also, be aware that the physics engine itself has no concept of the camera or graphics. You are free to do whatever you want with them, it won't mind- it's blind!
Also, I notice you calculate your world matrix for the camera (using yaw, pitch, and position), then get the view using "ViewMatrix = Matrix.Invert(WorldMatrix)". If I were to create a ViewMatrix first (for the purposes of a chase camera, using CreateLookAt in XNA), could I get the camera WorldMatrix by using "WorldMatrix = Matrix.Invert(ViewMatrix)"? I've done some research and it seems Matrices are mutually invertable like that. Do you think that would make sense? Thanks!
You can indeed invert the view matrix to get the world matrix. You can think of the view matrix as pulling objects from world space into camera/view space; the inverse transform pulls objects from camera/view space into world space.
jimmyfo
Posts: 12
Joined: Sun Dec 25, 2011 7:27 pm

Re: Quick camera questions

Post by jimmyfo »

Thank you for a very prompt and thorough answer! I am in the process of breaking out the camera mechanism (well, I will be now) and will share it when done, if you're interested. Thanks again!
Post Reply