Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/OpenEXR/Imath/ImathFrustum.h  view on Meta::CPAN

///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
// 
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// *       Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// *       Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// *       Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission. 
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////



#ifndef INCLUDED_IMATHFRUSTUM_H
#define INCLUDED_IMATHFRUSTUM_H


#include "ImathVec.h"
#include "ImathPlane.h"
#include "ImathLine.h"
#include "ImathMatrix.h"
#include "ImathLimits.h"
#include "ImathFun.h"
#include "ImathNamespace.h"

#include "IexMathExc.h"

IMATH_INTERNAL_NAMESPACE_HEADER_ENTER

//
//  template class Frustum<T>
//
//  The frustum is always located with the eye point at the
//  origin facing down -Z. This makes the Frustum class
//  compatable with OpenGL (or anything that assumes a camera
//  looks down -Z, hence with a right-handed coordinate system)
//  but not with RenderMan which assumes the camera looks down
//  +Z. Additional functions are provided for conversion from
//  and from various camera coordinate spaces.
//
//  nearPlane/farPlane: near/far are keywords used by Microsoft's
//  compiler, so we use nearPlane/farPlane instead to avoid
//  issues.


template<class T>
class Frustum
{
  public:
    Frustum();
    Frustum(const Frustum &);
    Frustum(T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false);
    Frustum(T nearPlane, T farPlane, T fovx, T fovy, T aspect);
    virtual ~Frustum();

    //--------------------
    // Assignment operator
    //--------------------

    const Frustum &     operator = (const Frustum &);

    //--------------------
    //  Operators:  ==, !=
    //--------------------
    
    bool                operator == (const Frustum<T> &src) const;
    bool                operator != (const Frustum<T> &src) const;

    //--------------------------------------------------------
    //  Set functions change the entire state of the Frustum
    //--------------------------------------------------------

    void                set(T nearPlane, T farPlane,
                            T left, T right,
                            T top, T bottom,
                            bool ortho=false);

    void                set(T nearPlane, T farPlane, T fovx, T fovy, T aspect);

    //------------------------------------------------------
    //	These functions modify an already valid frustum state
    //------------------------------------------------------

    void                modifyNearAndFar(T nearPlane, T farPlane);
    void                setOrthographic(bool);

    //--------------
    //  Access
    //--------------
    
    bool                orthographic() const  { return _orthographic; }
    T                   nearPlane() const     { return _nearPlane;    }
    T                   hither() const        { return _nearPlane;    }
    T                   farPlane() const      { return _farPlane;     }
    T                   yon() const           { return _farPlane;     }
    T                   left() const          { return _left;         }
    T                   right() const         { return _right;        }



( run in 1.495 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )