• Create Account

### #Actuallaylay

Posted 13 November 2012 - 12:05 AM

Thanks. So pretty much I can just increase along the length of the segment? What are the start and end v coords for?

It seems to work anyway but I'm having a problem with wrapping around the pipe that I didn't notice. The last face on the cylinder segment is messed up. This is how I'm calculating it.

[source lang="cpp"] // loop through each point on the radius for (unsigned int i = 0; i < m_points; ++i) { // sin and cos displace the vertex in a radius float x = cos(Math::DegreesToRadians(degrees)) * m_radius; float y = sin(Math::DegreesToRadians(degrees)) * m_radius; // offset the vertex up and right to orientate it Vector3f point = position; point += right * x; point += up * y; // create the vertex Vertex vertex; vertex.position = point; vertex.normal = (point - position).Normalise(); vertex.texCoord = Vector2f((float)i / ((float)m_points - 1.0f), ycoord); m_vertices.push_back(vertex); // keep going around the radius degrees += 360.0f / (float)m_points - 1; }[/source]

What I think is happening is that the 0th vertex on the ring has a u texcoord of 0 but the last one is 1, that's going to cause problems I think. How should I handle it?

I have a feeling I'll have to have a duplicate vertex at the 0th position because it needs to be 0 for the first face but 1 for the last face. Kind of sucks.

### #2laylay

Posted 12 November 2012 - 11:37 PM

Thanks. So pretty much I can just increase along the length of the segment? What are the start and end v coords for?

It seems to work anyway but I'm having a problem with wrapping around the pipe that I didn't notice. The last face on the cylinder segment is messed up. This is how I'm calculating it.

[source lang="cpp"] // loop through each point on the radius for (unsigned int i = 0; i < m_points; ++i) { // sin and cos displace the vertex in a radius float x = cos(Math::DegreesToRadians(degrees)) * m_radius; float y = sin(Math::DegreesToRadians(degrees)) * m_radius; // offset the vertex up and right to orientate it Vector3f point = position; point += right * x; point += up * y; // create the vertex Vertex vertex; vertex.position = point; vertex.normal = (point - position).Normalise(); vertex.texCoord = Vector2f((float)i / ((float)m_points - 1.0f), ycoord); m_vertices.push_back(vertex); // keep going around the radius degrees += 360.0f / (float)m_points - 1; }[/source]

What I think is happening is that the 0th vertex on the ring has a u texcoord of 0 but the last one is 1, that's going to cause problems I think. How should I handle it?

### #1laylay

Posted 12 November 2012 - 10:34 PM

Thanks. So pretty much I can just increase along the length of the segment? What are the start and end v coords for?

PARTNERS