coordinates in front of me (webgl / opengl) -


i'm learning webgl , i've been stuck on problem half day.

i'm moving scene way :

mat4.rotate(mvmatrix, degtorad(-angle), [0, 1, 0]);  mat4.translate(mvmatrix, [-currentx, 0, -currentz]); 

how supposed coordinates (x/z) of point in front of me (let's 10 units) ?

modelview matrix matrix transforms model local space view space. point "10 units in front of you" can anywhere, depending on space you're interested in. want know point 10 units in front of located in model space. well, nothing simple that.

the point 10 units in front of viewer located in view space @ (0,0,-10). have applying inverse transform, i.e. multiply vector inverse ov mvmatrix:

mat4.inverse(mvmatrix) * vec4(0,0,-10,1); 

if wonder last 1 element comes , why 4 element vector used 3 dimensional coordinate (which should wonder about) have read homogenous coordinates.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -