bon tout d' abord voila ma source, je l' ai faite a l' arrache a partir de 2 ou 3 tuts ke j' a v lu, donc vous verrez kelle est pas du tout optimisee :-) :
/////////////////////////////////////////////////////////////////
#include <conio.h>
char * screen =(char*)(0xA0000000L);
void setmode(int mode)
{
asm{
MOV AX, mode
INT 0x10
}
}
void putpixel(int X, int Y, char color)
{
screen [320*Y+X]=color;
}
typedef struct tri
{
float x,y,z;
};
typedef struct bi
{
int x,y;
};
tri c[8] = {
{ 1.0, 1.0, 1.0 },
{ -1.0, 1.0, 1.0 },
{ -1.0, -1.0, 1.0 },
{ 1.0, -1.0, 1.0 },
{ 1.0, 1.0, -1.0 }, <<<
{ -1.0, 1.0, -1.0 }, <<< LE PB EST { -1.0, -1.0, -1.0 }, <<< ICI
{ 1.0, -1.0, -1.0 } <<<
};
bi cube[8] =
{
{ 160+200*c[0].x/c[0].z, 100+200*c[0].y/c[0].z},
{ 160+200*c[1].x/c[1].z, 100+200*c[1].y/c[1].z},
{ 160+200*c[2].x/c[2].z, 100+200*c[2].y/c[2].z},
{ 160+200*c[3].x/c[3].z, 100+200*c[3].y/c[3].z},
{ 160+200*c[4].x/c[4].z, 100+200*c[4].y/c[4].z},
{ 160+200*c[5].x/c[5].z, 100+200*c[5].y/c[5].z},
{ 160+200*c[6].x/c[6].z, 100+200*c[6].y/c[6].z},
{ 160+200*c[7].x/c[7].z, 100+200*c[7].y/c[7].z}
};
void main()
{
setmode (0x13);
putpixel (cube[0].x, cube[0].y, 50);
putpixel (cube[1].x, cube[1].y, 50);
putpixel (cube[2].x, cube[2].y, 50);
putpixel (cube[3].x, cube[3].y, 50);
putpixel (cube[4].x, cube[4].y, 50);
putpixel (cube[5].x, cube[5].y, 50);
putpixel (cube[6].x, cube[6].y, 50);
putpixel (cube[7].x, cube[7].y, 50);
getch();
}
/////////////////////////////////////////////////////////////////
Tout cela marche tres bien (TC++ 3.0 DOS represent ;-), mis a part kil n' y a aucune perspective.En effet, on n' appercoit ke 4 points (ki en sont donc chacun 2 superpose ....). Le probleme vient d nombres indique dans la source, car kan je met la une valeur positive different de 1, g un effet de perspective nikel. Ke faire pour ke mon "moteur" accepte les coordones Z negatifs ???? Merci d' avance (je compte sur toa rainckill ;-)