#### Archived

This topic is now archived and is closed to further replies.

# More geomipmapping trouble

This topic is 5756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m trying to get geomipmapping to work, but I can''t. I can''t even throw away half the vertices for each block. This is the code I''m using:

int TerrainBlock::ThrowOutVerts(float (*vectors)[17][3], int width, int height)
{
float tmpvects[17][17][3];
memcpy(tmpvects, vectors, sizeof(tmpvects));

for (int z = 0; z < height / 2 + 1; z++)
for (int x = 0; x < width / 2+1; x++)
{
tmpvects[x][z][0] = vectors[x * 2][z*2][0];
tmpvects[x][z][1] = vectors[x*2][z*2][1];
tmpvects[x][z][2] = vectors[x*2][z*2][2];
}

memcpy(vectors, tmpvects, sizeof(vectors));
return(0);
}

Its called once for each mipmap level, using the mip map level before it. Width and height are the width of the block being passed, not the one it wants to get back. When I use this code, it doesn''t work. Vertices are being thrown out, but the blocks aren''t big enough. It looks like this. Can anyone help me out? I''m getting depressed cause i can''t even get this simple thing to work.

##### Share on other sites
those memcopies really confuse me. if you build the array inside the loop, what exactly is it good for?

what is vector? a pointer to the previous level or a pointer to a copy of it? if its not a copy youre ruining the previous level, if it is a copy you shouldnt need a tmpvects array, since values will only get bigger youre overwriting stuff that wont be needed later anyway.

also.. if your filling tmpvects (which should be only a quarter the size of vector), why do you memcopy sizeof vector elements from an array thats only sizeof vector/4? youre reading from memory you never allocated and therefore shouldnt be. hm.. wait.. why is tmpvects the size of a full patch (17x17) if its supposed to be just half of the previous level?

##### Share on other sites
It looks to me like you''re forgetting to adjust properly for the new grid size; you''re taking the low quarter (0 to 1/2 + 1) of each patch, and copying those vertices.

If what I remember of geomipmapping is still valid, what you should be doing is throwing out each second vertex across the entire patch.

Also..

sizeof(tmpvects) = sizeof(float)* 17 * 17 * 3
sizeof(vectors) = sizeof( float* ) * 17 * 3

##### Share on other sites
Ok, for this code you can pretty much replace anything to do with "vectors" with "vertices." I keep getting the two words mixed up. And the 17X17 patches for even the smaller blocks is basically because of the way I'm keeping up with the different blocks. The blocks are all named stuff like L0Verts, L1Verts, etc. Then I have an array of pointers to those different blocks. Since I'm doing that they all have to be the same size (right?).

quote:
It looks to me like you're forgetting to adjust properly for the new grid size; you're taking the low quarter (0 to 1/2 + 1) of each patch, and copying those vertices.

If what I remember of geomipmapping is still valid, what you should be doing is throwing out each second vertex across the entire patch.

But what about that vectors[x*2][z*2] part? I'm only getting a quarter of the vertices of the original part, but wouldn't the *2 basically move over two vertices, taking every other vertex? Like this:

I'm trying to keep the X's and throw away the 0's. Isn't that what that code is doing?

EDIT: OK, I replaced that crazy stuff that didn't work with this pic.

[edited by - BradDaBug on February 9, 2003 4:10:21 PM]

##### Share on other sites
OOOOOOOOOOOOOOOOOOOOOOHHHH!!! *bangs head against desk* I get it!

quote:
those memcopies really confuse me. if you build the array inside the loop, what exactly is it good for?
quote:
sizeof(tmpvects) = sizeof(float)* 17 * 17 * 3
sizeof(vectors) = sizeof( float* ) * 17 * 3

That was the problem. It was only copying PART of the new block into the, uh, other block! Its ok now. I got rid of the memcopy()''s. Now it works! It works! Thanks a bunch!

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633270
• Total Posts
3011158
• ### Who's Online (See full list)

There are no registered users currently online

×