Skip to main content
2 of 2
added 915 characters in body
user avatar
user avatar

Your understanding is correct:

  • The model matrix moves from model space to world space.
  • The view matrix moves from world space to view space.
  • The projection matrix moves from view space to clip space.

In which space are these coordinates?

Coordinates in model files are in model (or "object") space.

If it's in the model space, what is the best strategy to develop a model matrix to put this object into world space?

You do this when you decide you're going to render a particular instance of the model somewhere, oriented and scaled in some way. In the general sense you create a translation matrix based on the X, Y and Z in world space you want the object to appear, a rotation matrix based on how you want to orient the object in the world and a scaling matrix based on how you want to scale the object (if at all) and concatenate all three of these as appropriate via matrix multiplication.

You will generally create one such model matrix per instance you're going to draw in the world (whereas you'd probably create the view and projection matrices only once per frame).

Another OBJ model of same bunny might have coordinates all lying in [-1, 1] range for example. Does this mean this object is already transformed with an MVP?

No. It just means it's smaller (unless of course you choose to assume it's already transformed, which you can do, but that is of limited practical use).

From your commentary:

For example, to develop a translation matrix I need to look at object space coordinates, then I could say, "oh I can trasnlate x-axis by -20, that could put this object here". But this assumes I should be fully aware of the object space coordinates of each model.

No, it doesn't assume that. What is assumed in the transition from object to world space is that the you "place" the origin of the object in model space at the desired point in the world; that the model was authored so that the object-space coordinate (0,0,0) is a reasonable placement point for the object. For a humanoid character, for example, you might expect that (0,0,0) is centered under the model's feet.

The three basic transformation matrices are "about the origin," so (for example) a translation of (X, Y, Z) in a model matrix will put the point at (0,0,0) in object space at (X, Y, Z) in world space.

If this assumption that the model is built around a reasonable (0,0,0) point is not true... if for example somebody created a model of a human character and the feet were at (-43, 200, 2) for some reason.. then yes, you'd need to know this offset from the actual model space origin to the placement point. There is no way to algorithmically determine this offset for arbitrary geometry, so any content pipeline that is building models in this (very strange) fashion will generally either also make sure to export that offset in some form, or possibly only be used in a constrained set of circumstances where additional context allows one to algorithmically determine the offset. This is uncommon, however, and you're more likely to see models built around a reasonable origin for placement.

user1430