!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / LodGeneratorPlugin / Util / AtlasGenerator.cpp
blob3d9c8562f5a47f67d32c6b8ca0942100641b0ba0
1 #include "StdAfx.h"
3 #include "AtlasGenerator.h"
4 #include <Cry3DEngine/IIndexedMesh.h>
5 #include "TopologyTransform.h"
6 #include "Packer.h"
7 #include "TopologyGraph.h"
8 #include "UVGenerator.h"
10 namespace LODGenerator
12 CAtlasGenerator::CAtlasGenerator()
14 m_MeshMap = NULL;
17 CAtlasGenerator::~CAtlasGenerator()
19 if(m_MeshMap != NULL)
20 delete m_MeshMap;
24 CTopologyGraph* CAtlasGenerator::surface()
26 return m_MeshMap;
29 void CAtlasGenerator::pack_in_texture_space()
31 CPacker packer;
32 packer.pack_map(surface());
35 void CAtlasGenerator::generate_texture_atlas(bool auto_cut,bool auto_cut_cylinders,double max_overlap_ratio,double max_scaling, double min_fill_ratio)
37 if (surface() == NULL)
38 return;
40 CTopologyGraphMutator editor(surface());
41 FOR_EACH_VERTEX(CTopologyGraph, surface(), it)
43 editor.merge_tex_vertices(*it);
45 CUVGenerator generator(surface());
46 generator.set_auto_cut(auto_cut);
47 generator.set_auto_cut_cylinders(auto_cut_cylinders);
48 generator.set_max_overlap_ratio(max_overlap_ratio);
49 generator.set_max_scaling(max_scaling);
50 generator.set_min_fill_ratio(min_fill_ratio);
51 generator.apply();
52 pack_in_texture_space();
56 void CAtlasGenerator::setSurface(IStatObj *pObject)
58 m_MeshMap = CTopologyTransform::TransformToTopology(pObject);
61 void CAtlasGenerator::setSurface(CTopologyGraph* meshMap)
63 m_MeshMap = meshMap;