mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Generate smooth normals
This commit is contained in:
@@ -51,7 +51,7 @@ private:
|
|||||||
{
|
{
|
||||||
// read file via ASSIMP
|
// read file via ASSIMP
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
|
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
|
||||||
// check for errors
|
// check for errors
|
||||||
if(!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
|
if(!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
|
||||||
{
|
{
|
||||||
@@ -102,10 +102,13 @@ private:
|
|||||||
vector.z = mesh->mVertices[i].z;
|
vector.z = mesh->mVertices[i].z;
|
||||||
vertex.Position = vector;
|
vertex.Position = vector;
|
||||||
// normals
|
// normals
|
||||||
vector.x = mesh->mNormals[i].x;
|
if (mesh->HasNormals())
|
||||||
vector.y = mesh->mNormals[i].y;
|
{
|
||||||
vector.z = mesh->mNormals[i].z;
|
vector.x = mesh->mNormals[i].x;
|
||||||
vertex.Normal = vector;
|
vector.y = mesh->mNormals[i].y;
|
||||||
|
vector.z = mesh->mNormals[i].z;
|
||||||
|
vertex.Normal = vector;
|
||||||
|
}
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
if(mesh->mTextureCoords[0]) // does the mesh contain texture coordinates?
|
if(mesh->mTextureCoords[0]) // does the mesh contain texture coordinates?
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user