Assimp opengl load model vertices some values greater than 1

  assimp, c++, opengl

I have the following code from learnopengl.com

void Model::load_model(string path)
{
        //read file via ASSIMP
        Assimp::Importer Importer;
        const aiScene* scene = Importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
        //check for errors
        if(!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)// if not zero
        {
                cout << "error, assimp ," << Importer.GetErrorString() << endl;
                return;
        }
        //retrieve the directory path of the filepath
        directory = path.substr(0, path.find_first_of('/'));
        process_node(scene->mRootNode, scene);
}
/*
 * Process a node in a recursive fashion . Process each individual mesh located at the node and repeat this process on its children nodes (if any)
 */
void Model::process_node(aiNode* node, const aiScene* scene)
{
        for( GLuint i = 0; i < node->mNumMeshes; i++ )
        {
                //the node object only contains indices to index the actual objects of the scene.
                //The scene contains all the data , node is just to keep stuff organized( like relations between nodes )
                aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
                meshes.push_back(process_mesh(mesh, scene));
        }
        //after we've processed all the meshes ( if any ) we then recusrsively process each of the children nodes 
        for(GLuint i = 0; i < node->mNumChildren; i++)
        {
                process_node(node->mChildren[i], scene);
        }
}
Mesh Model::process_mesh(aiMesh* mesh, const aiScene* scene)
{
        //data to fill
        vector<Mesh::Vertex> vertices;
        vector<GLuint> indices;
        vector<Mesh::Texture> textures;

        //walk through each of the meshes vertices
        for(GLuint i = 0; i < mesh->mNumVertices; i++)
        {
                Mesh::Vertex vertex;
                // we declare a placeholder vector since assimp uses its own vector class that doesn't directly convert to glm's vec3 class
                //so we transfter the data to this placeholder glm::vec3 first 
                glm::vec3 vector;
                //positions
                vector.x = mesh->mVertices[i].x; 
                vector.y = mesh->mVertices[i].y;
                vector.z = mesh->mVertices[i].z;
                vertex.position = vector;
                //normals
                vector.x = mesh->mNormals[i].x;
                vector.y = mesh->mNormals[i].y;
                vector.z = mesh->mNormals[i].z; ...

When I print out the first 20 values of mesh->mVertices[i].x y and z I get some with values greater than 1 as show below

x1: 1.58967 Y1: -0.618526 z1: -0.683333
x1: 1.58939 Y1: -0.626895 z1: -0.681676

The obj file I am importing doesn’t have any values greater than 1 and this is making the render fail. Where might the problem be?

Source: Windows Questions C++

LEAVE A COMMENT