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

<i id='ivmVV'><tr id='ivmVV'><dt id='ivmVV'><q id='ivmVV'><span id='ivmVV'><b id='ivmVV'><form id='ivmVV'><ins id='ivmVV'></ins><ul id='ivmVV'></ul><sub id='ivmVV'></sub></form><legend id='ivmVV'></legend><bdo id='ivmVV'><pre id='ivmVV'><center id='ivmVV'></center></pre></bdo></b><th id='ivmVV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ivmVV'><tfoot id='ivmVV'></tfoot><dl id='ivmVV'><fieldset id='ivmVV'></fieldset></dl></div>

    1. <legend id='ivmVV'><style id='ivmVV'><dir id='ivmVV'><q id='ivmVV'></q></dir></style></legend>

    2. <small id='ivmVV'></small><noframes id='ivmVV'>

        • <bdo id='ivmVV'></bdo><ul id='ivmVV'></ul>
        <tfoot id='ivmVV'></tfoot>
      1. 使用 glm 以局部和全局方向旋轉(zhuǎn)和平移對(duì)象

        Rotate and translate object in local and global orientation using glm(使用 glm 以局部和全局方向旋轉(zhuǎn)和平移對(duì)象)

        1. <i id='gN3SN'><tr id='gN3SN'><dt id='gN3SN'><q id='gN3SN'><span id='gN3SN'><b id='gN3SN'><form id='gN3SN'><ins id='gN3SN'></ins><ul id='gN3SN'></ul><sub id='gN3SN'></sub></form><legend id='gN3SN'></legend><bdo id='gN3SN'><pre id='gN3SN'><center id='gN3SN'></center></pre></bdo></b><th id='gN3SN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gN3SN'><tfoot id='gN3SN'></tfoot><dl id='gN3SN'><fieldset id='gN3SN'></fieldset></dl></div>
        2. <legend id='gN3SN'><style id='gN3SN'><dir id='gN3SN'><q id='gN3SN'></q></dir></style></legend>
              • <bdo id='gN3SN'></bdo><ul id='gN3SN'></ul>
                • <small id='gN3SN'></small><noframes id='gN3SN'>

                  <tfoot id='gN3SN'></tfoot>
                    <tbody id='gN3SN'></tbody>
                  本文介紹了使用 glm 以局部和全局方向旋轉(zhuǎn)和平移對(duì)象的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在嘗試實(shí)現(xiàn)一些功能,在這些功能中我可以使用 glm 以局部或全局方向旋轉(zhuǎn)/平移對(duì)象,例如在 3D 建模軟件中.像這樣:

                  i am trying to implement functions, where i can rotate/ translate an object in local or global orientation, like in 3D modeling software, using glm. Something like this:

                  void Rotate(float x, float y, float z, bool localOrientation);
                  

                  但我不知道如何讓它工作.局部旋轉(zhuǎn)旋轉(zhuǎn)應(yīng)該是這樣的(?):

                  but I dont know how to get it working. Local rotation rotation should just be something like this(?):

                  m_Orientation *= glm::rotate(x, glm::vec3(1,0,0);
                  m_Orientation *= glm::rotate(y, glm::vec3(0,1,0);
                  m_Orientation *= glm::rotate(z, glm::vec3(0,0,1);
                  
                  // (m_Orientation is glm::mat4)
                  

                  但是如何將其與本地定位結(jié)合起來(lái)呢?實(shí)際上我需要在世界方向旋轉(zhuǎn)旋轉(zhuǎn)矩陣,對(duì)嗎?我希望你知道我對(duì)面向局部和全局的旋轉(zhuǎn)/平移的意思,就像在 3D 建模程序中一樣.在大多數(shù)情況下,您有一個(gè)按鈕可以在本地和全局之間切換.

                  But how to combine this with local orientation? Actually i need to rotate the rotation matrix in world orientation, right? I hope you know what i mean with local and global oriented rotation/translation, like it is in 3D modeling programs. In most of them you have a button to switch between local and global.

                  然后我將如何計(jì)算向前/向右/向上矢量?通常應(yīng)該是這樣的,對(duì)吧?:

                  And how would i calculating the forward/right/up vector then? normally it should be something like this, right?:

                  forward = m_Orientation * glm::vec4(0,0,-1,0);
                  

                  我用這個(gè)嘗試了全局旋轉(zhuǎn):

                  I tried global rotation with this:

                  m_GlobalOrientation = glm::rotate(m_GlobalRotation.x, glm::vec(1,0,0);
                  m_GlobalOrientation *= glm::rotate(m_GlobalRotation.y, glm::vec(0,1,0);
                  m_GlobalOrientation *= glm::rotate(m_GlobalRotation.z, glm::vec(0,0,1);
                  

                  但是只有 x 旋轉(zhuǎn)處于全局方向,y 和 z 旋轉(zhuǎn)處于局部方向,因?yàn)樗呀?jīng)圍繞 x 軸旋轉(zhuǎn).所以我需要一次旋轉(zhuǎn)所有 3 個(gè)角度(?)

                  but then only x rotation is in global orientation, y and z rotation is in local orientation, since it is already rotated around x axis. So I need to rotate all 3 angles at once(?)

                  翻譯本地應(yīng)該只是將翻譯值添加到當(dāng)前翻譯中,而本地翻譯應(yīng)該是 glm::inverse(m_Orientation) * translationVector 對(duì)嗎?

                  Translating local should just be adding translation values to current translation, and local translation should be glm::inverse(m_Orientation) * translationVector right?

                  推薦答案

                  在回答你的問(wèn)題之前,讓我解釋一下矩陣的一些核心概念.

                  Before I come to your question, let me explain some core concepts of matrices.

                  假設(shè)我們有以下矩陣:

                  其中 T 是平移,R 是旋轉(zhuǎn)矩陣.

                  wher T is a translation and R is a rotation matrix.

                  當(dāng)我們使用這個(gè)矩陣來(lái)變換一個(gè)頂點(diǎn)(甚至網(wǎng)格)時(shí),會(huì)有一個(gè)獨(dú)特的結(jié)果.但是,我們可以通過(guò)兩種解釋得出這個(gè)結(jié)果:

                  When we use this matrix to transform a vertex (or even mesh), there is one unique result. However, we can get to this result with the help of two interpretations:

                  解讀1:從右到左評(píng)估

                  如果我們從右到左評(píng)估矩陣,則所有變換都在全局坐標(biāo)系中執(zhí)行.所以如果我們變換一個(gè)位于原點(diǎn)的三角形,我們會(huì)得到以下結(jié)果:

                  If we evaluate the matrix from right to left, all transformations are performed in the global coordinate system. So if we transform a triangle that sits at the origin, we get the following result:

                  解讀2:從左到右評(píng)價(jià)

                  在另一種情況下,所有變換都在局部坐標(biāo)系中進(jìn)行:

                  In the other case, all transformations are performed in the local coordinate system:

                  當(dāng)然,我們得到了相同的結(jié)果.

                  Of course, we get the same result.

                  所以回到你的問(wèn)題.如果將對(duì)象的位置和方向存儲(chǔ)為矩陣 T.您可以通過(guò)將旋轉(zhuǎn)矩陣乘以當(dāng)前矩陣的右側(cè),在其局部坐標(biāo)系中旋轉(zhuǎn)此對(duì)象.在全局系統(tǒng)中通過(guò)在左側(cè)乘以它.這同樣適用于翻譯:

                  So coming back to your question. If you store the position and orientation of the object as a matrix T. You can rotate this object in its local coordinate system by multiplying a rotation matrix to the right side of the current matrix. And in the global system by multiplying it at the left side. The same applies for translation:

                  void Rotate(float x, float y, float z, bool localOrientation) 
                  {
                      auto rotationMatrix = glm::rotate(x, glm::vec3(1,0,0));
                      rotationMatrix  *= glm::rotate(y, glm::vec3(0,1,0));
                      rotationMatrix  *= glm::rotate(z, glm::vec3(0,0,1));
                      if(localOrientation)
                          this->T = this->T * rotationMatrix;
                      else
                          this->T = rotationMatrix * this->T;
                  }
                  

                  右/前/上向量是矩陣T的列向量.您可以直接讀取它們,也可以通過(guò)將矩陣與 (1, 0, 0, 0) (right), (0, 1, 0, 0) 相乘得到它們(up), (0, 0, 1, 0) (for/backward) or (0, 0, 0, 1) (position).

                  The right / forward / up vectors are the column vectors of the matrix T. You can either read them directly or get them by multiplying the matrix with (1, 0, 0, 0) (right), (0, 1, 0, 0) (up), (0, 0, 1, 0) (for/backward) or (0, 0, 0, 1) (position).

                  如果您想了解更多相關(guān)信息,請(qǐng)查看我的 有關(guān) DirectX 中矩陣的博客文章.但它適用于使用轉(zhuǎn)置矩陣的 DirectX.因此矩陣順序是相反的.閱讀文章時(shí)請(qǐng)注意這一點(diǎn).

                  If you want to read more about this, take a look at my blog article about matrices in DirectX. But it's for DirectX, which uses transposed matrices. Therefore the matrix order is reversed. Watch out for that when reading the article.

                  這篇關(guān)于使用 glm 以局部和全局方向旋轉(zhuǎn)和平移對(duì)象的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒(méi)有異常時(shí),C++ 異常會(huì)以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對(duì) const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時(shí)以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對(duì)象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說(shuō)明符 C++11 noexcept 之間的區(qū)別)

                  <small id='oNkRb'></small><noframes id='oNkRb'>

                      <tbody id='oNkRb'></tbody>
                  1. <i id='oNkRb'><tr id='oNkRb'><dt id='oNkRb'><q id='oNkRb'><span id='oNkRb'><b id='oNkRb'><form id='oNkRb'><ins id='oNkRb'></ins><ul id='oNkRb'></ul><sub id='oNkRb'></sub></form><legend id='oNkRb'></legend><bdo id='oNkRb'><pre id='oNkRb'><center id='oNkRb'></center></pre></bdo></b><th id='oNkRb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oNkRb'><tfoot id='oNkRb'></tfoot><dl id='oNkRb'><fieldset id='oNkRb'></fieldset></dl></div>
                    <tfoot id='oNkRb'></tfoot>
                      <bdo id='oNkRb'></bdo><ul id='oNkRb'></ul>
                        <legend id='oNkRb'><style id='oNkRb'><dir id='oNkRb'><q id='oNkRb'></q></dir></style></legend>

                            主站蜘蛛池模板: 99精品在线免费观看 | av入口| 欧美国产视频一区二区 | av毛片| 久久亚洲二区 | 毛片免费在线观看 | 免费在线播放黄色 | 国产一区二区观看 | 九九色综合 | 亚洲v日韩v综合v精品v | 天天草狠狠干 | 国产成人精品一区二 | 在线只有精品 | 精品国产欧美一区二区三区成人 | 成人精品 | 人人做人人澡人人爽欧美 | 在线播放亚洲 | 国产精品日韩高清伦字幕搜索 | 欧美成人一区二免费视频软件 | 中文字幕一二三 | 国产一区二区三区四区 | 色婷婷久久久久swag精品 | 91高清免费观看 | 国产一级毛片精品完整视频版 | 日本不卡一区二区三区在线观看 | 最新国产精品精品视频 | 欧美精品一区二区蜜桃 | 日本亚洲欧美 | 中文字幕日韩三级 | 国产在线观看一区二区三区 | 亚洲协和影视 | 欧美日韩国产中文字幕 | 精品国产欧美日韩不卡在线观看 | av毛片 | 婷婷国产一区二区三区 | 一级黄片一级毛片 | 成人一区二区三区 | 国产一级片一区二区 | 一级片网址| 毛片一级片| 亚洲欧美中文日韩在线v日本 |