#ifndef LWOOBJ_HPP
#define LWOOBJ_HPP

#include <afxwin.h>
#include <math.h>
#include <gl/gl.h>


#include <string>
#include <fstream>
using namespace std;

#include "..\objRtg\rtgLoader.hpp"


void gluPerspective( float fovy, float aspect, float zNear, float zFar );
/*
// colour
typedef struct RGB_t {
	SHORT r;
	SHORT g;
	SHORT b;
} COL;

// vertex
typedef struct VEC8_t {
	float x;
	float y;
} VEC8;

// vertex
typedef struct VEC12_t {
	float x;
	float y;
	float z;
} VEC12;

// vertex & alpha
typedef struct VEC16_t {
	float x;
	float y;
	float z;
	float a;
} VEC16;

// polygon
typedef struct POLY_t {
	int pointCount;
	short surfaceId;
	short *point;
	VEC12 center;
	VEC12 normal;
} POLY;


// short scaled percentage 0 .. 256  ( must be 2 bytes! )
typedef short IP2;

// float scaled percentage  0.0 .. 100.0 ( must be 4 bytes )
typedef float FP4;

// degrees
typedef float DEG4;

// surface attributes
typedef struct SURF_T {
	string name;	
	COL col;
	short flag;
	short diff;
	// ........
	// ignored all other attributes!! not useful for now
} SURF;

*/
class lwo {
private:
	string path;
	string filename;
	string fileabs;
	int filesize;
	char *data;

//protected:
public:
	// polygons an array of POLY[polyCount]
	int polyCount;
	POLY *poly;

	// 3D vectors an array of VEC12[vecCount]
	int	vecCount;
	VEC12 *v;

	// surface names an array of strings[surfCount]
	int		surfNameCount;
	string *surfName;

	// various surface attributes
	//int surfCount;
	SURF *surfAttrib;

public:
	char ready;	// null object or loaded and usable

	// construct destruct
	lwo ();
	~lwo ();
	// load lwo object
	int load ( string pth, string fnme );

	// format raw data to a usable state
	int format ( char *d);
		// format helper functions, do not call them on is own
		void getsurfacenames	(char *mem, int length);
		void getpoints			(char *mem, int length);
		void getpoly			(char *mem, int length);
		void getSurfAttrib		(char *mem, int length);
		void calcPoly			(void);	// precalc polygon centers and normals


		void makeWave ( int x, int y, char *name, float meshWidth, float meshHeight);

};







#endif