所以我想爲我的批處理渲染系統翻譯CPU上的頂點。我試圖複製glsl,但它不起作用。 (該模型沒有顯示出來)C++ glm Opengl glm :: mat4轉換和旋轉glm :: vec4
glm::vec4 off = glm::vec4(0, 0, 0, 1);
off = Util::createTransform(offset, glm::vec3(0, 45, 0)) * off; //translated the vertex by the offset(supplied by the function) and rotates by 45 degrees on the Y axis
for (int i = 0; i < Tvertex.size(); i++) {
Tvertex[i] *= glm::vec3(off.x, off.y, off.z); //I think its here I might have messed up?
}
這裏是 「的Util :: createTransform」 功能:
glm::mat4 Util::createTransform(glm::vec3 pos, glm::vec3 rot) {
glm::mat4 trans = glm::mat4(1.0);
trans = glm::rotate(trans, glm::radians(rot.x), glm::vec3(1, 0, 0));
trans = glm::rotate(trans, glm::radians(rot.y), glm::vec3(0, 1, 0));
trans = glm::rotate(trans, glm::radians(rot.z), glm::vec3(0, 0, 1));
trans = glm::translate(trans, pos);
return trans;
}
那麼,在哪裏我搞砸了?