# [Bf-committers] Projection matrix export to Python

Sergey Kurdakov sergey.forum at gmail.com
Wed Dec 29 02:53:49 CET 2010

```Hi,

recently, while investigating possibility to solve one of our internal
rendering problem I got a look at

dimetric and trimetric projections ( see set of links )
http://www.significant-bits.com/a-laymans-guide-to-projection-in-videogames
http://www.gamedev.net/reference/articles/article1269.asp<http://www.gamedev.net/reference/articles/article1269.asp#NEN2536>
http://www.compuphase.com/axometr.htm
http://www.ul.ie/~rynnet/keanea/dimetric.htm

I did not find a way to change projection matrix from python, and because
I'm relatively new to code, I just changed added to wmOrtho   my custom
function ( which was used in place of wmOrtho in couple of places) like

void wmOrthoCustom(float x1, float x2, float y1, float y2, float n, float
f,float scalex,float scaley,float scalez)
{

float l=x1/*x1*/, r=x2, b=y1, t=y2/*y1*/ , f_=f/*f*/ , n_=n/*n*/; //n - ear
f - far r - right

glMatrixMode(GL_PROJECTION);

orig_projmat[0]=scalex*(2./(r-l)); orig_projmat[4]=0; orig_projmat[8] =0;
orig_projmat[12]=-(r+l)/(r-l);
orig_projmat[1]=0; orig_projmat[5]=scaley*2/(t-b); orig_projmat[9] =0;
orig_projmat[13]=-(t+b)/(t-b);
orig_projmat[2]=0; orig_projmat[6]=0; orig_projmat[10]=scalez*(-2/(f-n));
orig_projmat[14]=-(f+n)/(f-n);
orig_projmat[3]=0; orig_projmat[7]=0; orig_projmat[11]=0;
orig_projmat[15]=1;

glMatrixMode(GL_MODELVIEW);
}

where scales vars I added as members of Camera and exported to python, which
allowed me to change relations between axes in object view window.

Now - if Projection matrix could be exported python ( and also used in
rendering pipeline, not only preview ), this might be a good feature  at
least at blendernation someone got interested while I was asking question.

It is not just very difficult - just instead of glOrtho or glPerspective to