开发者

Generating an MVP for an object

So I'm using GLM to generate a MVP for each specific model, like so: (Ignore the namespace errors, I am using namespace glm but sometimes I just like to write it in)

//Generate MVP
glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
glm::mat4 View = glm::lookAt(
    vec3(4, 4, 3),
    vec3(0, 0, 0),
    vec3(0, 1, 0)
    );
glm::mat4 Model = mat4(1.0f);

glm::mat4 MVP = Projection * View * Model;

If I want my model to be in a different place than the origin, should I simply change

glm::mat4 Model = mat4(1.0f);

to

glm::mat4 Model = glm::gtx::translate(x, y, z开发者_StackOverflow社区);


Yes, that should do it. Think of it as placing your model relative to the world.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜