Реферат: Трехмерная графика Теория

{

}

// Other functions

int IsVisible ( const Polygon& Poly, const Vector& PrCenter )

{

return ( Poly.Normal & ( PrCenter - Poly.Point[0] )) < 0 || Poly.TwoSides;

}

void DrawBSPTree ( BSPNode * Tree, const Vector& PrCntr )

{

if (( Tree -> Poly -> Normal & PrCntr ) > Tree -> d ) {

if ( Tree -> Right != NULL ) DrawBSPTree ( Tree -> Right, PrCntr );

Tree -> Poly -> Draw ( PrCntr );

if ( Tree -> Left != NULL ) DrawBSPTree ( Tree -> Left, PrCntr );

}

else {

if ( Tree -> Left != NULL ) DrawBSPTree ( Tree -> Left, PrCntr );

Tree -> Poly -> Draw ( PrCntr );

if ( Tree -> Right != NULL ) DrawBSPTree ( Tree -> Right, PrCntr );

}

}

Далее представлена демонстрационная программа, которая выполняет все вышеперечисленные операции с тетраэдром.

//Файл 3dgame.cpp

#include <dos.h>#include <graphics.h>#include <math.h>

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include "3dworks.h"

void DrawObject ( GrObject* Obj, const Vector& v )

{

К-во Просмотров: 1899
Бесплатно скачать Реферат: Трехмерная графика Теория