- Learning Windows 8 Game Development
- Michael Quandt
- 389字
- 2021-07-23 15:36:05
Co-ordinate systems
We're using Direct3D to display our 2D world, which means we need to consider the differences between how we work with 3D and what we need for 2D, and adapt to make everything fit together. For our purposes DirectXTK will take care of most of this; however it's useful to know what's going on, and understand the concepts involved so that you can delve into advanced concepts in future to create some amazing visuals.
In 2D the world is represented as a Cartesian plane, with the X-axis representing the horizontal axis, and the Y-axis representing the vertical. Many 2D systems, including Direct3D and DirectXTK, position the co-ordinate (0, 0)
, also known as the origin, at the top-left corner of the screen.

2D and 3D
3D adds a third dimension, Z, to the mix, which represents the axis perpendicular to both X and Y, heading "away" from the viewer if you view the X/Y plane head on. When referring to the camera, this represents the depth of the image, and can be translated to the 2D world to add layering and depth between the flat images.
This brings us to another topic—cameras. A camera is a virtual representation of real life cameras; they handle defining what is actually rendered on screen, and where, allowing for us to easily move the view around without messing with the entire game world.
You may be used to cameras in 3D games that have perspective (objects get smaller, the further away they are). A projection is the transformation from a 3D world to a flat 2D world, which is often called screen space. A perspective projection allows us to turn the lines and shapes of the world into a flat image that conveys depth by angling lines towards the horizon to introduce perspective.

A cube in perspective (left) and orthographic (right) projections
The problem with using the perspective projection for 2D is that we may want our sprites to look 3D, but they contain no depth information. When rendered with sprites sitting behind them, they will look mismatched and wrong. This is where the Orthographic projection comes into play. An orthographic projection prevents perspective from entering the image and allows us to control the illusion of the depth in a way that fits with the 2D sprites we are using.
- Cisco OSPF命令與配置手冊(cè)
- Web安全防護(hù)指南:基礎(chǔ)篇
- 物聯(lián)網(wǎng)識(shí)別技術(shù)
- 社交電商運(yùn)營(yíng)策略、技巧與實(shí)操
- 萬(wàn)物互聯(lián):蜂窩物聯(lián)網(wǎng)組網(wǎng)技術(shù)詳解
- HCNA網(wǎng)絡(luò)技術(shù)
- 無(wú)人機(jī)通信
- 網(wǎng)絡(luò)的琴弦:玩轉(zhuǎn)IP看監(jiān)控
- 物聯(lián)網(wǎng)通信技術(shù)
- Bonita Open Solution 5.x Essentials
- 語(yǔ)音信號(hào)處理及Blackfin DSP實(shí)現(xiàn)
- 網(wǎng)絡(luò)利他行為研究:積極心理學(xué)的視角
- 一本書讀懂物聯(lián)網(wǎng)
- 移動(dòng)物聯(lián)網(wǎng):商業(yè)模式+案例分析+應(yīng)用實(shí)戰(zhàn)
- 區(qū)塊鏈社區(qū)運(yùn)營(yíng)手冊(cè)