Hello All,
New to the forum and new to game development in general. I started taking a computer graphics class at MIT OpenCourseware to get the lay of the land. I'm an engineer (aerospace) by trade, and have little classical training in low-level languages. I'm learning more about C++ and OpenGL concurrently. Learning by doing.
The first assignment was to load a .obj file and make it rotate, change its color, etc... I expanded this assignment to include include a typical FPS type camera movement, like a minecraft style camera with no gravity, floating ominously in empty black space... Fixing that is where I'm running into issues...
I've since figured out how to display a relatively simple surface. It is a 3D sine wave F(x,y) = sin(x) + sin(y). I create an equally spaced mesh in x and y and calculate a z. I collect all the vertex information and use GL_QUADS to render my polygonal surface. This works great, except when I try to render too many polygons. This is my first problem:
How do I efficiently store this data? Is there an "industry standard" way to store/render a 2-d mesh of data? I can't think of any other way to render a hilly landscape than to do some sort of 2D meshgrid and map an altitude (Z-axis) to it.
My implementation has 3 parts:
Vec_V, which is a vector of type Vector3f which stores 3 floats, being the xyz coordinate of the vertices
Vec_N is the same, except it stores the normals
Vec_F is vector<vector<unsigned> > . Each element is a group of 4 integers, which are the vertex indices that go together to make a quadrilateral.
I then use all of these vectors to render all of the quads I used to make the surface. My code breaks when N is large (more than 3000ish), where N is the length of the mesh grid (N * N = number of vertices, (N-1)*(N-1) = number of quad elements).
Is that implementation reasonable? I know there is plenty of room for improvement. Using simpler data structures can help. Using quad strips instead of quads can reduce my data.... Any advice or resources? I tried googling "How to make the ground surface game dev c++" and similar queries and am struggling to find good resources.
Second question..... In procedurally generated games, or games in general... What methods are used to render what needs rendering. I'm struggling to fathom how this is done, because in my mind... it would require one to know every vertex in the entire world to determine which are "in view" of the character. I'm struggle to store 25 million vertices, which are but an insignificant fraction of what I plan to make the world out of.... How can I even calculate which vertices are in view, if I can barely store the local vertices? Obviously it's been done, so I'm just being ignorant. I'm really looking for some solid resources on how to conquer this problem.
Any help would be appreciated.. Resources, advice, explanations etc... Thanks in advance!