Re: [Algorithms] Clipping against OBBs
Brought to you by:
vexxed72
From: Nicolas S. <nic...@ch...> - 2000-08-15 00:06:31
|
I personally store OBBs as : - center - normalized axis - half width This is not the best choice for size, but althought I consider it gives the best speed compromise for my applications of OBBs. Althought my primary concern was culling against planes of the view frustrum and occluding volumes, I was also using them for test purposes as you do.. There is a pretty nice algorithm here http://www.cs.unc.edu/~hoff/research/vfculler/boxplane.html. This deals with testing an OBB against planes, so not your application, but I really like his approach, and it might apply to your case too, so it's worth reading. I used techniques based on this one very agressively and it is _really_ effective. If you are interested in plane equation, you almost have it in that format; axis being plane normals; you have (a,b,c) of ax+by+cz+d=0. I prefer to store them with normalized axis because I consider it is the best compromise for my different applciations of OBBs. But if you almost always work with the planes of the obb, you might want to replace box center+half width with "d" values. It might be less easier to use if your OBB is frequently transformed. But anyway, if you already have a functional software clipping pipeline, the easiest way is to express your world coordinates in bbox coordinates (the transformation is straightforward if you have obb axes). Using half width/normalized axis makes you clip against (-half_width,+half_width). Using "tweaked" (1 / half_width) non normalized axis makes you clip against (-1,+1). The latests seems easier, especially if you already have a working homogenous clipping pipeline. You just have to set w to 1, and care about the (z<-w) issue (and not z<0 as usal)... It even allows you to use extremely efficiently some buggy SIMD instructions that are not well suited for classical frustrum clipping, but are perfectly suited for that. If you do that, you will need to store extra information (which is basically the inverse of the world->box space transformation previously stored) to be able to transform your clipped results into viewport space (which is, I suppose your final goal). As my code that did the clip was ultra-experiental-debug-stuff, I did a brute force matrix inversion, and I definitely don't recommend it! ----- Original Message ----- From: "Doug Chism" <dc...@d-...> To: <gda...@li...> Sent: Monday, August 14, 2000 10:20 PM Subject: [Algorithms] Clipping against OBBs > Does anyone know of any good code sources for fast clipping of > lines/triangles against OBBs? I guess the idea would be to pull the planes > out of the OBB and clip against them - something along that line of thought? > If you are keeping track of the Center, Corner, Axes, Normalized Axes, and > Half Size, whats the fastest way to get the 6 plane equations of the OBB > from that ( or if cheaper/faster clipping approach available is there info > on that? ) > > Doug Chism > > > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |