Hello, im a new user, and currently im learning opengl.
Ive made a mesh in Blender and loaded it with a .obj parser that i made, i can now display the 3d model.
Then i wanted to make transformations. As you cant use inmediate mode with VBO i struggled until i came with a solution.
To handle rotations i made functions in my Mesh class, and i apply math directly to the vertex that i have loaded.
This is what my shaders looks like:
Vertex Shader:
#version 130
in vec4 vertexPosition;
void main()
{
gl_Position.x = vertexPosition.x;
gl_Position.y = vertexPosition.y;
gl_Position.z = vertexPosition.z;
gl_Position.w = 1.0;
}
Fragment Shader(only for color):
#version 130
out vec3 color;
void main()
{
color = vec3(0.0,0.5,1.0);
}
This is how my functions look like:
(this is my calculateTranslation function)
void Modelo::calcularTraslado(float x, float y, float z)
{
glm::vec3 vectorTransf(x,y,z);
for(unsigned int i=0; i<vertices.size(); i++)
{
vertices[i] += vectorTransf;
}
glBindBuffer(GL_ARRAY_BUFFER, _vboID);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec3), &vertices[0], GL_STATIC_DRAW); //GL buffer data takes position info?
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Then the only thing i have to do is use my function (like this: calcularTraslado(1.0,1.0,1.0)) and i can translate the mesh in the space.
The problem is, i dont know if this is the correct way to do this, ive noticed that if i have a very large number of vertices to draw, the calculations take a lot of time, so i dont really know what can i do.
Thanks for take the time to read, and for the help!
Sorry for my bad english, im still learning it lol