Ejemplo n.º 1
0
bool CModel::LoadSourceFile()
{
#ifdef TINKER_NO_TOOLS
	return false;
#else
	CConversionScene* pScene = new CConversionScene();
	CModelConverter c(pScene);

	if (!c.ReadModel(m_sFilename))
	{
		delete pScene;
		return false;
	}

	g_asTextures.clear();
	g_aaflData.clear();
	g_aabbVisBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999));
	g_aabbPhysBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999));

	LoadSceneIntoToy(pScene);

	size_t iTextures = g_asTextures.size();

	m_ahMaterials.resize(iTextures);
	m_aiVertexBuffers.resize(iTextures);
	m_aiVertexBufferSizes.resize(iTextures);

	for (size_t i = 0; i < iTextures; i++)
	{
		if (g_aaflData[i].size() == 0)
			continue;

		m_aiVertexBuffers[i] = CRenderer::LoadVertexDataIntoGL(g_aaflData[i].size()*4, &g_aaflData[i][0]);
		m_aiVertexBufferSizes[i] = g_aaflData[i].size()/FIXED_FLOATS_PER_VERTEX;

		CData oMaterialData;
		CData* pShader = oMaterialData.AddChild("Shader", "model");
		pShader->AddChild("DiffuseTexture", g_asTextures[i]);
		m_ahMaterials[i] = CMaterialLibrary::AddMaterial(&oMaterialData);

		//TAssert(m_aiMaterials[i]);
		if (!m_ahMaterials[i].IsValid())
			TError(tstring("Couldn't create fake material for texture \"") + g_asTextures[i] + "\"\n");
	}

	m_aabbVisBoundingBox = g_aabbVisBounds;
	m_aabbPhysBoundingBox = g_aabbPhysBounds;

	delete pScene;

	return true;
#endif
}
Ejemplo n.º 2
0
bool CModel::Load(class CConversionScene* pScene, size_t iMesh)
{
	g_aaflData.clear();

	LoadMesh(pScene, iMesh);

	size_t iMaterials = g_aaflData.size();

	for (size_t i = 0; i < iMaterials; i++)
	{
		if (g_aaflData[i].size() == 0)
			continue;

		m_aiVertexBuffers.push_back(CRenderer::LoadVertexDataIntoGL(g_aaflData[i].size()*4, &g_aaflData[i][0]));
		m_aiVertexBufferSizes.push_back(g_aaflData[i].size()/FIXED_FLOATS_PER_VERTEX);
	}

	m_aabbVisBoundingBox = g_aabbVisBounds;
	m_aabbPhysBoundingBox = g_aabbPhysBounds;

	return true;
}