Sunday, July 3, 2022
HomeGame Developmentarithmetic - Why does my parallel projection seem inverted?

arithmetic – Why does my parallel projection seem inverted?


I’ve the next parallel projection (Row main):

enter image description here

And it’s giving me the next output:

enter image description here

When in actuality it must be giving me this (picture not centered):

enter image description here

n is 0.1
and f is 100
The origin is in the midst of the wireframe and the 42 wireframe top is within the +z route.

My matrix multiplication:

typedef struct s_point
{
    float   x;
    float   y;
    float   z;
    int     c; //coloration
}   t_point;


void    multiply_matrix_vector(t_point *i, t_point *o, t_pmatrix *m)
{
    float   w;

    o->x = i->x * m->m[0][0] + i->y * m->m[1][0] + i->z * m->m[2][0] + m->m[3][0];
    o->y = i->x * m->m[0][1] + i->y * m->m[1][1] + i->z * m->m[2][1] + m->m[3][1];
    o->z = i->x * m->m[0][2] + i->y * m->m[1][2] + i->z * m->m[2][2] + m->m[3][2];
    w = i->x * m->m[0][3] + i->y * m->m[1][3] + i->z * m->m[2][3] + m->m[3][3];
    if (w != 0.0f)
    {
        o->x /= w;
        o->y /= w;
        o->z /= w;
    }
    o->c = i->c;
}

What am I doing mistaken?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments