# DirectX Camera

This topic is 2918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there a way to position the camera in such a way that World location (0,0) is in the bottom left of my window?... Meaning i will only be working in quadrant1, +x/+y locations.

Edit:
My overall issue is understanding how to put the camera in some kind of boundary. So the user cant scroll too far in any direction and see "nothingness".

Edit:
Is this a stupid or vague question? This is the 3rd forum I've tried without so much as a hint of what to do, or any questions about clarifying what I'm asking.

[Edited by - Cazicss on September 26, 2010 4:27:05 AM]

##### Share on other sites
I'm not sure about what you want to do, but try to calculate the far frustum corners of your camera. Look at this website: http://www.lighthouse3d.com/opengl/viewfrustum/index.php?defvf

The set camera position to:
X = fbl.x
Y = fbl.y
Z = farDist

Read the tutorial on the link I wrote and you will understand what does fbl mean.

Can you explain what you want to do a little more?

##### Share on other sites
First off i have to thank you! .. First person to try to help.

Ok, what i've done is started the camera positioned to be above location (0,0,0) and to lokat (0,0,0) .... but this puts (0,0,0) in the center of my screen. I want (0,0,0) in the bottom left corner so that the left and bottom edges of my screen are in alignment with the y and x axis. Does that make more sense?.. Im not sure how to tell how far to move the camera to the right and up to ensure that im in alignment with the 2 axies

EDIT: I do not want to see negative locations on screen.

##### Share on other sites
Read my first post again, I modified it.

##### Share on other sites
Maybe what I'm trying to do isn't important. If you play a game such as, say starcraft, you can scroll the screen up,down,left,right ..but when you reach the edges of the map your camera stops so that u can scroll no further.

I was assuming keeping the screen in the +x/+y section of the world would keep the math easier so i didnt want to move allow the camera to move into -x or -y values... since i wouldnt be putting any terrain or objects in that space anyway.

##### Share on other sites
Well, forget my first post... it wont work :S

I guess you have to calculate the the far frustum corners with current camera position (0,0,0) and look at (0,0,far plane z);

Then you set the camera position to (far top right frustum corner x, far top right frustum corner y, 0) and look at ( far top right frustum corner x, far top right frustum corner y, far top right frustum corner z);

Look at this image:

The black rectangle is the far plane of frustum when camera position is (0,0,0) and look at is (0,0,far plane z), and the red rectangle is when the camera position is (far top right frustum corner x, far top right frustum corner y, 0) and look at ( far top right frustum corner x, far top right frustum corner y, far top right frustum corner z). Im not sure if it will work.

P.S. Read the tutorial is posted a link in my first topic. It will tell you how to get the far frustum top right corner position (ftr).

##### Share on other sites
Hmm so it sounds like i need to look into these "far frustrum corner" things. I'll take a longer look at your link and try to do some extra research into the "far frustrum". For now I'm headed to bed and will post back in this thread when I've had a chance to go over some things.

Thanks again =). Most appreciated to have a direction ^_^

##### Share on other sites
It's a fairly easy topic to grasp, assuming you have a working knowledge of vectors and trig. I'm going to work in 2D for a sec, but the principle is the same

L     R         imagine a triangle lying on the XZ plane, running from camera  \   /          origin, to 2 points that each lie on opposite edges of the far   \ /           plane of your frustum. I'll call them Left,Right,and Camera   C

You can see that angle LCR is the (FOV)Field of view for this axis. Also note that if segment LR (not shown) was cut in half at point F, that a segment CF is perpendicular to LR. Knowing this, we can use trig to solve for C using 1/2 our FOV using a position of (0,far-near) for L.

Now picture the same thing on the YZ plane, using Top,Bottom,Camera for the 3 points of the frustum...

So by constraining the Bottom-Left corner of the far plane to be (0,0,far) you will get a frustum that exists only in the first quadrant, (though we should be using octant, as it is the proper term for 3D, but would depend most likely on Handedness

##### Share on other sites
Are you using ortho projection? I.e, do you use D3DXMatrixOrthoLH to create your projection matrix?

If you are, then the minimum position for your camera is x = W/2.0f and y = H/2.0f, where W and H are the width and height values used to create your projection matrix.

##### Share on other sites
Quote:
 Original post by BuckeyeAre you using ortho projection? I.e, do you use D3DXMatrixOrthoLH to create your projection matrix?If you are, then the minimum position for your camera is x = W/2.0f and y = H/2.0f, where W and H are the width and height values used to create your projection matrix.

Im using D3DXMatrixPerspectiveFovLH(&m_Projection, D3DX_PI/4, 500/500, 1, 500);

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
13

• 10
• 9
• 25
• 16
• 9
• ### Forum Statistics

• Total Topics
632610
• Total Posts
3007409

×