NOTE: I haven’t had much luck getting this to compile using g++ because of my Vector class. It definitely compiles in MS Visual Studio, though. The compiler errors in g++ aren’t what I’m trying to fix, though a friend of mine was able to get it compiling on his PC (he uses g++) by removing all instances of Vector& from Vector, and passing it by value instead.
DESCRIPTION OF PROBLEM:
The way the program works is that it reads in an SDL file. The SDL file contains information about the scene: the light positions, colors, etc. It also contains information about the materials used in the scene. It then contains a line which directs you to the file that contains all the mesh information (a .3VN file - formatted as follows:
<3 tuple containing: # of vertices, # of normals, # of faces for object>
<List of 3 tuples corresponding to the vertices of the object>
<List of 3 tuples corresponding to the normals of the object>
<Foreach face in the object:
of vertices in face
for each vertex in the face
indices of vertices in the list of vertices
indices of normals in the list of normals>)
I then attempt to render (using OpenGL with GLUT) the object described by the SDL/3VN file(s). The problem is that when it renders, it looks incorrect. That is, the object is clearly missing triangles when it’s being drawn. It looks very choppy. The code is kind of long, so I’m going to post it on another site.
Source is at:
http://www.freewebs.com/volatilevoid/Camera.h
http://www.freewebs.com/volatilevoid/Camera.cpp
http://www.freewebs.com/volatilevoid/Vector.h
http://www.freewebs.com/volatilevoid/Mesh.h
http://www.freewebs.com/volatilevoid/CubeMain.cpp
Scene files:
http://www.freewebs.com/volatilevoid/pewterglass.sdl
http://www.freewebs.com/volatilevoid/glass.3vn
I confirmed that both the SDL and 3VN files are being read in correctly, so I’m really at a loss as to what’s wrong. I apologize for the messiness of my code: I kept adding in debugging output and removing it, and moved so much stuff around to try to find the problem that I made my code look like a trainwreck. I’m also going to post a much shorter SDL/3VN file, since it might be easier to find the problem with a less complex object:
Other scene files:
http://www.freewebs.com/volatilevoid/Cube.sdl
http://www.freewebs.com/volatilevoid/Cube.3vn
Note, to move around in the scene see the key() function in CubeMain.cpp
‘x’ rotates on the XZ plane (‘X’ rotates in the opposite direction on the XZ plane)
‘y’ rotates on the YZ plane (‘Y’ - opposite direction)
‘l’ slides on the X axis
‘k’ slides on the Y axis
‘j’ slides on the Z axis
‘t’ tilts
‘p’ pans
‘r’ rolls
EDIT: I realize I have a memory leak where I read in the file, new a Mesh and never delete it. While that’s a problem, it’s not THE problem that’s causing improper rendering. I’ll add in code to clean up the leak (after glutMainLoop () releases, I can clean up the mesh).
Thanks in advance.
VV