It’s been several months since the post, and I’ve finally convinced myself to attempt to cobble together the beginings of a 3-D engine. I’ve also purchased Practical Java Game Programming, and have been looking at that. Both the book and Mithrandirs post have been helpful, but I still have plenty of questions about how to begin.
Anyway, it seems logical to have a Scene object containing Sector objects (which can be frustum culled), with the Sector objects containing lists of objects within those sectors. I can see the use of this being that frustum culling the Sectors would automatically cull all of the objects in that sector if done correctly. It also seems logical to have Appearance objects associated with the Sector objects so that those Apperances can be shared.
So, if I were to rig this up, I can imagine a set of calls like:
// Called from drawing loop
myScene.draw();
// Method of Scene
public void draw(GL gl)
{
for(int i=0; i<sectorList.length; i++)
{
sectorList[i].draw(GL gl);
}
}
// Method of Sector
public void draw(GL gl)
{
for(int i=0; i<objectList.length; i++)
{
objectList[i].draw(GL gl);
}
}
// Method of gameObject
public void draw(GL gl)
{
// Use the vertex arrays and associated
// Appearance object to render the objects
// individual polygons
}
All of that sounds OK until I remember that there isn’t any state sorting at all. There clearly needs to be a list of some sort at the global level so that all of these things can BE state sorted, collision detected, etc.
My problems:
-
If I place references to the gameObjects in the global lists, how do the individual polygons making up those complex objects get sorted?
-
If there is a global list of objects, then I don’t need to
call draw() down the hierarchy, I could just call draw() on the global list. BUT, then how do I do the frustum culling of the objects in each sector? I could imagine having a flag in each object to set it’s drawable state, and then flipping them all on or off based on the results of the frustum cullilng, but that can’t be right.
If someone has the patience to answer this and the myriad of other questions I’m going to have, my hat is off to you
I have no doubt that an answer to these 2 questions will cause me to have many more…
Thanks,
Keith
p.s. Thanks Mithrandir for writing those lengthy post. I have them printed and saved