I am trying to implement Blades of Waving Grass and I am still stuck at the point where I need to achieve texture arrangements like in the figure below (the first one).

So my plan is to draw the first texture, then draw the second and rotate it by 30°, then another and rotate it by 60° etc. Drawing the first texture is not a problem but I have some issues rotating the second one. I would expect it to look something like this (view from above):

Instead the actual result looks something like this:

Vertex and position data:

GLfloat vertices[] = { -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, }; glm::vec3 texturePositions[] = { glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f) };

Camera/View transformations:

// Camera/View transformation glm::mat4 view; view = camera.GetViewMatrix(); // Projection glm::mat4 projection; projection = glm::perspective(glm::radians(camera.Zoom), (GLfloat)WIDTH / (GLfloat)HEIGHT, 0.1f, 1000.0f); // Get the uniform locations GLint modelLoc = glGetUniformLocation(ourShader.Program, "model"); GLint viewLoc = glGetUniformLocation(ourShader.Program, "view"); GLint projectionLoc = glGetUniformLocation(ourShader.Program, "projection"); // Pass the matrices to the shader glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view)); glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));

Drawing the first two textures:

//Texture 1 glm::mat4 model; model = glm::translate(model, texturePositions[0]); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glDrawArrays(GL_TRIANGLES, 0, 6); //Texture 2 GLfloat angle = glm::radians(30.0f); model = glm::translate(model, texturePositions[1]); model = glm::rotate(model, angle, glm::vec3(0.0f, 1.0f, 0.0f)); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glDrawArrays(GL_TRIANGLES, 0, 6);

As I am still in the very early learning process so I am kind of clueless here.

1. I think that the order of transformations for the second texture is fine in my code, isn't it?

2. Also how would I determine the right position for the object where the rotation would be applied correctly? (see above point 2)

3. Might it be more efficient to apply the rotation in the objects local space? Is that possible in my case?

4. If I change the rotation axis from **y** to **z** the object rotates around its own center just like expected.

5. I also tried to apply the following solutions (taken from here and here) where I moved the object to **glm::vec3(-x,-y,-z) **rotate it and then moving it back to **glm::vec3(x,y,z)**, unfortunately with no success. Which makes sence as the position vector is set to (0,0,0) anyway. I also tried to change this position to something else than the origin also with no success.

I do not expect anybody to write code for me (though some snippet would be nice) but I would appreciate some hints or somebody pointing me in the right direction. I think that I have a basic fallacy here.

Thanks in advance.