# I need to remove vertices based on a translation, but with rotation applied I don't have direct access

So I chose the name Tunnel Man because I wanted to make tunnels. Tunnels have walls and without induces it takes 6 vertices to make a wall. These are 2 units wide. I have decided to do things from scratch because I have used game engines and some things I could not find out how to do, But this was easy when it came to doing this because I could make an object to be my wall and it’s translation is always available. In order to do things within the limits of the computer I must create new walls and delete the ones I don’t need. This is generally how I would remove them in a game engine:

``````for (int i=0;i < walls.size();i++){
if (abs(walls[i].translation.x - mapx * 2) > 2 &&  abs(walls[i].translation.z - mapz * 2) > 2) walls[i].delete();
}
``````

This is just made up code but you can understand the idea if you know code.

This is my real OpenGL code to make the wall.

``````void MazeHolder::addwall(glm::vec3 rotation, glm::vec3 translation, float type)
{
for (int i = 0; i < prevtrans.size(); i++) {
if (translation == prevtrans.at(i).translation) return;
}
WallInfo info;
info.translation = translation;
info.number = wallVertices.size();
prevtrans.push_back(info);
NormalVertex vertex;
glm::mat4 rotMatrix = glm::eulerAngleXYZ(rotx, roty, rotz);
glm::mat4 transMatrix = glm::translate(glm::mat4(1.0), translation);
glm::mat4 model = transMatrix * rotMatrix;
glm::vec4 lnorm = rotMatrix * glm::vec4(0, 1, 0, 1);
glm::mat3 trpos = glm::mat3(glm::transpose(glm::inverse(transMatrix)));
vertex.normal = trpos * glm::vec3(lnorm);
vertex.wallType = type;
Pass3 ref;
Pass3 loc;
for (int i = 0; i < 6; i++) {

vertex.position = glm::vec3(model * glm::vec4(ppos[posind[i]], 1));
vertex.texCoord = ptex[texind[i]];

//loc = getTangents(ref, trpos);
wallVertices.push_back(vertex);

}
}
``````

I have tried different ways to do this, here is a remnant of 1 attempt: prevtrans.push_back(info);
I have tried putting 6 vertices in a group but because I didn’t see anything I think that the code couldn’t decode the addresses.

I managed to solve this problem. I couldn’t do it by requesting 2 classes and my code was in a class. So I created a function for the Main.cpp to request the geometry and another class to render it.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.