Search the Community
Showing results for tags 'quadtree'.
-
- 1 comment
-
- 1
-
- first person shooter
- quadtree
- (and 10 more)
-
Hi, I'm doing a planet generator for my game. But I've some problems with the c++ libnoise. I successfully generated a quadtree (maybe with a bad algo... ^^') and successfully transformed it into a sphere according to this great blog. But now, I want to apply a perlin noise using the c++ libnoise library. But the render is not really good... But I think I'm in the right way. My problem is about the noise coherence between each faces of my cube. The faces are not joined. Here is a screenshot. I do this following code to generate one face of my cube : //generating the front face... Surface* frontFace = model->AddSurface(); for(int i = 0 ; i<numSquare ; i++) { for(int j = 0 ; j<numSquare ; j++) { float x = -1+i*segment; float y = -1+j*segment; float z = -1; float dx = (x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0))) * Radius; //transform into sphere float dy = (y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0))) * Radius; float dz = (z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0))) * Radius; float ndz = dz + perlinModule.GetValue(dx,dy,dz);//generate noise int v0 = frontFace->AddVertex(dx,dy,ndz); x = -1+(i*segment)+segment; y = -1+j*segment; z = -1; dx = (x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0))) * Radius; dy = (y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0))) * Radius; dz = (z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0))) * Radius; ndz = dz + perlinModule.GetValue(dx,dy,dz); int v1 = frontFace->AddVertex(dx,dy,ndz); x = -1+(i*segment)+segment; y = -1+(j*segment)+segment; z = -1; dx = (x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0))) * Radius; dy = (y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0))) * Radius; dz = (z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0))) * Radius; ndz = dz + perlinModule.GetValue(dx,dy,dz); int v2 = frontFace->AddVertex(dx,dy,ndz); x = -1+i*segment; y = -1+(j*segment)+segment; z = -1; dx = (x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0))) * Radius; dy = (y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0))) * Radius; dz = (z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0))) * Radius; ndz = dz + perlinModule.GetValue(dx,dy,dz); int v3 = frontFace->AddVertex(dx,dy,ndz); frontFace->AddTriangle(v2,v1,v0); frontFace->AddTriangle(v0,v3,v2); } } I don't know how to solve this. I didn't find good explanations on the web. I'm not really good in maths but I've some logic ideas (I think ...), it's a miracle if this code works xD. Maybe it's my cube generation algorythm which is bad... I understood that some others use a lerp function to join "smoothly" each faces, but I don't know how I can apply this to my code. ^^' If someone can help it would be great. Thx ! PS: I'm french so really sorry for my english