Re: Too lazy to find an algorithm myself :-)
Jorrit Tyberghein <[email protected]>
| Newsgroups | gmane.comp.graphics.crystalspace.devel |
|---|---|
| Message-ID | <CAA49VVL5gcKL--G6BB5CvDbTpW2sy-j438mY_xyxsSVDLaU-GQ@mail.gmail.com> |
Thanks for the replies. Actually I found out that csMeshOnTexture::ScaleCamera() currently is already correct. The problem was that I was using it wrong in CEL. But thanks to the tips below below I could confirm this and I'm busy fixing it in CEL. Greetings, On Fri, May 11, 2012 at 9:11 PM, Mat Sutcliffe <[email protected]>wrote: > Might not be the perfect solution, but I suppose you could use > csBox3::ProjectBox() to project the box as a csBox2 on the view plane, then > multiply the camera distance by the ratio of bounding box dimension to view > box dimension. Whether dimension means width or height would depend on a > comparison between the ratio of bbox width and height and the ratio of vbox > width and height. > > csBox2 bbox; > float minz, maxz; > if (input_box.ProjectBox (camera->GetTransform (), camera->GetFOV (), 0, > 0, bbox, minz, maxz)) > { > float dist = (input_box.GetCenter () - camera->GetTransform ().GetOrigin > ()).Norm (); > > float bbox_girth = (bbox.MaxX () - bbox.MinX ()) / (bbox.MaxY () - > bbox.MinY ()); > float vbox_girth = (vbox.MaxX () - vbox.MinX ()) / (vbox.MaxY () - > vbox.MinY ()); > if (bbox_girth > vbox_girth) > { > return dist * (bbox.MaxX () - bbox.MinX ()) / (vbox.MaxX () - > vbox.MinX ()); > } > else > { > return dist * (bbox.MaxY () - bbox.MinY ()) / (vbox.MaxY () - > vbox.MinY ()); > } > } > // not tested ;) > > > On 11 May 2012 15:21, Jorrit Tyberghein <[email protected]>wrote: > >> So I just ask you guys. >> >> Given an axis aligned bounding box in world space and given a camera that >> is located >> at a certain spot in the world I would like to calculate at which the >> camera has to be >> so that the entire bounding box is exactly visible in the given view >> rectangle. So assume >> there is a line between the center of the box going through the current >> camera position. >> I want a new position on that line where the camera can see the bounding >> box (assuming >> it is oriented so that it looks at the center of the bounding box) and >> the box is just visible >> in the view rectangle. >> >> Any takers? :-) >> >> Thanks in advance, >> >> -- >> Project Manager of Crystal Space (http://www.crystalspace3d.org) >> and CEL (http://cel.crystalspace3d.org) >> Support Crystal Space. Donate at >> https://sourceforge.net/donate/index.php?group_id=649 >> Personal page: http://users.telenet.be/jorritTyberghein/ >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Crystal-develop mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/crystal-develop >> >> > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Crystal-develop mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/crystal-develop > > -- Project Manager of Crystal Space (http://www.crystalspace3d.org) and CEL (http://cel.crystalspace3d.org) Support Crystal Space. Donate at https://sourceforge.net/donate/index.php?group_id=649 Personal page: http://users.telenet.be/jorritTyberghein/ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Crystal-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-develop