1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#pragma once
#include "inode.h"
#include "imodel.h"
#include "imodelsurface.h"
#include "math/AABB.h"
#include "math/Matrix4.h"
#include "math/Vector3.h"
#include <map>
#include <list>
namespace model
{
class ModelExporter :
public scene::NodeVisitor
{
private:
model::IModelExporterPtr _exporter;
bool _skipCaulk;
std::string _caulkMaterial;
bool _centerObjects;
// Optional origin to use for the centering transformation
// instead of the object bounds origin
Vector3 _origin;
bool _useOriginAsCenter;
// Whether lights should be exported too (as small diamond-shaped objects)
bool _exportLightsAsObjects;
std::list<scene::INodePtr> _nodes;
// The translation centering the objects
// is identity if _centerObjects is false
Matrix4 _centerTransform;
public:
ModelExporter(const model::IModelExporterPtr& exporter);
// Define whether the exporter should ignore caulked surfaces
void setSkipCaulkMaterial(bool skipCaulk);
// Define whether we should arrange the objects around the world origin
void setCenterObjects(bool centerObjects);
// Define the origin to use for centering the objects
void setOrigin(const Vector3& origin);
// Set whether lights should be exported too (as small diamond-shaped objects)
void setExportLightsAsObjects(bool enabled);
bool pre(const scene::INodePtr& node) override;
// Processes the nodes previously collected in the pre() method
void processNodes();
// Returns the transformation matrix used to put the model at the desired place
// This can be identity if centerobjects is false, or a translation matrix
// moving the model parts towards the world origin
const Matrix4& getCenterTransform();
private:
AABB calculateModelBounds();
bool isExportableMaterial(const std::string& materialName);
void processBrush(const scene::INodePtr& node);
void processPatch(const scene::INodePtr& node);
void processLight(const scene::INodePtr& node);
};
}
|