root/juggler/tags/1.0.5/Kernel/vjProjection.cpp

Revision 2828, 3.1 kB (checked in by patrickh, 8 years ago)

Updated the copyright to what ISU's lawyers decided they want now.
The vast majority of this was done using Kevin's auto-copyright.pl script
which definitely made this easier. All the copyright blocks now have
begin and end tags so that if and when we have to update the copyright
information again, it will be even simpler.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998, 1999, 2000 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  * -----------------------------------------------------------------
26  * File:          $RCSfile$
27  * Date modified: $Date$
28  * Version:       $Revision$
29  * -----------------------------------------------------------------
30  *
31  *************** <auto-copyright.pl END do not edit this line> ***************/
32
33
34 #include <Kernel/vjProjection.h>
35
36 float vjProjection::mNearDist = 0.1f;
37 float vjProjection::mFarDist = 10000.0f;
38
39
40 //: Helper to the frustum apex and corners in model coordinates
41 //!NOTE: The normal frustum is in camera (clip) coordinates
42 //+      and the model is in model (eye) coordinates.
43 //+      The matrix viewMat transforms from eye to clip
44 void vjProjection::getFrustumApexAndCorners(vjVec3& apex, vjVec3& ur, vjVec3& lr, vjVec3& ul, vjVec3& ll)
45 {
46    vjMatrix view_mat_inv;
47    view_mat_inv.invert(mViewMat);   // Get the inverse matrix
48
49    //float near_dist = mFocusPlaneDist;
50    // User like triangles to get the params for the focus surface
51    float mult_factor = mFocusPlaneDist/mFrustum[vjFrustum::VJ_NEAR];
52    float bot = mFrustum[vjFrustum::VJ_BOTTOM]*mult_factor;
53    float left = mFrustum[vjFrustum::VJ_LEFT]*mult_factor;
54    float top = mFrustum[vjFrustum::VJ_TOP]*mult_factor;
55    float right = mFrustum[vjFrustum::VJ_RIGHT]*mult_factor;
56
57    // Create points in clip space
58    vjVec3 apexClip(0.0f, 0.0f, 0.0f);
59    vjVec3 urClip(right, top, -mFocusPlaneDist);
60    vjVec3 lrClip(right, bot, -mFocusPlaneDist);
61    vjVec3 ulClip(left, top, -mFocusPlaneDist);
62    vjVec3 llClip(left, bot, -mFocusPlaneDist);
63
64    apex.xformFull(view_mat_inv, apexClip);
65    ur.xformFull(view_mat_inv, urClip);
66    lr.xformFull(view_mat_inv, lrClip);
67    ul.xformFull(view_mat_inv, ulClip);
68    ll.xformFull(view_mat_inv, llClip);
69 }
70
71
72 std::ostream& vjProjection::outStream(std::ostream& out)
73 {
74    out << "eye: ";
75    switch(mEye)
76    {
77    case vjProjection::LEFT:
78       out << "Left";
79       break;
80    case vjProjection::RIGHT:
81       out << "Right";
82       break;
83    }
84    out << "  Frustum: " << mFrustum;
85    return out;
86 }
87
88 std::ostream& operator<<(std::ostream& out, vjProjection& proj)
89 {
90    return proj.outStream(out);
91 }
Note: See TracBrowser for help on using the browser.