1 | /*
|
---|
2 | Lwo2MeshWriter based on the MilkShape exporter
|
---|
3 | Dennis Verbeek (dennis.verbeek@chello.nl)
|
---|
4 |
|
---|
5 | Linux port by Magnus Møller Petersen (magnus@moaner.dk]
|
---|
6 |
|
---|
7 | doExportSkeleton is unfinished
|
---|
8 | */
|
---|
9 |
|
---|
10 | #ifndef _LWO2MESH_H_
|
---|
11 | #define _LWO2MESH_H_
|
---|
12 |
|
---|
13 | #include "lwObject.h"
|
---|
14 | #include "Ogre.h"
|
---|
15 |
|
---|
16 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
---|
17 |
|
---|
18 | /* GNU libc has no equivalent to _splitpath() and _makepath(), so we'll write my
|
---|
19 | * own using a combination of string functions and dirname() / basname().
|
---|
20 | */
|
---|
21 |
|
---|
22 | // I've pulled the following values from the top of my head.
|
---|
23 | #define _MAX_DRIVE 256
|
---|
24 | #define _MAX_FNAME 256
|
---|
25 | #define _MAX_DIR 256
|
---|
26 | #define _MAX_EXT 256
|
---|
27 |
|
---|
28 | // Function prototypes.
|
---|
29 | void _splitpath( const char *_fn, char *_drive, char *_dir, char *_node, char *_ext );
|
---|
30 | void _makepath( char *_fn, const char *_drive, const char *_dir, const char *_node,
|
---|
31 | const char *_ext );
|
---|
32 |
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | using namespace Ogre;
|
---|
36 |
|
---|
37 | enum Parameters
|
---|
38 | {
|
---|
39 | InfoOnly,
|
---|
40 | PrintVMaps,
|
---|
41 | UseSharedVertexData,
|
---|
42 | UseSeparateLayers,
|
---|
43 | GenerateLOD,
|
---|
44 | UseFixedMethod,
|
---|
45 | ExportMaterials,
|
---|
46 | RenameMaterials,
|
---|
47 | UseInteractiveMethod,
|
---|
48 | UseObjectMethod,
|
---|
49 | UsePrefixMethod,
|
---|
50 | ExportSkeleton,
|
---|
51 | HasNormals,
|
---|
52 | MakeNewSubMesh,
|
---|
53 | LinearCopy
|
---|
54 | };
|
---|
55 |
|
---|
56 | #define NUMFLAGS 15
|
---|
57 |
|
---|
58 | class Lwo2MeshWriter
|
---|
59 | {
|
---|
60 | public:
|
---|
61 | bool writeLwo2Mesh(lwObject *nobject, char *ndest);
|
---|
62 | private:
|
---|
63 | void prepLwObject(void);
|
---|
64 |
|
---|
65 | void doExportMaterials(void);
|
---|
66 |
|
---|
67 | Skeleton *doExportSkeleton(const String &skelName, int layer);
|
---|
68 |
|
---|
69 | VertexData *setupVertexData(unsigned short vertexCount, VertexData *oldVertexData = 0, bool deleteOldVertexData = true);
|
---|
70 | void copyPoints(int surfaceIndex, unsigned long polygontype, vpoints &sourcepoints, vpoints &destpoints);
|
---|
71 | void copyPolygons(int surfaceIndex, unsigned long polygontype, vpolygons &sourcepolygons, vpolygons &destpolygons);
|
---|
72 | void copyDataToVertexData(vpoints &points,
|
---|
73 | vpolygons &polygons,
|
---|
74 | vvmaps &vmaps,
|
---|
75 | IndexData *indexData,
|
---|
76 | VertexData *vertexData,
|
---|
77 | unsigned short vertexDataOffset = 0);
|
---|
78 |
|
---|
79 | inline int getPointIndex(lwPoint *point, vpoints &points);
|
---|
80 | inline void getTextureVMaps(vtextures &textures, vvmaps &svmaps, vvmaps &dvmaps);
|
---|
81 |
|
---|
82 | inline String makeLayerFileName(char* dest, unsigned int l, char *layername);
|
---|
83 | inline String makeMaterialFileName(char* dest);
|
---|
84 |
|
---|
85 | char *dest;
|
---|
86 | lwObject *object;
|
---|
87 | Mesh* ogreMesh;
|
---|
88 |
|
---|
89 | unsigned int nLayers;
|
---|
90 | unsigned int nSurfaces;
|
---|
91 |
|
---|
92 | unsigned int numPolygons;
|
---|
93 | unsigned int *numLayerPolygons;
|
---|
94 | unsigned int *numLayerSurfacePolygons;
|
---|
95 | unsigned int *numSurfacePolygons;
|
---|
96 |
|
---|
97 | unsigned int vertexCount;
|
---|
98 | unsigned int *numLayerVertices;
|
---|
99 | unsigned int *numLayerSurfaceVertices;
|
---|
100 | unsigned int *numSurfaceVertices;
|
---|
101 | };
|
---|
102 |
|
---|
103 | #endif // _LWO2MESH_H_
|
---|
104 |
|
---|