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 | GenerateEdgeLists,
|
---|
45 | GenerateTangents,
|
---|
46 | UseFixedMethod,
|
---|
47 | ExportMaterials,
|
---|
48 | RenameMaterials,
|
---|
49 | UseInteractiveMethod,
|
---|
50 | UseObjectMethod,
|
---|
51 | UsePrefixMethod,
|
---|
52 | ExportSkeleton,
|
---|
53 | HasNormals,
|
---|
54 | MakeNewSubMesh,
|
---|
55 | LinearCopy
|
---|
56 | };
|
---|
57 |
|
---|
58 | #define NUMFLAGS 17
|
---|
59 |
|
---|
60 | class Lwo2MeshWriter
|
---|
61 | {
|
---|
62 | public:
|
---|
63 | bool writeLwo2Mesh(lwObject *nobject, char *ndest);
|
---|
64 | private:
|
---|
65 | void prepLwObject(void);
|
---|
66 |
|
---|
67 | void doExportMaterials(void);
|
---|
68 |
|
---|
69 | Skeleton *doExportSkeleton(const String &skelName, int layer);
|
---|
70 |
|
---|
71 | VertexData *setupVertexData(unsigned short vertexCount, VertexData *oldVertexData = 0, bool deleteOldVertexData = true);
|
---|
72 | void copyPoints(int surfaceIndex, unsigned long polygontype, vpoints &sourcepoints, vpoints &destpoints);
|
---|
73 | void copyPolygons(int surfaceIndex, unsigned long polygontype, vpolygons &sourcepolygons, vpolygons &destpolygons);
|
---|
74 | void copyDataToVertexData(vpoints &points,
|
---|
75 | vpolygons &polygons,
|
---|
76 | vvmaps &vmaps,
|
---|
77 | IndexData *indexData,
|
---|
78 | VertexData *vertexData,
|
---|
79 | unsigned short vertexDataOffset = 0);
|
---|
80 |
|
---|
81 | inline int getPointIndex(lwPoint *point, vpoints &points);
|
---|
82 | inline void getTextureVMaps(vtextures &textures, vvmaps &svmaps, vvmaps &dvmaps);
|
---|
83 |
|
---|
84 | inline String makeLayerFileName(char* dest, unsigned int l, char *layername);
|
---|
85 | inline String makeMaterialFileName(char* dest);
|
---|
86 |
|
---|
87 | char *dest;
|
---|
88 | lwObject *object;
|
---|
89 | MeshPtr ogreMesh;
|
---|
90 |
|
---|
91 | unsigned int nLayers;
|
---|
92 | unsigned int nSurfaces;
|
---|
93 |
|
---|
94 | unsigned int numPolygons;
|
---|
95 | unsigned int *numLayerPolygons;
|
---|
96 | unsigned int *numLayerSurfacePolygons;
|
---|
97 | unsigned int *numSurfacePolygons;
|
---|
98 |
|
---|
99 | unsigned int vertexCount;
|
---|
100 | unsigned int *numLayerVertices;
|
---|
101 | unsigned int *numLayerSurfaceVertices;
|
---|
102 | unsigned int *numSurfaceVertices;
|
---|
103 | };
|
---|
104 |
|
---|
105 | #endif // _LWO2MESH_H_
|
---|
106 |
|
---|