Browse Source

Adding LOD

Panagiotis Christopoulos Charitos 10 years ago
parent
commit
485a778516
4 changed files with 33 additions and 1 deletions
  1. 2 0
      src/gr/gl/CommandBuffer.cpp
  2. 1 1
      thirdparty
  3. 29 0
      tools/scene/Exporter.cpp
  4. 1 0
      tools/scene/Exporter.h

+ 2 - 0
src/gr/gl/CommandBuffer.cpp

@@ -203,6 +203,8 @@ public:
 				m_info.m_baseInstance);
 
 			ANKI_COUNTER_INC(GL_DRAWCALLS_COUNT, U64(1));
+			ANKI_COUNTER_INC(GL_VERTICES_COUNT,
+				U64(m_info.m_instanceCount * m_info.m_count));
 		}
 
 		return ErrorCode::NONE;

+ 1 - 1
thirdparty

@@ -1 +1 @@
-Subproject commit 36e4d961fce003ba23af6e31b32b448b5728f0a0
+Subproject commit defc185ddd5d7cb80537a6357d5e5aeaf3d7a26d

+ 29 - 0
tools/scene/Exporter.cpp

@@ -663,6 +663,28 @@ void Exporter::exportModel(const Model& model) const
 		<< getMeshName(getMeshAt(model.m_meshIndex))
 		<< ".ankimesh</mesh>\n";
 
+	// Write mesh1
+	if(!model.m_lod1MeshName.empty())
+	{
+		bool found = false;
+		for(unsigned i = 0; i < m_scene->mNumMeshes; i++)
+		{
+			if(m_scene->mMeshes[i]->mName.C_Str() == model.m_lod1MeshName)
+			{
+				file << "\t\t\t<mesh1>" << m_rpath
+					<< getMeshName(getMeshAt(i))
+					<< ".ankimesh</mesh1>\n";
+				found = true;
+				break;
+			}
+		}
+
+		if(!found)
+		{
+			ERROR("Couldn't find the LOD1 %s", model.m_lod1MeshName.c_str());
+		}
+	}
+
 	// Write material
 	file << "\t\t\t<material>" << m_rpath
 		<< getMaterialName(getMaterialAt(model.m_materialIndex),
@@ -964,6 +986,7 @@ void Exporter::visitNode(const aiNode* ainode)
 		unsigned mtlIndex =  m_scene->mMeshes[meshIndex]->mMaterialIndex;
 
 		// Check properties
+		std::string lod1MeshName;
 		bool special = false;
 		for(const auto& prop : m_scene->mMeshes[meshIndex]->mProperties)
 		{
@@ -999,6 +1022,11 @@ void Exporter::visitNode(const aiNode* ainode)
 				m_sectors.push_back(sector);
 				special = true;
 			}
+			else if(prop.first == "lod1")
+			{
+				lod1MeshName = prop.second;
+				special = false;
+			}
 		}
 
 		if(special)
@@ -1040,6 +1068,7 @@ void Exporter::visitNode(const aiNode* ainode)
 		Model mdl;
 		mdl.m_meshIndex = meshIndex;
 		mdl.m_materialIndex = mtlIndex;
+		mdl.m_lod1MeshName = lod1MeshName;
 		m_models.push_back(mdl);
 
 		// Create new node

+ 1 - 0
tools/scene/Exporter.h

@@ -26,6 +26,7 @@ struct Model
 	uint32_t m_meshIndex = INVALID_INDEX; ///< Mesh index in the scene
 	uint32_t m_materialIndex = INVALID_INDEX;
 	uint32_t m_instancesCount = 1;
+	std::string m_lod1MeshName;
 };
 
 /// Scene node.