Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
3D проектирование и освещение / Лабораторная работа №4.doc
Скачиваний:
54
Добавлен:
01.05.2014
Размер:
180.74 Кб
Скачать

Текст программы и пояснение некоторых функций

Для описания точки в пространстве использовалась структура Vector3D, которая имеет следующие поля: x, y, z – координаты точки в пространстве, S – глубина пространственной точки.

Для описания точки на плоскости использовалась структура Vector2D, которая имеет следующие поля: x, y – координаты точки на плоскости, h – глубина точки.

Буфер глубины организован в оперативной памяти. Для осуществления вывода изображения на экран функция Draw( ) преобразует значения h, хранящиеся в буфере глубины, в яркости, зависящие от удаленности объекта от наблюдателя, и выводит соответствующие точкам значения яркости на экран.

#include <bios.h>

#include <conio.h>

#include <dos.h>

#include <math.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define Hmax 255

#define Smin 5

#define Smax 180

#define OBJECTNUM 3

#define Rot1(_q,_e,A,B) { ClearZ();for(o=0;o<OBJECTNUM;o++)if(o==1) {for (i=0; i<n; i++)\

{ j=T[o][i].A; T[o][i].A=j*cos(PI/180) _q T[o][i].B*sin(PI/180);\

T[o][i].B=T[o][i].B*cos(PI/180) _e j*sin(PI/180); }} Draw(); }

#define Rot2(_q,_e) { ClearZ();for(o=0;o<OBJECTNUM;o++)if(o==1) { for (i=0; i<n; i++)\

{ j=T[o][i].x; T[o][i].x=j*cos(PI/180) _q T[o][i].z*sin(PI/180);\

T[o][i].z=T[o][i].z*cos(PI/180) _e j*sin(PI/180);\

j=T[o][i].y; T[o][i].y=j*cos(PI/180) _q T[o][i].z*sin(PI/180);\

T[o][i].z=T[o][i].z*cos(PI/180) _e j*sin(PI/180);\

j=T[o][i].x; T[o][i].x=j*cos(PI/180) _q T[o][i].y*sin(PI/180);\

T[o][i].y=T[o][i].y*cos(PI/180) _e j*sin(PI/180);}} Draw(); }

#define Del 0x5300

#define PgDown 0x5100

#define PgUp 0x4900

#define CtrlL 0x7400

#define CtrlR 0x7300

#define FPlus 0x4E2B

#define FMinus 0x4A2D

#define Home 0x4700

#define Up 0x4800

#define Left 0x4B00

#define Right 0x4D00

#define End 0x4F00

#define Down 0x5000

#define Esc 0x011B

#define F1 0x3B00

#define F2 0x3C00

#define F3 0x3D00

#define F4 0x3E00

#define F5 0x3F00

#define F6 0x4000

#define F7 0x4100

#define F8 0x4200

#define F9 0x4300

#define F10 0x4400

#define K1 0x0231

#define K2 0x0332

#define K3 0x0433

#define K4 0x0534

#define K5 0x0635

#define K6 0x0736

#define K7 0x0837

#define K8 0x0938

#define K9 0x0A39

#define K0 0x0B30

#define PI 3.14159265

////////////////////////////////////////////////////////////////////////////

typedef struct V3D

{ float x, y, z, S;

} Vector3D;

typedef struct V2D

{ int x, y;

unsigned char h;

} Vector2D;

typedef struct facet

{ int np;

int p[12];

} Facet;

////////////////////////////////////////////////////////////////////////////

FILE *stream;

int end;

Vector3D T[OBJECTNUM][50], Axes[OBJECTNUM][4];

Vector2D U[OBJECTNUM][50], Top[OBJECTNUM][12], Axes2[OBJECTNUM][4];

Facet facets[OBJECTNUM][10];

float A, B, xu[OBJECTNUM], yu[OBJECTNUM], zu[OBJECTNUM], xp[OBJECTNUM];

float yp[OBJECTNUM], zp[OBJECTNUM], xl[OBJECTNUM], yl[OBJECTNUM];

float zl[OBJECTNUM], f[OBJECTNUM];

float EdgeTable[OBJECTNUM][40][6], ActiveEdgeTable[OBJECTNUM][40][5];

int n,Relation[OBJECTNUM][50][50], RelationAxes[OBJECTNUM][4][4], axes, gr;

int mgr[10]={1,1,1,1,1,1,1,1,1,1},wire=1;

unsigned char far ZBuffer[320][200];

////////////////////////////////////////////////////////////////////////////

//Set the video mode 320X200X256c

void setVideoMode(int mode) {

_asm { mov ax,mode; int 10h; }

}

////////////////////////////////////////////////////////////////////////////

// Set the palette to 256 colors gradation of blue

void Palette(void)

{

int i;

outp(0x3C8, 0x00);

for (i = 0; i < 256; i++)

{

outp(0x3C9, 0);

outp(0x3C9, 0);

outp(0x3C9, i+256);

}

}

////////////////////////////////////////////////////////////////////////////

//Get a user choice

int GetOption(void)

{

int i=0;

while (!i)

if (kbhit())

i=bioskey(0);

return i;

}

////////////////////////////////////////////////////////////////////////////

//returns the maximum of two numbers

float Max(float x, float y)

{ return x>y? x: y; }

////////////////////////////////////////////////////////////////////////////

//returns the abolute value of a number

float Abs(float x)

{ return x<0? -x: x; }

////////////////////////////////////////////////////////////////////////////

//Reads a number from the object file

int GetNumber(void)

{ int p=0;

char s[4];

do

s[p++]=fgetc(stream);

while(s[p-1]!=',' && s[p-1]!='=' && s[p-1]!=0x0D);

end=s[p-1]==0x0D? 1: 0;

s[p-1]=0;

return atoi(s);

}

////////////////////////////////////////////////////////////////////////////

//Reads a digit from the object file

int GetDigit(void)

{ char s[2];

s[0]=fgetc(stream);

s[1]=0;

return atoi(s);

}

////////////////////////////////////////////////////////////////////////////

//Sorting the table of edgies

void OrderEdgeTable(int n)

{ int i, j, k, m, q;

float a, b;

for (int o=0; o<OBJECTNUM; o++){

for (i=0; i<n-1; i++)

for (j=i; j<n; j++)

if (EdgeTable[o][i][0]>EdgeTable[o][j][0])

for (k=0; k<5; k++)

{ a=EdgeTable[o][i][k];

EdgeTable[o][i][k]=EdgeTable[o][j][k];

EdgeTable[o][j][k]=a;

}

b=EdgeTable[o][0][0];

for (a=i=0; i<n; i++)

{ if (b!=EdgeTable[o][i][0]) a++;

EdgeTable[o][i][5]=a;

b=EdgeTable[o][i][0];

}

for (m=q=b=0; b<k+1; b++)

{ m=q;

for (i=m; i<n; i++)

if (EdgeTable[o][i][5]!=b)

{ q=i;

break;

}

for (i=m; i<q-1; i++)

for (j=i; j<q; j++)

if (EdgeTable[o][i][2]>EdgeTable[o][j][2])

for (k=0; k<5; k++)

{ a=EdgeTable[o][i][k];

EdgeTable[o][i][k]=EdgeTable[o][j][k];

EdgeTable[o][j][k]=a;

}

}

}

}

////////////////////////////////////////////////////////////////////////////

//Sorting the table of active edgies

void OrderActiveEdgeTable(int n)

{ int i, j, k;

float a;

for (int o=0; o<OBJECTNUM; o++){

for (i=0; i<n-1; i++)

for (j=i; j<n; j++)

if (ActiveEdgeTable[o][i][2]>ActiveEdgeTable[o][j][2])

for (k=0; k<5; k++)

{ a=ActiveEdgeTable[o][i][k];

ActiveEdgeTable[o][i][k]=ActiveEdgeTable[o][j][k];

ActiveEdgeTable[o][j][k]=a;

}

}

}

////////////////////////////////////////////////////////////////////////////

//Adding an edge to the table of active edgies

int AddGroupActiveEdgeTable(int i, int na, int n, int o)

{ int k, j, a=0;

for (j=i; j<n; j++)

if (EdgeTable[o][j][5]==EdgeTable[o][i][5]) a++;

for (j=0; j<a; j++, na++)

for (k=0; k<5; k++)

ActiveEdgeTable[o][na][k]=EdgeTable[o][i+j][k];

return na;

}

////////////////////////////////////////////////////////////////////////////

//Get the intersections

int CrossTop(Vector2D *t, int n, int x, int y)

{ int i;

for (i=0; i<n; i++)

if (t[i].x==x && t[i].y==y)

if ((y<t[i? i-1: n-1].y && y<t[i<n-1? i+1: 0].y) ||

(y>=t[i? i-1: n-1].y && y>=t[i<n-1? i+1: 0].y))

return 1;

return 0;

}

////////////////////////////////////////////////////////////////////////////

// Write a pixel to the Z buffer

void WriteZ(int x, int y, unsigned char h)

{ if (x>=0 && x<320 && y>=0 && y<200)

if (ZBuffer[x][y] <= h)

ZBuffer[x][y]=h;

}

////////////////////////////////////////////////////////////////////////////

//Get the intensity of a pixel (depends on it's deeph)

unsigned int Bright(int h)

{ int v;

v=h%Hmax;

v=(v<1)? 0: v;

v=v>255? 255: v;

return v;

}

////////////////////////////////////////////////////////////////////////////

// Copy the image to the screen

void ShowZ(void)

{ int x, y;

for (y=0; y<200; y++)

for (x=0; x<320; x++)

pokeb(0xA000, 320*y+x, ZBuffer[x][y]? Bright(ZBuffer[x][y]): 0);

}

////////////////////////////////////////////////////////////////////////////

//Draws a line in Z buffer

void Line(Vector2D a, Vector2D b)

{ float h, dh, dx, dy, x, y, i, w;

x=a.x; y=a.y; h=a.h;

w=Max(Abs(b.x-a.x), Abs(b.y-a.y));

dh=w? (b.h-a.h)/w: a.h;

if (!w)

WriteZ(x, y, h);

else

{ dx=Abs(b.x-a.x)/w;

dy=Abs(b.y-a.y)/w;

if (b.x<a.x) dx=-dx;

if (b.y<a.y) dy=-dy;

for (i=0; i<w; i++)

{ WriteZ(x, y, h);

x+=dx; y+=dy; h+=dh;

}

}

}

////////////////////////////////////////////////////////////////////////////

//Gets the H

float H(float y1, float y2, float y,int o)

{ int i, j, a, b;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

if (U[o][i].y==y1 && U[o][j].y==y2 && Relation[o][i][j])

{ a=i; b=j; j=n; i=n;}

return U[o][a].h+(U[o][b].h-U[o][a].h)*(y-y1)/(y2-y1);

}

////////////////////////////////////////////////////////////////////////////

// Fill a polygon with string scanning method

void FillPoly(Vector2D *t, int q)

{ int i, j, na, p, a, b;

float Y, Ymax, k, h1, h2, h, dh;

for(int o=0;o<OBJECTNUM;o++){

for (na=i=0; i<q; i++) // Init the EdgeTable

{ j=i>q-2? 0: i+1;

EdgeTable[o][i][0]=t[i].y<t[j].y? t[i].y: t[j].y;

EdgeTable[o][i][1]=t[i].y>t[j].y? t[i].y: t[j].y;

EdgeTable[o][i][2]=t[i].y==EdgeTable[o][i][0]? t[i].x: t[j].x;

EdgeTable[o][i][3]=t[i].y!=EdgeTable[o][i][0]? t[i].x: t[j].x;

EdgeTable[o][i][4]=(EdgeTable[o][i][3]-EdgeTable[o][i][2])/((EdgeTable[o][i][1]-EdgeTable[o][i][0])? EdgeTable[o][i][1]-EdgeTable[o][i][0]: 1);

}

OrderEdgeTable(q);

Y=EdgeTable[o][0][0];

for (Ymax=i=0; i<q; i++)

Ymax=EdgeTable[o][i][1]>Ymax? EdgeTable[o][i][1]: Ymax;

do

{ for (i=0; i<q; i++)

if (Y==EdgeTable[o][i][0])

{ na=AddGroupActiveEdgeTable(i, na, q,o);

break;

}

OrderActiveEdgeTable(na);

if (ActiveEdgeTable[o][0][0]==ActiveEdgeTable[o][0][1] && ActiveEdgeTable[o][1][0]==ActiveEdgeTable[o][1][1])

break;

if (ActiveEdgeTable[o][0][0]==ActiveEdgeTable[o][1][1] ||

(ActiveEdgeTable[o][1][0]==ActiveEdgeTable[o][0][1] && ActiveEdgeTable[o][0][0]!=ActiveEdgeTable[o][0][1]))

{ h1=H(ActiveEdgeTable[o][0][0], ActiveEdgeTable[o][0][1], Y,o);

h2=H(ActiveEdgeTable[o][2][0], ActiveEdgeTable[o][2][1], Y,o);

}

else

{ if (ActiveEdgeTable[o][0][0]==ActiveEdgeTable[o][0][1])

h1=H(ActiveEdgeTable[o][1][0], ActiveEdgeTable[o][1][1], Y,o);

else

h1=H(ActiveEdgeTable[o][0][0], ActiveEdgeTable[o][0][1], Y,o);

if (ActiveEdgeTable[o][1][0]==ActiveEdgeTable[o][1][1])

h2=H(ActiveEdgeTable[o][2][0], ActiveEdgeTable[o][2][1], Y,o);

else

h2=H(ActiveEdgeTable[o][1][0], ActiveEdgeTable[o][1][1], Y,o);

}

for (i=0; i<na-1; i++)

if ((Y==ActiveEdgeTable[o][i][1] && Y==ActiveEdgeTable[o][i+1][0]) || (Y==ActiveEdgeTable[o][i][0] && Y==ActiveEdgeTable[o][i+1][1]))

{ ActiveEdgeTable[o][i][2]=(int)(ActiveEdgeTable[o][i][2]+.5);

ActiveEdgeTable[o][i+1][2]=(int)(ActiveEdgeTable[o][i+1][2]+.5);

}

for (p=i=0; i<na-1; i++)

{ a=ActiveEdgeTable[o][i][2]; b=ActiveEdgeTable[o][i+1][2];

h=h1;

if (a!=b)

dh=(h2-h1)/(b-a);

if (a!=b && !CrossTop(t, q, a+.5, Y))

p=!p;

if (p)

for (k=a; k<b; k+=.9, h+=dh)

WriteZ(k+.5, Y, h);

}

for (i=0; i<na; i++)

if (Y==ActiveEdgeTable[o][i][1])

{ for (j=0; j<5; j++)

ActiveEdgeTable[o][i][j]=ActiveEdgeTable[o][na-1][j];

na--; i=-1;

}

for (i=0; i<na; i++)

ActiveEdgeTable[o][i][2]+=ActiveEdgeTable[o][i][4];

Y++;

}

while (Y<Ymax);

}

}

////////////////////////////////////////////////////////////////////////////

//clear the Z contents

void ClearZ(void)

{ int x, y;

for (y=0; y<200; y++)

for (x=0; x<320; x++)

ZBuffer[x][y]=0;

}

////////////////////////////////////////////////////////////////////////////

//Draw the image

void Draw(void)

{ int i, j;

float a, b, c, d, l, a1, a2, a3, b1, b2, b3, c2, c3, lxy;

for(int o=0;o<OBJECTNUM;o++){

xu[o]=xp[o]-xl[o]; yu[o]=yp[o]-yl[o]; zu[o]=zp[o]-zl[o];

lxy=sqrt(xu[o]*xu[o]+yu[o]*yu[o]); l=sqrt(xu[o]*xu[o]+yu[o]*yu[o]+zu[o]*zu[o]);

a1=-yu[o]/lxy; a2=-xu[o]*zu[o]/(l*lxy); a3=xu[o]/l; b1=xu[o]/lxy;

b2=-yu[o]*zu[o]/(l*lxy); b3=yu[o]/l; c2=lxy/l; c3=zu[o]/l;

for (i=0; i<n; i++)

{ a=T[o][i].x-xp[o]; b=T[o][i].y-yp[o]; c=T[o][i].z-zp[o];

d=a*a3+b*b3+c*c3;

T[o][i].S=-d;

U[o][i].x=-f[o]*(a*a1+b*b1)/d+160;

U[o][i].y=-f[o]*(a*a2+b*b2+c*c2)/d+100;

U[o][i].h=(int)A/T[o][i].S-B;

}

for (i=0; i<n; i++)

for (j=i+1; j<n; j++)

if (Relation[o][i][j])

if (T[o][i].S >= 0 && T[o][j].S >= 0)

Line(U[o][i], U[o][j]);

if (axes)

{ for (i=0; i<4; i++)

{ a=Axes[o][i].x-xp[o];

b=Axes[o][i].y-yp[o];

c=Axes[o][i].z-zp[o];

d=a*a3+b*b3+c*c3;

Axes[o][i].S=-d;

Axes2[o][i].x=-f[o]*(a*a1+b*b1)/d+160;

Axes2[o][i].y=-f[o]*(a*a2+b*b2+c*c2)/d+100;

}

Axes2[o][0].h=Axes2[o][1].h=Axes2[o][2].h=Axes2[o][3].h=(int)A/Axes[o][0].S-B;

for (i=0; i<4; i++)

for (j=i+1; j<4; j++)

if (RelationAxes[o][i][j])

if (Axes[o][i].S>=0 && Axes[o][j].S>=0)

Line(Axes2[o][i], Axes2[o][j]);

}

for (i=0; i<gr; i++)

if (mgr[i])

{ for (j=0; j<facets[o][i].np; j++)

Top[o][j]=U[o][facets[o][i].p[j]];

FillPoly(Top[o], facets[o][i].np);

}

}

ShowZ();

}

////////////////////////////////////////////////////////////////////////////

void Menu(int k)

{ int i;

float j,o;

switch (k)

{ case FPlus: { ClearZ();for(i=0;i<OBJECTNUM;i++)f[i]+=3; Draw(); } break; // Increase focus

case FMinus: { ClearZ();for(i=0;i<OBJECTNUM;i++){f[i]=f[i]>2? f[i]-3: f[i];} Draw(); } break; // Decrease focus

case Home: { ClearZ();for(i=0;i<OBJECTNUM;i++){zp[i]=zp[i]<-26? zp[i]+3: zp[i]; zl[i]=zl[i]<43? zl[i]+3: zl[i];} Draw(); } break; //Come in

case End: { ClearZ();for(i=0;i<OBJECTNUM;i++){zp[i]=zp[i]>-180? zp[i]-3: zp[i]; zl[i]=zl[i]>-110? zl[i]-3: zl[i];} Draw(); } break; //Go out

case Down: { ClearZ();yp[0]+=3; yl[0]+=3; Draw(); } break; // Up

case Up: { ClearZ();yp[0]-=3; yl[0]-=3; Draw(); } break; // Down

case Right: { ClearZ();xp[0]-=3; xl[0]-=3; Draw(); } break; // Left

case Left : { ClearZ();xp[0]+=3; xl[0]+=3; Draw(); } break; // Right

case PgDown: { ClearZ();yp[2]+=3; yl[2]+=3; Draw(); } break; // Up

case PgUp: { ClearZ();yp[2]-=3; yl[2]-=3; Draw(); } break; // Down

case CtrlL: { ClearZ();xp[2]-=3; xl[2]-=3; Draw(); } break; // Left

case CtrlR: { ClearZ();xp[2]+=3; xl[2]+=3; Draw(); } break; // Right

case K1: { ClearZ(); mgr[0]=1-mgr[0]; Draw(); } break;

case K2: { ClearZ(); mgr[1]=1-mgr[1]; Draw(); } break;

case K3: { ClearZ(); mgr[2]=1-mgr[2]; Draw(); } break;

case K4: { ClearZ(); mgr[3]=1-mgr[3]; Draw(); } break;

case K5: { ClearZ(); mgr[4]=1-mgr[4]; Draw(); } break;

case K6: { ClearZ(); mgr[5]=1-mgr[5]; Draw(); } break;

case K7: { ClearZ(); mgr[6]=1-mgr[6]; Draw(); } break;

case K8: { ClearZ(); mgr[7]=1-mgr[7]; Draw(); } break;

case K9: { ClearZ(); mgr[8]=1-mgr[8]; Draw(); } break;

case K0: { ClearZ(); mgr[9]=1-mgr[9]; Draw(); } break;

case F2: { ClearZ(); axes=1-axes; Draw(); } break; // On/Off axes

case F3: { while(!kbhit()) Rot1(+,-,x,z) } break;// Right to left rotation

case F4: { while(!kbhit()) Rot1(-,+,x,z) } break;// Left to right rotation

case F5: { while(!kbhit()) Rot1(+,-,y,z) } break;// Up to down rotation

case F6: { while(!kbhit()) Rot1(-,+,y,z) } break;// Down to up rotation

case F7: { while(!kbhit()) Rot1(+,-,x,y) } break;// watch rotation

case F8: { while(!kbhit()) Rot1(-,+,x,y) } break;// vs watch rotation

case F9: { while(!kbhit()) Rot2(+,-) } break;

case F10:{ while(!kbhit()) Rot2(-,+) } break;

case F1:

{ setVideoMode(0x03);;

_setcursortype(_NOCURSOR);

puts(" Key і Description");

puts("ДДДДДДДДДДДДДДДДДЕДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД");

puts(" + , - і Change the focus distance");

puts(" Home і Come in");

puts(" End і Go out");

puts(" Up і Up");

puts(" Down і Down");

puts(" Left і Left");

puts(" Right і Right");

puts(" F2 і On/Off axes");

puts(" F3 і Right to left rotation");

puts(" F4 і Left to right rotation");

puts(" F5 і Up to down rotation");

puts(" F6 і Down to up rotation");

puts(" F7 і Watch rotation");

puts(" F8 і VS watch rotation");

puts(" F9, F10 і Rotate in differente directions");

puts(" 0,...,9 і Show/Hide a facet");

puts(" Del і Wire figure view");

puts(" PgUp і Move the cube up");

puts(" PgDown і Move the cube down");

puts(" Ctrl+Left і Move the cube left");

puts(" Ctrl+Right і Move the cube right");

puts(" Esc і Shutdown");

puts("ДДДДДДДДДДДДДДДДДБДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД");

getch();

setVideoMode(0x13);;

Palette();

Draw();

}

break;

case Del:

wire=!wire;

ClearZ();

if(wire==0) for (o=0; o<10; mgr[o]=0, o++);

else for (o=0; o<10; mgr[o]=1, o++);

Draw();

}

}

////////////////////////////////////////////////////////////////////////////

// Skip x symbols in the object file

void Jump(int x)

{ while (x--)

fgetc(stream);

}

////////////////////////////////////////////////////////////////////////////

//Load data from file

void GetData(int o)

{ int i, k;

Jump(2);

xp[o]=GetNumber(); // Get the watcher coordinates

yp[o]=GetNumber(); // xp, yp, zp

zp[o]=GetNumber();

Jump(3);

xl[o]=GetNumber(); // Get the look at cordinates

yl[o]=GetNumber(); // xl, yl, zl

zl[o]=GetNumber();

Jump(3);

f[o]=GetNumber(); // Get the focus

Jump(1);

n=0;

do // Get the vertexes

{ k=GetNumber(); // Number of points

if (!k) break;

k--;

n++;

T[o][k].x=GetNumber();

T[o][k].y=GetNumber();

T[o][k].z=GetNumber();

Jump(1);

} while (1);

Jump(1);

do // Facets

{ k=GetNumber();

if (!k) break;

k--;

for (facets[o][k].np=0; !end; facets[o][k].p[facets[o][k].np++]=GetNumber()-1);

Jump(1);

gr=k+1;

} while (1);

for (i=0; i<50; i++)

for (k=0; k<50; k++)

Relation[o][i][k]=0;

for (i=0; i<gr; i++)

{ Relation[o][facets[o][i].p[0]][facets[o][i].p[facets[o][i].np-1]]=1;

Relation[o][facets[o][i].p[facets[o][i].np-1]][facets[o][i].p[0]]=1;

for (k=0; k<facets[o][i].np-1; k++)

{ Relation[o][facets[o][i].p[k]][facets[o][i].p[k+1]]=1;

Relation[o][facets[o][i].p[k+1]][facets[o][i].p[k]]=1;

}

}

}

////////////////////////////////////////////////////////////////////////////

void main(void)

{

int k,i;

char buff[10];

char s[80];

int o;

A=(float)Hmax*Smin*Smax/(Smax-Smin);

B=(float)Hmax*Smin/(Smax-Smin);

setVideoMode(0x13);

Palette();

for(o=0;o<OBJECTNUM;o++){

strcpy(s,"Object");

itoa(o+1,buff,10);

strcat(s,buff);

strcat(s,".3d");

if (!(stream=fopen(s, "rb")))

{ fprintf(stderr, "\nCannot open file \"%s\"\n",s);

return;

}

GetData(o);

fclose(stream);

}

Draw();

axes=0;

for(o=0;o<OBJECTNUM;o++){

Axes[o][0].x=Axes[o][0].y=Axes[o][0].z=0;

Axes[o][1].x=Axes[o][1].y=0; Axes[o][1].z=60;

Axes[o][2].x=Axes[o][2].z=0; Axes[o][2].y=60;

Axes[o][3].z=Axes[o][3].y=0; Axes[o][3].x=60;

RelationAxes[o][0][0]=RelationAxes[o][1][1]=RelationAxes[o][2][2]=RelationAxes[o][3][3]=0;

RelationAxes[o][0][1]=RelationAxes[o][0][2]=RelationAxes[o][0][3]=1;

}

Menu(F3);

do

{

k=GetOption();

Menu(k);

}while (k!=Esc);

setVideoMode(0x03);

}

Соседние файлы в папке 3D проектирование и освещение