RE: [Algorithms] Non uniform scaling spheres.
Brought to you by:
vexxed72
From: Martin F. <mf...@at...> - 2002-12-17 13:49:26
|
Hi, My solution to this problem was to store the axis aligned bounding box in object space. (Top level of my collision tree for each object) When the scale is changed I transform the axis aligned box's midpoint and one extreme to world space using the new scale matrix and rebuild the sphere from these two points. This method gives you a world space sphere so you don't need to transform it each frame to world space. You must remember to move it however if the object moves. This technique doens't give you a minimum sphere but it's often alot better than just scaling the sphere using the maximum scale component. Cheers, Martin -----Original Message----- From: gda...@li... [mailto:gda...@li...]On Behalf Of Tom van Dijck Sent: 17 December 2002 12:37 To: gda...@li... Subject: [Algorithms] Non uniform scaling spheres. Hi, My culling stuff uses bounding spheres to cull against frustum. However I also support non-uniform scaling... When one of my objects is scaled in a non uniform way my spheres obviously are all wrong or not spheres anymore.. I tried to get the dominant axis from the scaling matrix, and scale my sphere using that. which does work only in the cases that the non uniform scaling is applied along one of the axis (x,y or z). And off course one of my artists does not. The question now is, is there a way to scale the sphere using the matrix which is used for the Geometry, and retain the shape of the sphere, as in, it must stay a sphere, not an ellipsis thing. Off course I could run through all the vertices and scale them using the matrix and calculate the sphere using that.... but I'm trying to keep it somewhat fast.. I currently do something like: (pseudo style) m_Bound = geometry->GetBound(); m_Bound.position = matrix * m_Bound.position; point3 p1 = matrix.right() * m_Bound.radius; point3 p2 = matrix.up() * m_Bound.radius; point3 p3 = matrix.forward() * m_Bound.radius; point3 radius; radius.x = p1.length(); radius.y = p2.length(); radius.z = p3.length(); m_Bound.radius = radius.maxcomponent(); // returns the max of x,y and z. Tom van Dijck mudGE Entertainment. ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/ _______________________________________________ GDAlgorithms-list mailing list GDA...@li... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 intY has scanned this email for all known viruses (www.inty.com) |