為什麼我們需要維護自己的矩陣來轉換遊戲對象? (Why we need to maintain our own matrices to transform Game objects?)


問題描述

為什麼我們需要維護自己的矩陣來轉換遊戲對象? (Why we need to maintain our own matrices to transform Game objects?)

First, I think that I don't have complete understanding about 3D/Game maths. But I know C++ and OpenGL basics. Recently i have intergrated NVidia PhysX with OpenGL and worked well. So i can tranform my OpenGL objects using PhysX. Here is a part of my code,

NxMat34 pose = actor‑>getGlobalPose(); 
float mat[16];
pose.getColumnMajor44(mat);

glPushMatrix(); 
glMultMatrixf(mat);
‑‑ draw the object ‑‑
glPopMatrix();

Bui i know that other people use separate matrices to represent their objects transformations even though they have physics libraries to transform their objects. My problem is why we need to maintain separate matrices/quaternions ? Can't we use Physics library's matrices?

‑‑‑‑‑

參考解法

方法 1:

Your question presupposs that:

  1. Everyone uses the exact same physics library. Or any physics library for that matter; many games don't need them.

  2. Everyone uses exactly and only the matrices that come from that library. Animation frequently requires offsetting the position of the rendered entity from the "physics" location of it, not to mention having a different orientation. Or having bones (which are almost never part of any physics system) or other independent parts of the object.

You don't need to do anything. If you've got something that works for you, then do it. Just remember that there are consequences for every action. And in this case, the consequence is that you're directly binding the physics location of a game object to the location of the game object.

The tighter your code is coupled, the less flexible it is to needs down the line.

(by shanNicol Bolas)

參考文件

  1. Why we need to maintain our own matrices to transform Game objects? (CC BY‑SA 3.0/4.0)

#matrix #3d #opengl #C++






相關問題

BLAS 子程序 dgemm、dgemv 和 ddot 不適用於標量? (BLAS subroutines dgemm, dgemv and ddot doesn't work with scalars?)

為什麼我們需要維護自己的矩陣來轉換遊戲對象? (Why we need to maintain our own matrices to transform Game objects?)

R 高斯消除和 qr 分解 (R Gaussian Elimination and qr factorization)

生成尺寸為 8x8 的正定矩陣 (Generating Positive definite matrix of dimensions 8x8)

替代在此 Ruby 代碼中使用基於時間間隔分配標籤的巨型 if/else (Alternative to using a giant if/else in this Ruby code that assigns labels based on the time interval)

如何創建一個行矩陣,其元素是我的 while 循環的迭代 (How to create a row matrix whose elements are the iterations of my while loop)

在Matlab中找到矩陣中相同元素的開始索引和結束索引 (Find the Start Index and End Index of the same Element in a Matrix in Matlab)

用 Matlab 寫一個方程(矩陣大小) (writing an equation with Matlab (Matrix size))

使用 numpy 或 pandas 從元組列表中為二元組創建頻率矩陣 (Create a frequency matrix for bigrams from a list of tuples, using numpy or pandas)

如何在循環和 if 語句中使用遞歸公式 (How to use recursive formula in loop and if statement)

如何從 p 值矩陣中獲得緊湊的字母顯示? (How to get a compact letter display from a matrix of p-values?)

刺激基質上的液體流動 (Stimulating Liquid Flow on Matrix)







留言討論