Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualFrozT

Posted 16 July 2013 - 10:46 AM

Well I'm changing the way I'm asking this question and simplifying it.  Basically, I just want to know how to move a camera the way I've moved my world matrix.

 

this is what I've been trying:

MainCamera.Eye = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.Eye, WorldMatrix);
MainCamera.At = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.At, WorldMatrix);
MainCamera.Up = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.Up, WorldMatrix);

but it always yields some strange result.

 

Thanks


#1FrozT

Posted 04 July 2013 - 04:32 PM

Hi All,

 

I've been banging my head against a wall now for about a week trying to solve a small but annoying camera issue.  The construct is quite simple really, I have a building which has many floors (a floor is just a quad.)  I create camera objects just over and out from each floor so that at any time I want to flip to the view of a floor I just use that floors pre-defined camera position. Each camera is set at exactly the same distance etc. from the floor it's set to look at.  Now when I flip to any given Camera, the lower floors appear to display more towards the bottom of the display at a more perpendicular angle, and the upper floor cams appear to display the floor nearer the top of the display, at a steeper angle. Here is a text representation of what I'm talking about:

Side View of building

            /Cam
           /
--Floor--|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ /Cam
         | /
---------|/ 
         | 


Perspective View

Upper Floors
|--------------|<-display
| [=========]  |
| [  FLOOR  ]  |<-perspective view of floor
| [=========]  |
| |         |  |
| |         |  |<-rest of building
| |         |  |
|--------------|

Lower Floors
|--------------|
| |         |  |
| |         |  |
| [=========]  |
| [         ]  |
| [  FLOOR  ]  |
| [=========]  |
|--------------|

When I flip to a camera I do a transform coordinate with the Eye, At, and Up using the world of the building itself so if the buildings been rotated then the cameras follow suite.

 

My basic setup is as follows:

public void AddFloor(float floorYLocation)
{
....
perpectiveFloorCamera.Eye = new Vector3(0, floorYLocation + perpectiveCamera.ZNear + building.DiameterXZ, building.RadiusNegZ);
perpectiveFloorCamera.At = new Vector3(0, floorYLocation, building.RadiusPosZ);
perpectiveFloorCamera.Up = new Vector3(0,1.0f,0); // or (0,floorYLocation + 1.0f,0)
//Where:
//DiameterXZ = diameter of the base of the building  (eg 2.0f)
//RadiusNegZ = smallest Z coord in model of building (eg -1.0f)
//RadiusPosZ = highest Z coord in model of building  (eg +1.0f)
//Those just make the cam point a little down and forward at the floor for a perspective view of the floor
...
}

public void ZoomToFloor(Floor floor)
{
MainCamera.Eye = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.Eye, WorldMatrix);
MainCamera.At = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.At, WorldMatrix);
MainCamera.Up = Vector3.TransformCoordinate(floor.perpectiveFloorCamera.Up, WorldMatrix);
//I've also tried to invert+transpose the world matrix before transforming.
}

So then just for fun I decided that for every floor I would flip to the bottom floor camera only, transform it and then just move it up in the Y direction until I got to the floor I needed to be at.  Same thing, no difference at all.  Even tried just flipping to the bottom floor camera, and moving the whole building down in the Y direction until I reached my floor, same thing.

 

 

My goal is to be able to flip to any floor camera and have it display the floor with the exact same angle/dimensions as when viewing any other floor.  The floor should occupy the same amount of the display and be on the same angle no matter how high up or low down in the building the floor is (But not an Ortho view, I already have one of those working just fine.)  It sounds like it should be simple but apparently not in practice (for me anyway.)   My camera's View's are Matrix.LookAtLH(eye, at, up) and 45 degree FOV.

 

Any ideas?  Is this some kind of FOV/Projection issue or something?

 

Thanks


PARTNERS