Joerg,
Fantastic! Thank you for the screenshots⌠Iâm very excited to see you having the LOD-sphere approach working with the AABBs, and once everything is working Iâd love to see a video if youâd be willing to share! No pressure though.
Perhaps a degrees to radians issue on the AABB transform? Can you post a screenshot of the bug? How are you calculating the angle? I took the non-normalized & non-transformed patch coordinates (i.e. quadtree node from the original cube), normalized the corners, then converted those into rho & phi (elevation and asimuth), and then took the simple average of the for to get both az. and el. [Canât remember if I mentioned this before or not, but I actually pre-distort my quadtree nodes after splitting then in order to fix the âpinchingâ near each cube corner. Itâs a one-line equation, and it successfully removes the pinching, but I donât think itâs cricitcal. Happy to share the code if youâre interested]
With these average angles, I simply concatenated two rotation matrices (one about the x-axis, and one about the z-axis - assuming, your âpolar axisâ is the y-axis, that is) to get the resultant patch-aligned BB rotation matrix.
When debug-visualizing these in camera view, apply the transformation to a cube whose âbottomâ plane has a y-value of rmin, and whose âtopâ plane has a y-value of rmax (again, assuming the y-axis runs through your planetâs poles), and which is centered on the y-axis: i.e. the âleftâ plane of the cube is -N units in the x direction, and the ârightâ plane is +N units in the x direction, where N is the half-width of the patch ONCE NORMALIZED. That last point caught me off-guard at first- you need to calculate the width/length of the AABB after the patch has been normalized. Thereâs probably an equation that could predict this for you, but it was easier to just normalize the patchâs corners to the planetâs radii (use rMax to garuntee complete coverage), then take the distance between tem and save those as width/length.
(Iâm sure there are many qays to accomplish what Iâm desribing - this is simply my approach. It looks like you have the patches displaying just fine!)
You can of course perform this transformation in the opposite direction to put the cameraâs position into the patchâs âaligned coordinate spaceâ, which is neccessary for the LOD-sphere + patch-aligned BB method. Just make sure youâre using the cameraâs position relative to the planetâs origin before applying this transformation, then simply apply the backwards transformation to the cameraâs position (i.e. the same concatenated rotation matrices, just with negated elevation and azimuth values). Itâs efficient to precalculate and store both the âforwardâ and âbackwardsâ transforms.
Again, Iâm very much enjoying watching your progress. Youâre quickly getting to the point where I left my own project (actually, youâve surpassed me in a few areas, where Iâd written the algorithms and built prototypes but hadnât yet incorporated them into the entire engine), so Iâm excited to break new ground with you and try out different ideas if you decide to continue your progress. Great work!
Oh, I forgot to ask - what language are using with Unity? C#?
EDIT- Made a few clarifications, might be worth re-reading if you read this before the edit
.