Пример #1
0
void Model::loaded(FS::IFile& file, bool success, FS::FileSystem& fs)
{
	PROFILE_FUNCTION();
	if (success)
	{
		FileHeader header;
		file.read(&header, sizeof(header));
		if (header.m_magic == FILE_MAGIC &&
			header.m_version <= (uint32_t)FileVersion::LATEST &&
			parseMeshes(file) && parseGeometry(file) && parseBones(file) &&
			parseLODs(file))
		{
			m_size = file.size();
			decrementDepCount();
		}
		else
		{
			g_log_warning.log("renderer") << "Error loading model "
										  << m_path.c_str();
			onFailure();
			return;
		}
	}
	else
	{
		g_log_warning.log("renderer") << "Error loading model "
									  << m_path.c_str();
		onFailure();
	}
}
Пример #2
0
bool Model::load(FS::IFile& file)
{
	PROFILE_FUNCTION();
	FileHeader header;
	file.read(&header, sizeof(header));
	if (header.m_magic == FILE_MAGIC 
		&& header.m_version <= (uint32)FileVersion::LATEST 
		&& parseMeshes(file) 
		&& parseGeometry(file) 
		&& parseBones(file) 
		&& parseLODs(file))
	{
		m_size = file.size();
		return true;
	}

	g_log_warning.log("renderer") << "Error loading model " << getPath().c_str();
	return false;
}
Пример #3
0
bool Model::load(FS::IFile& file)
{
	PROFILE_FUNCTION();
	FileHeader header;
	file.read(&header, sizeof(header));

	if (header.magic != FILE_MAGIC)
	{
		g_log_warning.log("Renderer") << "Corrupted model " << getPath().c_str();
		return false;
	}

	if(header.version > (u32)FileVersion::LATEST)
	{
		g_log_warning.log("Renderer") << "Unsupported version of model " << getPath().c_str();
		return false;
	}

	u32 global_flags = 0; // backward compatibility
	if(header.version > (u32)FileVersion::WITH_FLAGS)
	{
		file.read(&global_flags, sizeof(global_flags));
	}

	bgfx::VertexDecl global_vertex_decl;
	if (header.version > (u32)FileVersion::SINGLE_VERTEX_DECL && header.version <= (u32)FileVersion::MULTIPLE_VERTEX_DECLS)
	{
		parseVertexDeclEx(file, &global_vertex_decl);
	}

	if (parseMeshes(global_vertex_decl, file, (FileVersion)header.version, global_flags)
		&& parseBones(file)
		&& parseLODs(file))
	{
		m_size = file.size();
		return true;
	}

	g_log_error.log("Renderer") << "Error loading model " << getPath().c_str();
	return false;
}