   Simple Matrix Question
  I looked this up but I wanted to double check with you guys:The camera position in object space is the 4th column of the modelview matrix.is that correct?  If not... what is?   
Quote:Original post by AtmaWeaponI looked this up but I wanted to double check with you guys:The camera position in object space is the 4th column of the modelview matrix.is that correct?  If not... what is?Since you mention 'modelview' I'm assuming OpenGL here. In any case the answer is no, that's not correct. The 4th column does contain the translation for the modelview matrix, but it's not the camera position.The first reason for this is that the modelview matrix may contain any number of concatenated transforms, usually only one of which is related to the camera position. In general, there's no way to extract the camera position from the modelview matrix unless you know exactly what individual transforms went into it and in what order.The second reason is that even if the modelview matrix is known to only contain the view transform, it's actually inverted relative to the 'actual' camera position and orientation. It is possible though to extract the camera position from a view-only modelview matrix (just not directly).[Edit: I see now you asked about the camera position 'in object space'. Depending on what you mean by this, my above answer may not be completely relevant.]   ;  Thanks a bunch.  I'm using OpenGL and yes it is the camera position in object space.  But in the end, all I really need is the camera vector.  Isn't this just the inverse model view matrix multiplied by the vertex position?In other words in my shader I would have mul(invModelView, vertexPos)   ;Quote:Original post by AtmaWeaponBut in the end, all I really need is the camera vector.  Isn't this just the inverse model view matrix multiplied by the vertex position?In that case, the first reason in jyk's reply is totally relevant, and the answer to your question is no. In your case, you must pass two matrices (model and view, or model-view and view, or model-view and camera) separately to the shader. But why do you need to know the camera's position in the shader?;Quote:In that case, the first reason in jyk's reply is totally relevant, and the answer to your question is no. In your case, you must pass two matrices (model and view, or model-view and view, or model-view and camera) separately to the shader. But why do you need to know the camera's position in the shader?The camera vector is the view vector.  This needed for many things from reflections, phong shading, etc.  So why do I need seperate model-view and view matrices.  Could elaborate more what you mean.  Isn't model view just mul(model, view)   