xisto Community

# Help Me (perspective Projection) make a Mode7 projection

## Recommended Posts

I made this code to test isometric projection:

`#include <graphics.h>#include <stdlib.h>#include <stdio.h>#include <conio.h>#include <math.h>float matrix[4][4] ={{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};void vertex( float x, float y, float z ){	float n[4],r[4]={0, 0, 0, 0};   n[0]=x; n[1]=y; n[2]=z; n[3]=1;   for(int i=0; i<4; i++)   	for(int j=0; j<4; j++)      	r[i]+=n[j]*matrix[j][i];   putpixel(r[0]+(getmaxx()/2),r[1]+(getmaxx()/2),YELLOW);}int main(void){   int gdriver = DETECT, gmode, errorcode;   initgraph(&gdriver, &gmode, "");   errorcode = graphresult();   if (errorcode != grOk) {      printf("Graphics error: %s\n", grapherrormsg(errorcode));      printf("Press any key to halt:");      getch();      exit(1);   }   int angle = 40;	do{      cleardevice();      //isometric projection      matrix[2][0] = -0.5 * sin( angle * M_PI / 180 );      matrix[2][1] = -0.5 * cos( angle * M_PI / 180 );      for(int i=-100; i< 100; i+=1)         for(int j=-100; j< 100; j+=1)               vertex(i,0,j);      angle+=10;      if(angle>=360) angle=0;   }while(!kbhit());	getch();   closegraph();   return 0;}`

this code is for isometric projection, can anyone help me to turn it to perspective projection?

or maybe ones called that Mode7.

## Create an account

Register a new account