| 1 | //////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // paramlist.h |
|---|
| 3 | // Author : Francesco Giordana |
|---|
| 4 | // Start Date : January 13, 2005 |
|---|
| 5 | // Copyright : (C) 2006 by Francesco Giordana |
|---|
| 6 | // Email : fra.giordana@tiscali.it |
|---|
| 7 | //////////////////////////////////////////////////////////////////////////////// |
|---|
| 8 | |
|---|
| 9 | /********************************************************************************* |
|---|
| 10 | * * |
|---|
| 11 | * This program is free software; you can redistribute it and/or modify * |
|---|
| 12 | * it under the terms of the GNU Lesser General Public License as published by * |
|---|
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
|---|
| 14 | * (at your option) any later version. * |
|---|
| 15 | * * |
|---|
| 16 | **********************************************************************************/ |
|---|
| 17 | |
|---|
| 18 | #ifndef PARAMLIST_H |
|---|
| 19 | #define PARAMLIST_H |
|---|
| 20 | |
|---|
| 21 | #include "mayaExportLayer.h" |
|---|
| 22 | |
|---|
| 23 | // Length units multipliers from Maya internal unit (cm) |
|---|
| 24 | |
|---|
| 25 | #define CM2MM 10.0 |
|---|
| 26 | #define CM2CM 1.0 |
|---|
| 27 | #define CM2M 0.01 |
|---|
| 28 | #define CM2IN 0.393701 |
|---|
| 29 | #define CM2FT 0.0328084 |
|---|
| 30 | #define CM2YD 0.0109361 |
|---|
| 31 | |
|---|
| 32 | namespace OgreMayaExporter |
|---|
| 33 | { |
|---|
| 34 | class Submesh; |
|---|
| 35 | |
|---|
| 36 | typedef struct clipInfoTag |
|---|
| 37 | { |
|---|
| 38 | float start; //start time of the clip |
|---|
| 39 | float stop; //end time of the clip |
|---|
| 40 | float rate; //sample rate of anim curves, -1 means auto |
|---|
| 41 | MString name; //clip name |
|---|
| 42 | } clipInfo; |
|---|
| 43 | |
|---|
| 44 | typedef enum |
|---|
| 45 | { |
|---|
| 46 | NPT_CURFRAME, |
|---|
| 47 | NPT_BINDPOSE |
|---|
| 48 | } NeutralPoseType; |
|---|
| 49 | |
|---|
| 50 | typedef enum |
|---|
| 51 | { |
|---|
| 52 | TS_TEXCOORD, |
|---|
| 53 | TS_TANGENT |
|---|
| 54 | } TangentSemantic; |
|---|
| 55 | |
|---|
| 56 | /***** Class ParamList *****/ |
|---|
| 57 | class ParamList |
|---|
| 58 | { |
|---|
| 59 | public: |
|---|
| 60 | // class members |
|---|
| 61 | bool exportMesh, exportMaterial, exportAnimCurves, exportCameras, exportAll, exportVBA, |
|---|
| 62 | exportVertNorm, exportVertCol, exportTexCoord, exportCamerasAnim, |
|---|
| 63 | exportSkeleton, exportSkelAnims, exportBSAnims, exportVertAnims, exportBlendShapes, |
|---|
| 64 | exportWorldCoords, useSharedGeom, lightingOff, copyTextures, exportParticles, |
|---|
| 65 | buildTangents, buildEdges, skelBB, bsBB, vertBB; |
|---|
| 66 | |
|---|
| 67 | float lum; // Length Unit Multiplier |
|---|
| 68 | |
|---|
| 69 | MString meshFilename, skeletonFilename, materialFilename, animFilename, camerasFilename, matPrefix, |
|---|
| 70 | texOutputDir, particlesFilename; |
|---|
| 71 | |
|---|
| 72 | std::ofstream outMaterial, outAnim, outCameras, outParticles; |
|---|
| 73 | |
|---|
| 74 | MStringArray writtenMaterials; |
|---|
| 75 | |
|---|
| 76 | std::vector<clipInfo> skelClipList; |
|---|
| 77 | std::vector<clipInfo> BSClipList; |
|---|
| 78 | std::vector<clipInfo> vertClipList; |
|---|
| 79 | |
|---|
| 80 | NeutralPoseType neutralPoseType; |
|---|
| 81 | TangentSemantic tangentSemantic; |
|---|
| 82 | |
|---|
| 83 | std::vector<Submesh*> loadedSubmeshes; |
|---|
| 84 | std::vector<MDagPath> currentRootJoints; |
|---|
| 85 | |
|---|
| 86 | // constructor |
|---|
| 87 | ParamList() { |
|---|
| 88 | lum = 1.0; |
|---|
| 89 | exportMesh = false; |
|---|
| 90 | exportMaterial = false; |
|---|
| 91 | exportSkeleton = false; |
|---|
| 92 | exportSkelAnims = false; |
|---|
| 93 | exportBSAnims = false; |
|---|
| 94 | exportVertAnims = false; |
|---|
| 95 | exportBlendShapes = false; |
|---|
| 96 | exportAnimCurves = false; |
|---|
| 97 | exportCameras = false; |
|---|
| 98 | exportParticles = false; |
|---|
| 99 | exportAll = false; |
|---|
| 100 | exportWorldCoords = false; |
|---|
| 101 | exportVBA = false; |
|---|
| 102 | exportVertNorm = false; |
|---|
| 103 | exportVertCol = false; |
|---|
| 104 | exportTexCoord = false; |
|---|
| 105 | exportCamerasAnim = false; |
|---|
| 106 | useSharedGeom = false; |
|---|
| 107 | lightingOff = false; |
|---|
| 108 | copyTextures = false; |
|---|
| 109 | skelBB = false; |
|---|
| 110 | bsBB = false; |
|---|
| 111 | vertBB = false; |
|---|
| 112 | meshFilename = ""; |
|---|
| 113 | skeletonFilename = ""; |
|---|
| 114 | materialFilename = ""; |
|---|
| 115 | animFilename = ""; |
|---|
| 116 | camerasFilename = ""; |
|---|
| 117 | particlesFilename = ""; |
|---|
| 118 | matPrefix = ""; |
|---|
| 119 | texOutputDir = ""; |
|---|
| 120 | skelClipList.clear(); |
|---|
| 121 | BSClipList.clear(); |
|---|
| 122 | vertClipList.clear(); |
|---|
| 123 | neutralPoseType = NPT_CURFRAME; |
|---|
| 124 | buildEdges = false; |
|---|
| 125 | buildTangents = false; |
|---|
| 126 | tangentSemantic = TS_TANGENT; |
|---|
| 127 | loadedSubmeshes.clear(); |
|---|
| 128 | currentRootJoints.clear(); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | ParamList& operator=(ParamList& source) |
|---|
| 132 | { |
|---|
| 133 | int i; |
|---|
| 134 | lum = source.lum; |
|---|
| 135 | exportMesh = source.exportMesh; |
|---|
| 136 | exportMaterial = source.exportMaterial; |
|---|
| 137 | exportSkeleton = source.exportSkeleton; |
|---|
| 138 | exportSkelAnims = source.exportSkelAnims; |
|---|
| 139 | exportBSAnims = source.exportBSAnims; |
|---|
| 140 | exportVertAnims = source.exportVertAnims; |
|---|
| 141 | exportBlendShapes = source.exportBlendShapes; |
|---|
| 142 | exportAnimCurves = source.exportAnimCurves; |
|---|
| 143 | exportCameras = source.exportCameras; |
|---|
| 144 | exportAll = source.exportAll; |
|---|
| 145 | exportWorldCoords = source.exportWorldCoords; |
|---|
| 146 | exportVBA = source.exportVBA; |
|---|
| 147 | exportVertNorm = source.exportVertNorm; |
|---|
| 148 | exportVertCol = source.exportVertCol; |
|---|
| 149 | exportTexCoord = source.exportTexCoord; |
|---|
| 150 | exportCamerasAnim = source.exportCamerasAnim; |
|---|
| 151 | exportParticles = source.exportParticles; |
|---|
| 152 | useSharedGeom = source.useSharedGeom; |
|---|
| 153 | lightingOff = source.lightingOff; |
|---|
| 154 | copyTextures = source.copyTextures; |
|---|
| 155 | skelBB = source.skelBB; |
|---|
| 156 | bsBB = source.bsBB; |
|---|
| 157 | vertBB = source.vertBB; |
|---|
| 158 | meshFilename = source.meshFilename; |
|---|
| 159 | skeletonFilename = source.skeletonFilename; |
|---|
| 160 | materialFilename = source.materialFilename; |
|---|
| 161 | animFilename = source.animFilename; |
|---|
| 162 | camerasFilename = source.camerasFilename; |
|---|
| 163 | particlesFilename = source.particlesFilename; |
|---|
| 164 | matPrefix = source.matPrefix; |
|---|
| 165 | texOutputDir = source.texOutputDir; |
|---|
| 166 | buildEdges = source.buildEdges; |
|---|
| 167 | buildTangents = source.buildTangents; |
|---|
| 168 | tangentSemantic = source.tangentSemantic; |
|---|
| 169 | skelClipList.resize(source.skelClipList.size()); |
|---|
| 170 | for (i=0; i< skelClipList.size(); i++) |
|---|
| 171 | { |
|---|
| 172 | skelClipList[i].name = source.skelClipList[i].name; |
|---|
| 173 | skelClipList[i].start = source.skelClipList[i].start; |
|---|
| 174 | skelClipList[i].stop = source.skelClipList[i].stop; |
|---|
| 175 | skelClipList[i].rate = source.skelClipList[i].rate; |
|---|
| 176 | } |
|---|
| 177 | BSClipList.resize(source.BSClipList.size()); |
|---|
| 178 | for (i=0; i< BSClipList.size(); i++) |
|---|
| 179 | { |
|---|
| 180 | BSClipList[i].name = source.BSClipList[i].name; |
|---|
| 181 | BSClipList[i].start = source.BSClipList[i].start; |
|---|
| 182 | BSClipList[i].stop = source.BSClipList[i].stop; |
|---|
| 183 | BSClipList[i].rate = source.BSClipList[i].rate; |
|---|
| 184 | } |
|---|
| 185 | vertClipList.resize(source.vertClipList.size()); |
|---|
| 186 | for (i=0; i< vertClipList.size(); i++) |
|---|
| 187 | { |
|---|
| 188 | vertClipList[i].name = source.vertClipList[i].name; |
|---|
| 189 | vertClipList[i].start = source.vertClipList[i].start; |
|---|
| 190 | vertClipList[i].stop = source.vertClipList[i].stop; |
|---|
| 191 | vertClipList[i].rate = source.vertClipList[i].rate; |
|---|
| 192 | } |
|---|
| 193 | neutralPoseType = source.neutralPoseType; |
|---|
| 194 | for (i=0; i<source.loadedSubmeshes.size(); i++) |
|---|
| 195 | loadedSubmeshes.push_back(source.loadedSubmeshes[i]); |
|---|
| 196 | for (i=0; i<source.currentRootJoints.size(); i++) |
|---|
| 197 | currentRootJoints.push_back(source.currentRootJoints[i]); |
|---|
| 198 | |
|---|
| 199 | return *this; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | // destructor |
|---|
| 203 | ~ParamList() { |
|---|
| 204 | if (outMaterial) |
|---|
| 205 | outMaterial.close(); |
|---|
| 206 | if (outAnim) |
|---|
| 207 | outAnim.close(); |
|---|
| 208 | if (outCameras) |
|---|
| 209 | outCameras.close(); |
|---|
| 210 | if (outParticles) |
|---|
| 211 | outParticles.close(); |
|---|
| 212 | } |
|---|
| 213 | // method to pars arguments and set parameters |
|---|
| 214 | void parseArgs(const MArgList &args); |
|---|
| 215 | // method to open files for writing |
|---|
| 216 | MStatus openFiles(); |
|---|
| 217 | // method to close open output files |
|---|
| 218 | MStatus closeFiles(); |
|---|
| 219 | }; |
|---|
| 220 | |
|---|
| 221 | }; //end namespace |
|---|
| 222 | |
|---|
| 223 | #endif |
|---|