I have made something similar before but when I debug the program I am getting "Exception thrown at 0x009DC690 in Core.exe: 0xC0000005: Access violation reading location 0x00000000. If there is a handler for this exception, the program may be safely continued." I hit the break button an it puts a breakpoint at vector.x = mesh->mNormals[i].x;. I believe that the compiler can not find any normals and gives out this error. So does anyone know how to fix this. This has never done this to me before.

mesh.h

Code :
#pragma once
 
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
 
using namespace std;
 
#include <GL/glew.h>
#include <glm.hpp>
#include <gtc/matrix_transform.hpp>
#include <assimp\scene.h>
#include "../../shaders/shaderProgram.h"
 
namespace JokesterEngine {
	namespace gameobject {
		struct Vertex {
			glm::vec3 Position;
			glm::vec3 Normal;
			glm::vec2 TexCoords;
		};
 
		struct Texture {
			GLuint id;
			string type;
			aiString path;
		};
 
		class Mesh {
		public:
			vector<Vertex> vertices;
			vector<GLuint> indices;
			vector<Texture> textures;
 
			Mesh(vector<Vertex> vertices, vector<GLuint> indices, vector<Texture> textures)
			{
				this->vertices = vertices;
				this->indices = indices;
				this->textures = textures;
 
				this->setupMesh();
			}
 
 
			void Draw(shaders::ShaderProgram shader)
			{
 
				GLuint diffuseNr = 1;
				GLuint specularNr = 1;
				for (GLuint i = 0; i < this->textures.size(); i++)
				{
					glActiveTexture(GL_TEXTURE0 + i); 
 
					stringstream ss;
					string number;
					string name = this->textures[i].type;
					if (name == "texture_diffuse")
						ss << diffuseNr++;
					else if (name == "texture_specular")
						ss << specularNr++; 
					number = ss.str();
 
					glUniform1i(glGetUniformLocation(shader.m_ProgramID, (name + number).c_str()), i);
					glBindTexture(GL_TEXTURE_2D, this->textures[i].id);
				}
 
				glUniform1f(glGetUniformLocation(shader.m_ProgramID, "material.shininess"), 16.0f);
 
				glBindVertexArray(this->VAO);
				glDrawElements(GL_TRIANGLES, this->indices.size(), GL_UNSIGNED_INT, 0);
				glBindVertexArray(0);
 
				for (GLuint i = 0; i < this->textures.size(); i++)
				{
					glActiveTexture(GL_TEXTURE0 + i);
					glBindTexture(GL_TEXTURE_2D, 0);
				}
			}
 
		private:
			GLuint VAO, VBO, EBO;
 
			void setupMesh()
			{
				glGenVertexArrays(1, &this->VAO);
				glGenBuffers(1, &this->VBO);
				glGenBuffers(1, &this->EBO);
 
				glBindVertexArray(this->VAO);
 
				glBindBuffer(GL_ARRAY_BUFFER, this->VBO);
 
				glBufferData(GL_ARRAY_BUFFER, this->vertices.size() * sizeof(Vertex), &this->vertices[0], GL_STATIC_DRAW);
 
				glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->EBO);
				glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->indices.size() * sizeof(GLuint), &this->indices[0], GL_STATIC_DRAW);
 
				glEnableVertexAttribArray(0);
				glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)0);
 
				glEnableVertexAttribArray(1);
				glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, Normal));
 
				glEnableVertexAttribArray(2);
				glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, TexCoords));
 
				glBindVertexArray(0);
			}
		};
	}
}

model.h

Code :
#pragma once
// Std. Includes
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
 
#include <GL/glew.h>
#include <glm.hpp>
#include <gtc/matrix_transform.hpp>
#include <SOIL/SOIL.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
 
#include "../../shaders/shaderProgram.h"
 
#include "mesh.h"
 
GLint TextureFromFile(const char* path, string directory);
namespace JokesterEngine {
	namespace gameobject {
		class Model
		{
		public:
			Model(GLchar* path)
			{
				this->loadModel(path);
			}
 
			void Draw(shaders::ShaderProgram shader)
			{
				for (GLuint i = 0; i < this->meshes.size(); i++)
					this->meshes[i].Draw(shader);
			}
 
		private:
			/*  Model Data  */
			vector<Mesh> meshes;
			string directory;
			vector<Texture> textures_loaded;
 
			void loadModel(string path)
			{
				Assimp::Importer importer;
				const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
 
				if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
				{
					cout << "ERROR::ASSIMP:: " << importer.GetErrorString() << endl;
					return;
				}
 
				this->directory = path.substr(0, path.find_last_of('/'));
 
				this->processNode(scene->mRootNode, scene);
			}
 
			void processNode(aiNode* node, const aiScene* scene)
			{
 
				for (GLuint i = 0; i < node->mNumMeshes; i++)
				{
					aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
					this->meshes.push_back(this->processMesh(mesh, scene));
				}
 
				for (GLuint i = 0; i < node->mNumChildren; i++)
				{
					this->processNode(node->mChildren[i], scene);
				}
 
			}
 
			Mesh processMesh(aiMesh* mesh, const aiScene* scene)
			{
				vector<Vertex> vertices;
				vector<GLuint> indices;
				vector<Texture> textures;
 
				for (GLuint i = 0; i < mesh->mNumVertices; i++)
				{
					Vertex vertex;
					glm::vec3 vector; 
 
					vector.x = mesh->mVertices[i].x;
					vector.y = mesh->mVertices[i].y;
					vector.z = mesh->mVertices[i].z;
					vertex.Position = vector;
 
					vector.x = mesh->mNormals[i].x;
					vector.y = mesh->mNormals[i].y;
					vector.z = mesh->mNormals[i].z;
					vertex.Normal = vector;
 
					if (mesh->mTextureCoords[0])
					{
						glm::vec2 vec;
 
						vec.x = mesh->mTextureCoords[0][i].x;
						vec.y = mesh->mTextureCoords[0][i].y;
						vertex.TexCoords = vec;
					}
					else
						vertex.TexCoords = glm::vec2(0.0f, 0.0f);
					vertices.push_back(vertex);
				}
 
				for (GLuint i = 0; i < mesh->mNumFaces; i++)
				{
					aiFace face = mesh->mFaces[i];
 
					for (GLuint j = 0; j < face.mNumIndices; j++)
						indices.push_back(face.mIndices[j]);
				}
 
				if (mesh->mMaterialIndex >= 0)
				{
					aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
 
					vector<Texture> diffuseMaps = this->loadMaterialTextures(material, aiTextureType_DIFFUSE, "texture_diffuse");
					textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
 
					vector<Texture> specularMaps = this->loadMaterialTextures(material, aiTextureType_SPECULAR, "texture_specular");
					textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
				}
 
				return Mesh(vertices, indices, textures);
			}
 
			vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, string typeName)
			{
				vector<Texture> textures;
				for (GLuint i = 0; i < mat->GetTextureCount(type); i++)
				{
					aiString str;
					mat->GetTexture(type, i, &str);
 
					GLboolean skip = false;
					for (GLuint j = 0; j < textures_loaded.size(); j++)
					{
						if (textures_loaded[j].path == str)
						{
							textures.push_back(textures_loaded[j]);
							skip = true;
							break;
						}
					}
					if (!skip)
					{   //
						Texture texture;
						texture.id = TextureFromFile(str.C_Str(), this->directory);
						texture.type = typeName;
						texture.path = str;
						textures.push_back(texture);
						this->textures_loaded.push_back(texture);
					}
				}
				return textures;
			}
		};
	}
}
 
 
 
GLint TextureFromFile(const char* path, string directory)
{ 
	string filename = string(path);
	filename = directory + '/' + filename;
	GLuint textureID;
	glGenTextures(1, &textureID);
	int width, height;
	unsigned char* image = SOIL_load_image(filename.c_str(), &width, &height, 0, SOIL_LOAD_RGB);
 
	glBindTexture(GL_TEXTURE_2D, textureID);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
	glGenerateMipmap(GL_TEXTURE_2D);
 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
	glBindTexture(GL_TEXTURE_2D, 0);
	SOIL_free_image_data(image);
	return textureID;
}

core.cpp

Code :
#include <iostream>
 
#include "data\graphics\window.h"
#include "data\shaders\shaderProgram.h"
#include "data\graphics\buffers\buffer.h"
#include "data\graphics\buffers\indexBuffer.h"
#include "data\graphics\buffers\vertexarray.h"
#include "data\graphics\renderer.h"
#include "data\graphics\texture\texture.h"
#include "data\graphics\buffers\bufferdata.h"
#include "data\gameobjects\light.h"
#include "data\graphics\material.h"
#include "data\gameobjects\model\model.h"
 
int main() {
	JokesterEngine::graphics::Window m_Window(1080, 720, "SPACE BATTLES");
	JokesterEngine::shaders::ShaderProgram m_Shader("Resources/shaders/vertexShader.txt", "Resources/shaders/fragmentShader.txt");
	JokesterEngine::shaders::ShaderProgram m_ModelShader("Resources/shaders/modelVertexShader.txt", "Resources/shaders/modelFragmentShader.txt");
	JokesterEngine::graphics::Renderer m_Renderer;
	JokesterEngine::gameobject::Model m_NanoGuy("Resources/models/nanosuit/nanosuit2.obj");
 
	glEnable(GL_DEPTH_TEST);
 
	while (!m_Window.closed())
	{
		m_Window.varUpdate();
 
		m_Renderer.screenColor();
		m_Window.clear();
 
		m_ModelShader.enable();
 
		glm::mat4 projection;
		projection = glm::perspective(45.0f, static_cast<float>(m_Window.getWindowX()) / static_cast<float>(m_Window.getWindowY()), 0.1f, 100.0f);
 
		glm::mat4 view;
		view = m_Window.m_Camera.GetViewMatrix();
 
		glm::mat4 model;
		model = glm::scale(model, glm::vec3(0.2f, 0.2f, 0.2f));
		model = glm::translate(model, glm::vec3(0.0f, 0.0f, 0.0f));
 
		glUniformMatrix4fv(glGetUniformLocation(m_ModelShader.m_ProgramID, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
		glUniformMatrix4fv(glGetUniformLocation(m_ModelShader.m_ProgramID, "view"), 1, GL_FALSE, glm::value_ptr(view));
		glUniformMatrix4fv(glGetUniformLocation(m_ModelShader.m_ProgramID, "model"), 1, GL_FALSE, glm::value_ptr(model));
 
		m_NanoGuy.Draw(m_ModelShader);
 
		m_Window.update();
		m_Window.Do_Movement();
	}
 
	m_Shader.disable();
 
	return 0;
}