Polygon Clump

support for the ARM toolchain
Post Reply
tiga
Posts: 7
Joined: Fri May 15, 2009 1:17 pm

Polygon Clump

Post by tiga » Mon May 18, 2009 8:14 pm

Hi there again. I have posted the problem I (still) have in a thread before, but as this thread is about an error happening in the newer universal binary versions of the ndstool that seems to be occuring on my PPC Mac while compiling, I'll start a new one.

I'll explain it again: I wrote my 'own' engine using BSP trees for drawing and collision detecting. It works fine on my Mac and PC, but it does not on my DS. This makes me quite sad... :-(
I guess it's something about the hardware (or communicating with the hardware) that fails -- the program loads the map succesfully, collision detection works perfect, placing the start location for the camera using the vertices of a specific polygon is correct. Only process that fails is the drawing -- all vertices of every polygon are totally misplaced and all polygons are overlapping.

The 'world' is structured as follows:
Vertices, polygons and BSP trees are stored in an array in a CPP file created with 'new'. So, by saying 'vertex', 'polygon' or 'BSP tree', I'm referencing to an element of these arrays.
Vertices just have the members 'x', 'y', 'z' (nothing special, I know).
Polygons have 6 pointers to planes (forming the edges of that polygon) created within the polygon, 3 pointers to vertices, and members 'x', 'y', 'z', 'd' -- representing the plane of that polygon (those 6 planes too have these members, of course).
BSP trees have a pointer to a polygon representing the hyperplane, a vector containing pointers to polygons, and pointers to the 'front' and 'back' node (BSP trees).

This is how polygons are drawn (not original code):

Code: Select all

vector<Polygon*> pvector;
Polygon *polygon= NULL;

for (int i= 0; i< vector.size(); i++) {
    polygon= pvector.at(i);
    glVertex3f(polygon->vertex0->x, polygon->vertex0->y, polygon->vertex0->z);
    glVertex3f(polygon->vertex1->x, polygon->vertex1->y, polygon->vertex1->z);
    glVertex3f(polygon->vertex2->x, polygon->vertex2->y, polygon->vertex2->z);
}
This is the sequence of code:
main -> DrawFrame (glLoadIdentity, glRotatef, glTransferf, glBegin) -> DrawTree (iterating through every tree) -> DrawPolygons (code above) --> back in DrawFrame (glEnd, glFlush)

So, nothing special. But this is what happens:
Image
This is what it should look and looks like in the SDL version (Mac & PC).

Image
And this is the result on both a real DS and Desmume.
I colored the vertices to make visible how much the scene is messed up.

As loading the map and collision detection works 100%, I have absolutely no clue what's going on...
Does anyone else know what could be wrong??

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests