久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

了解 libGDX 投影矩陣

Understanding the libGDX Projection Matrix(了解 libGDX 投影矩陣)
本文介紹了了解 libGDX 投影矩陣的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在過去的幾周里,我一直在嘗試學習 libGDX 庫.我發現很難理解相機/視口關系系統,尤其是在我第一次嘗試游戲開發時.我被告知要使用的一行代碼以及 API 提到的代碼是:

Over the past few weeks I've been attempting to learn the libGDX library. I'm finding it hard, especially for my first endeavor toward game development, to comprehend the system of Camera/viewport relationships. One line of code that I've been told to use, and the API mentions, is:

    batch.setProjectionMatrix(camera.combined);

盡管進行了 4 個小時的研究,但我仍然對這段代碼的功能缺乏完整的了解.據我的基本理解,它告訴"相機正在尋找的批次.我缺乏理解力令人沮喪和憤怒,如果有人能幫助我,我將不勝感激.代碼片段的另一個問題是我不確定何時需要實現(在渲染方法、創建方法等中).

Despite a good 4 hours of research, I'm still lacking a complete understanding of the functionality of this code. It is to my basic understanding that it "tells" the batch where the camera is looking. My lack of comprehension is depressing and angering, and I'd appreciate if anyone could assist me. Another issue with the code snippet is that I'm unsure of when it's necessary to implement (in the render method, create method, etc).

推薦答案

考慮用相機拍照.例如.使用您的智能手機相機拍攝公園長凳的照片.當你這樣做時,你會在智能手機的屏幕上看到公園里的長椅.這可能看起來很明顯,但讓我們看看這涉及到什么.

Consider taking a picture with a camera. E.g. using your smartphone camera taking a picture of a bench in the park. When you do that, then you'll see the bench in the park on the screen of your smartphone. This might seem very obvious, but let's look at what this involves.

圖片上長凳的位置是相對于您拍照時站立的位置.換句話說,它是相對于相機而言的.在典型的游戲中,您不會相對于對象放置對象.相反,您將它們放置在您的游戲世界中.在您的游戲世界和您的相機之間進行轉換是使用矩陣完成的(這只是一種轉換坐標的數學方法).例如.當您將相機向右移動時,長凳會在照片上向左移動.這稱為視圖矩陣.

The location of the bench on the picture is relative to where you were standing when taking the photo. In other words, it is relative to the camera. In a typical game, you don't place object relative to the object. Instead you place them in your game world. Translating between your game world and your camera, is done using a matrix (which is simply a mathematical way to transform coordinates). E.g. when you move the camera to the right, then the bench moves to the left on the photo. This is called the View matrix.

圖片上長凳的確切位置還取決于長凳和相機之間的距離.至少,它是 3D 的(2D 非常相似,所以請繼續閱讀).當它更遠時,它更小,當它靠近相機時,它更大.這稱為透視投影.您還可以進行正交投影,在這種情況下,對象的大小不會根據與相機的距離而改變.無論哪種方式,公園長凳的位置和大小都會轉換為屏幕上的位置和大小(以像素為單位).例如.公園里的長凳是兩米寬,而照片上是 380 像素.這稱為投影矩陣.

The exact location of the bench on the picture also depends on the distance between bench and the camera. At least, it does in 3D (2D is very similar, so keep reading). When it is further away it is smaller, when it is close to the camera it is bigger. This is called a perspective projection. You could also have an orthographic projection, in which case the size of the object does not change according to the distance to the camera. Either way, the location and size of the bench in the park is translated to the location and size in pixels on the screen. E.g. the bench is two meters wide in the park, while it is 380 pixels on the photo. This is called the projection matrix.

camera.combined 表示組合的視圖和投影矩陣.換句話說:它描述了游戲世界中的事物應該在屏幕上渲染的位置.

camera.combined represents the combined view and projection matrix. In other words: it describes where things in your game world should be rendered onto the screen.

調用 batch.setProjectionMatrix(cam.combined); 指示批處理使用該組合矩陣.每當值更改時,您都應該調用它.這通常是在調用 resize 時以及在您移動或以其他方式改變相機時.

Calling batch.setProjectionMatrix(cam.combined); instruct the batch to use that combined matrix. You should call that whenever the value changes. This is typically when resize is called and also whenever you move or otherwise alter the camera.

如果您不確定,那么您可以在 render 方法的開頭調用它.

If you are uncertain then you can call that in the start of your render method.

這篇關于了解 libGDX 投影矩陣的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why does the android emulator camera stop unexpectedly?(為什么android模擬器相機會意外停止?)
Android camera , onPictureTaken(byte[] imgData, Camera camera) method amp; PictureCallback never called(Android camera , onPictureTaken(byte[] imgData, Camera camera) 方法 amp;PictureCallback 從未調用過) - IT屋-程序員軟件開發技
QR code reading with camera - Android(使用相機讀取二維碼 - Android)
IP camera with OpenCv in Java(Java中帶有OpenCv的IP攝像頭)
Android mock Camera(Android 模擬相機)
Multiple cameras in libgdx ( probably similar in other frameworks )(libgdx 中的多個攝像頭(在其他框架中可能類似))
主站蜘蛛池模板: 狠狠的干狠狠的操 | 日本一区二区三区在线观看 | 欧美日韩一二三区 | 亚洲成人一二区 | 亚洲成人精品一区二区 | 久久久国产一区二区三区 | 国产亚洲精品久久yy50 | 婷婷激情在线 | 香蕉久久久 | 日韩电影中文字幕在线观看 | 99成人 | 在线一区二区三区 | 五月天综合影院 | 看片地址 | 亚洲精品一区二区 | 一区二区三区国产 | 99精品电影| 欧美极品少妇xxxxⅹ免费视频 | 久久国产精品免费一区二区三区 | 日本人做爰大片免费观看一老师 | 99亚洲精品视频 | 久久99精品久久久久久青青日本 | 精品国产成人 | 男女羞羞在线观看 | 91欧美 | 久久久五月天 | 国产精品久久久久久婷婷天堂 | 久久国产精品一区二区 | 91久久国产综合久久91精品网站 | 亚洲成人av在线播放 | 久久精品a级毛片 | 日韩免费一区二区 | 久久亚洲视频 | 一级毛片免费完整视频 | 精产国产伦理一二三区 | 成人免费黄色片 | 久草精品视频 | 亚洲天堂精品久久 | 性做久久久久久免费观看欧美 | 伊人网站在线观看 | 免费视频一区 |