所以,我用这个画了一个黄色的长方体
glm::mat4 yellow_bone_obj_mat = m_bone_animation->get_yellow_mat();
glUniformMatrix4fv(glGetUniformLocation(shader.program, "model"), 1, GL_FALSE, glm::value_ptr(yellow_bone_obj_mat));
bone_obj->obj_color = m_bone_animation->colors[1];
draw_object(shader, *bone_obj);
带比例因子{ 0.5f,4.0f,0.5f }
和位置{ 2.0f,3.0f,2.0f }
我想让我的黄色长方体向右旋转90度,同时让黄色长方体的最终位置粘住红色立方体
应该看起来像这样
我尝试过
m_yellow_mat = glm::translate(m_yellow_mat, glm::vec3(0.0, -0.5, 0.0)); //0.5f is just random number to check if pivot changed
m_yellow_mat = glm::rotate(m_yellow_mat, glm::radians(angle), glm::vec3(0, 0, 1));
m_yellow_mat = glm::translate(m_yellow_mat, glm::vec3(0.0, 0.5, 0.0));
将此作为输出
下一次我尝试过
m_yellow_mat = glm::translate(m_yellow_mat, glm::vec3(0.0, -0.5, 0.0)); //0.5f is just random number to check if pivot changed
m_yellow_mat = glm::rotate(m_yellow_mat, glm::radians(angle), glm::vec3(1, 0, 0)); //changed axis
m_yellow_mat = glm::translate(m_yellow_mat, glm::vec3(0.0, 0.5, 0.0));
将其作为输出。不管我做什么,长方体都不会落在右侧。我不确定为什么