Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering with GL_TRIANGLE_STRIP (.3ds model data)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 TheEffigy   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 April 2012 - 06:52 PM

Hi there,

I've just written a .3ds format model loader which seems to be working very well - but I'm am having an issue rendering the model objects. It seems to me that the issue is with the order that I am rendering the vertices and most likely is a very simple and silly mistake perhaps someone here can point out for me.

As you can see in the screenshot below, the faces for the left and right hand side of the cube aren't rendering correctly.

Posted Image

And this is my relevant chunk of rendering code:
void Model::render() const {
	glColor3f(1.0, 1.0, 1.0);
	std::for_each(i_->objects.begin(), i_->objects.end(),
			[](const i::Object& obj) {
				glBegin(GL_TRIANGLE_STRIP);
				std::for_each(obj.faces.begin(), obj.faces.end(),
						[&obj](const i::Object::Face& f) {
							const Vector3& v1 = obj.vertices[f.x];
							glVertex3f(v1.x, v1.y, v1.z);
							const Vector3& v2 = obj.vertices[f.y];
							glVertex3f(v2.x, v2.y, v2.z);
							const Vector3& v3 = obj.vertices[f.z];
							glVertex3f(v3.x, v3.y, v3.z);
						});
				glEnd();
			});
}
I've gone over the model loading code and I'm quite certain it follows the format specification correctly, and my hex editor agrees with what I've loaded.

Sponsor:

#2 TheEffigy   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 April 2012 - 07:45 PM

May be worth noting that a simple plane, and a slightly more complex plane with an edge extruded 90 degrees render just fine... but as the polygons and depth increase things become a bit crazy.

#3 TheEffigy   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 April 2012 - 10:37 PM

Ah, problem solved! I went over a few other loaders I found on the net and it turns out that you have to swap the ordering of the face vertices.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS