To warm for thinking... I need math help.

Started by
13 comments, last by mind in a box 13 years, 10 months ago
So it is like this?
	int x=0;	int y=0;	int z=0;		x=Where->x / (GridSize.x/ChunkDivisions);	y=Where->y / (GridSize.y/ChunkDivisions);	z=Where->z / (GridSize.z/ChunkDivisions);	int Result=0;	Result += x * pow(NumberOfChunks,2);	Result += y * pow(NumberOfChunks,1);	Result += z * pow(NumberOfChunks,0);

(GridSize is the whole volume size)

Am I right?
Advertisement
If GridSize.x, GridSize.y and GridSize.z are different, then the number reconstruction would be different.

Really, it would be very good to know what your problem really is, not just a few examples that don't cover the actual complexity you have to deal with. In any case, you should be able to get it to work with what you have now.
Okay, they *may* could differ. So I'll explain what I have:

I use the PolyVox library to convert a Voxel-Volume to polygon meshes. So, for now I have a Voxel-Volume at the size of 64x64x64 (Which can change when the user wants, even to something like 32x64x64). In the Terrain Editor when you place a sphere into the voxel-volume, the polygon mesh has to get regenerated. However, doing it for thw whole volume would be a waste of performance. Thats the reason I would like to break the polygon meshes into different chunks. So only a few (1 or more) would have to get regenerated from the volume (I am able to convert only the region I wish from the voxel-volume). That saves much performance, allows me to have higher resolutions, makes culling and LOD easier, and it also helps me with layered textures on top of my terrain.

Here is how I thought I can do it:

- Place the Voxel sphere somewhere into the Volume
- Check the chunks which are near to the sphere location (With that function above, treat the sphere as a cube and check it's corners)
- Regenerate the intersecting chunks

This way, the player will also be able to throw a grenade onto the terrain and to produce a hole with that - very smoothly :)

I hope you understand why I need that now...
Oh, it looks like your code above would work just fine. I thought you were dividing some dimensions into different numbers of chunks, but I see now that that's not the case.
Okay, thank you for your help! :)

This topic is closed to new replies.

Advertisement