我一直在尝试让旋转工作,它似乎工作,当我尝试移动对象时出现我的问题,我期待对象的轴与网格一起旋转,但它保持全局轴并继续移动该轴上的对象。我对轮换的理解有缺陷吗?或者是导致这种情况发生的代码,如果我的理解是问题是否有办法用对象转换对象轴。我的代码如下。
Projection= glm::perspective(45.f, 4.0f / 3.0f, 0.1f, 100.0f);
//position and direction are calculated based on mouse position
View = glm::lookAt(
position,
position+direction,
up
);
glm::mat4 myMatrix = glm::translate(x,y,z);
glm::mat4 myScalingMatrix = glm::scale(0.2f, 0.2f ,0.2f);
glm::vec3 myRotationAxis( 0, 1, 0);
glm::mat4 tempModel = glm::mat4(1.f);
glm::mat4 myRotationMatrix =glm::rotate( tempModel,45.f, myRotationAxis );
glm::mat4 Model= myMatrix* myRotationMatrix *myScalingMatrix;
glm::mat4 MVP = Projection* View * Model;