105 lines
3.8 KiB
C++
105 lines
3.8 KiB
C++
//------------------------------------------------------------------------------
|
||
#ifndef object3dH
|
||
#define object3dH
|
||
//------------------------------------------------------------------------------
|
||
//#include <Classes.hpp>
|
||
//#include <Controls.hpp>
|
||
//#include <StdCtrls.hpp>
|
||
//#include <Forms.hpp>
|
||
//#include <GL/glu.h>
|
||
//#include "texture.h"
|
||
#include "structs.h"
|
||
|
||
//------------------------------------------------------------------------------
|
||
//Материал для фейсов
|
||
class TTriMat
|
||
{
|
||
private:
|
||
protected:
|
||
public:
|
||
char name[20];
|
||
char imgpath[20];
|
||
unsigned int textureid;
|
||
RfColorRGBA ColorAmbientRGB;
|
||
RfColorRGBA ColorDiffuseRGB;
|
||
RfColorRGBA ColorSpecularRGB;
|
||
float USCALE,VSCALE;
|
||
|
||
TTriMat();
|
||
void Release();
|
||
};
|
||
//------------------------------------------------------------------------------
|
||
//для разбивки объекта по материалам
|
||
struct RMatFaces
|
||
{
|
||
char *name; //название материала
|
||
unsigned short count; //кол-во
|
||
unsigned short *faces; //номера фейсов принадлежащие данному материалу
|
||
};
|
||
//------------------------------------------------------------------------------
|
||
//3d модель из треугольников
|
||
class TTriangles
|
||
{
|
||
private:
|
||
protected:
|
||
public:
|
||
unsigned short countMF;
|
||
RMatFaces *MatFaces;
|
||
bool del;
|
||
|
||
RfPointXYZ MinPointXYZ,MaxPointXYZ,PointXYZCenter; //координаты краёв параллелипипида (для отсечения в плоскости XY)
|
||
TTriMat* TriMat;
|
||
|
||
char name[20]; //название обьекта ASCII
|
||
bool bInit,bSmooth;
|
||
unsigned int vbov,vbon,vbot,vbof; //вершины,нормали,текстура,рёбра
|
||
|
||
RfPointXYZ *Vertices; //массив точек
|
||
RfPointXYZ *SmoothNormals; // Массив сглаживающих нормалей (для каждой точки)
|
||
RfPointXY *TexVertices; //координаты текстуры для каждой точки
|
||
RsFacesABC *faces; //3х угольник из граней
|
||
|
||
unsigned int *SmoothG; //массив сглаживающих групп (их всего 32 по количеству бит в беззнаковом int)
|
||
|
||
unsigned int CountVertex; //количество вершин (и координат текстуры и нормалей)
|
||
unsigned int CountFaces; //количество граней
|
||
//unsigned int countMapPoint;
|
||
|
||
TTriangles();//конструктор
|
||
virtual ~TTriangles();
|
||
void render();
|
||
void CalcSmoothNormals(); //просчитать сглаживающие нармали к поверхности
|
||
void CalcMinMaxPoint();
|
||
void cutOnSmoothGroup(); //добавить(разрезать) точки по номеру сглаживающей группы
|
||
//резка обьекта по материалу будет производиться родителем потому что создаються новые обьекты TTriangles
|
||
void AddMaterial(char *name,unsigned short wnum,unsigned short *faces); //название материала,колво элементов, список фейсов с этим материалом
|
||
};
|
||
//------------------------------------------------------------------------------
|
||
//набор 3d моделей из 3х угольников
|
||
class TTrianglesList
|
||
{
|
||
private:
|
||
protected:
|
||
unsigned int count;
|
||
TTriangles **List;
|
||
unsigned int countMat;
|
||
TTriMat **ListMat;
|
||
public:
|
||
RfPointXYZ MinPointXYZ,MaxPointXYZ,CenterPointXYZ;
|
||
|
||
TTrianglesList();//конструктор
|
||
virtual ~TTrianglesList();
|
||
TTriangles* Add();
|
||
void DelTri(TTriangles* tri);
|
||
TTriMat* AddMat();
|
||
void render();
|
||
void CalcSmoothNormals();
|
||
void CalcMinMaxPoint();
|
||
void cutOnSmoothGroup();
|
||
void cutOnMaterials(); //разркзать обьект по материалу
|
||
TTriMat *FindMatOnName(char *name);
|
||
};
|
||
//------------------------------------------------------------------------------
|
||
#endif
|
||
|