本文整理汇总了C++中ModelData::SetModelID方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelData::SetModelID方法的具体用法?C++ ModelData::SetModelID怎么用?C++ ModelData::SetModelID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelData
的用法示例。
在下文中一共展示了ModelData::SetModelID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadOBJ
//.........这里部分代码省略.........
}
else
{
num += Line[i];
}
}
}
// Read in vertex position
else
{
for (std::size_t i = 1; i < Line.length(); i++)
{
if (Line[i] == ' ' || i == Line.length() - 1)
{
if (num.length() > 0)
verts.push_back(std::stof(num));
num.clear();
}
else
{
num += Line[i];
}
}
}
}
}
MeshStream.close();
}
else
{
model->SetUseValidity(false);
return model;
}
for (size_t i = 0; i < vert_indicies.size(); i++)
{
model->verticies.push_back(verts[(vert_indicies[i] - 1)*3]);
model->verticies.push_back(verts[(vert_indicies[i] - 1) * 3 + 1]);
model->verticies.push_back(verts[(vert_indicies[i] - 1) * 3 + 2]);
}
for (size_t i = 0; i < norm_indicies.size(); i++)
{
model->normals.push_back(norms[(norm_indicies[i] - 1)*3]);
model->normals.push_back(norms[(norm_indicies[i] - 1) * 3 + 1]);
model->normals.push_back(norms[(norm_indicies[i] - 1) * 3 + 2]);
}
for (size_t i = 0; i < tex_coords_indicies.size(); i++)
{
model->uvs.push_back(tex[(tex_coords_indicies[i] - 1) * 2]);
model->uvs.push_back(tex[(tex_coords_indicies[i] - 1) * 2 + 1]);
}
// Calculate tangent basis
int vert_count = 0;
int uv_count = 0;
while (vert_count < model->verticies.size())
{
if (uv_count >= model->uvs.size()) break;
// Triangle verts
glm::vec3 & v0 = glm::vec3(model->verticies[vert_count++], model->verticies[vert_count++], model->verticies[vert_count++]);
glm::vec3 & v1 = glm::vec3(model->verticies[vert_count++], model->verticies[vert_count++], model->verticies[vert_count++]);
glm::vec3 & v2 = glm::vec3(model->verticies[vert_count++], model->verticies[vert_count++], model->verticies[vert_count++]);
// Triangle UVs
glm::vec2 & uv0 = glm::vec2(model->uvs[uv_count++], model->uvs[uv_count++]);
glm::vec2 & uv1 = glm::vec2(model->uvs[uv_count++], model->uvs[uv_count++]);
glm::vec2 & uv2 = glm::vec2(model->uvs[uv_count++], model->uvs[uv_count++]);
// Edges of the triangle : postion delta
glm::vec3 deltaPos1 = v1 - v0;
glm::vec3 deltaPos2 = v2 - v0;
// UV delta
glm::vec2 deltaUV1 = uv1 - uv0;
glm::vec2 deltaUV2 = uv2 - uv0;
float r = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV1.y * deltaUV2.x);
glm::vec3 tangent = (deltaPos1 * deltaUV2.y - deltaPos2 * deltaUV1.y)*r;
glm::vec3 bitangent = (deltaPos2 * deltaUV1.x - deltaPos1 * deltaUV2.x)*r;
for (int i = 0; i < 3; i++)
{
model->bitangets.push_back(bitangent.x);
model->bitangets.push_back(bitangent.y);
model->bitangets.push_back(bitangent.z);
model->tangents.push_back(tangent.x);
model->tangents.push_back(tangent.y);
model->tangents.push_back(tangent.z);
}
}
model->SetModelID(ModelIdentifier++);
model->SetUseValidity(true);
return model;
}