   Cube To Sphere
  I'm working on a spherical height map system,ive got the patch generation and the balancing algorithms to work.But im stuck on a little problem ; i cant seem to correctly calculate the devision point.when i dont normalize the vertices ( making the spherical heightmap into a cube ) the subdivision works perfectlyok, so this is my division function.Point is a vector that holds which point to divide around.for now i just send camera.x and camera.y as the point elements.the rest should be self explanatory.void CSurfaceSector::DivideToPoint( CVector2 Point ){// Check if we can divide deeperif( mLevel < SURFACE_LEVELS ){// Mark as dividedmDivided = true;// Mark Children as not dividedmChildren[ 0 ]->mDivided = false;mChildren[ 1 ]->mDivided = false;mChildren[ 2 ]->mDivided = false;mChildren[ 3 ]->mDivided = false;if( Point.y >= 0 ){// Upif( Point.x >= 0 ){// RightPoint -= CVector2( mHalfSize , mHalfSize );mChildren[ CHILD_UP_RIGHT ]->DivideToPoint( Point );}else{// LeftPoint -= CVector2( -mHalfSize , mHalfSize );mChildren[ CHILD_UP_LEFT ]->DivideToPoint( Point );}}else{// Downif( Point.x >= 0 ){// RightPoint -= CVector2( mHalfSize , -mHalfSize );mChildren[ CHILD_DOWN_RIGHT ]->DivideToPoint( Point );}else{// LeftPoint -= CVector2( -mHalfSize , -mHalfSize );mChildren[ CHILD_DOWN_LEFT ]->DivideToPoint( Point );}}}}im starting to have second thoughts about using position values instead of using angles.how do you think i should proceed?[Edited by - LackOfGrace on August 8, 2007 8:30:35 AM]
  does anyone understand what im talking about?   ;  Call the cube's coordinates (x,y,z). If the cube is centered at the origin, then the vector <x,y,z> passes through the cube's center and the point in question.Divide <x,y,z> by sqrt(x^2+y^2+z^2) and you will get a vector in the same direction of length 1. Multiple this by the circles radius to get the desired point.If the cube is not at the origin, you will need to translate it to the origin and then back to its original location.Good luck,eat2thepieseye   ;  well, that wasnt quite the problem.the problem is that when im recalculating the point that is to be used by the lower level i dont account for the bending of the surfaceif( Point.x >= 0 ){// RightPoint -= CVector2( mHalfSize , mHalfSize );// <------ This LinemChildren[ CHILD_UP_RIGHT ]->DivideToPoint( Point );}what will the math be to do this correctly?   ;  i still havent solved it...tonight i will redo the divison system to use rotations instead...   ;  What is a division point? I don't understand what you are talking about.   ;  I really hope this helps you somehow: Mapping a Cube to a Shpere;  accually that seems to be just the right thingwill look at it when i get home   ;  Ok, looked at it, and it is what i need .. inversedi would need a sphere to cube formula   ;  got it to work, thanks for the help   