PixelLightAPI  .
BoundingBox.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: BoundingBox.h                                  *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLMATH_BOUNDINGBOX_H__
00024 #define __PLMATH_BOUNDINGBOX_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLMath/Matrix3x3.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLMath {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Bounding box class
00046 */
00047 class BoundingBox {
00048 
00049 
00050     //[-------------------------------------------------------]
00051     //[ Friends                                               ]
00052     //[-------------------------------------------------------]
00053     friend class Intersect;
00054 
00055 
00056     //[-------------------------------------------------------]
00057     //[ Public functions                                      ]
00058     //[-------------------------------------------------------]
00059     public:
00060         /**
00061         *  @brief
00062         *    Constructor
00063         */
00064         PLMATH_API BoundingBox();
00065 
00066         /**
00067         *  @brief
00068         *    Copy constructor
00069         *
00070         *  @param[in] cSource
00071         *    Source to copy from
00072         */
00073         PLMATH_API BoundingBox(const BoundingBox &cSource);
00074 
00075         /**
00076         *  @brief
00077         *    Destructor
00078         */
00079         PLMATH_API ~BoundingBox();
00080 
00081         /**
00082         *  @brief
00083         *    Copy operator
00084         *
00085         *  @param[in] cSource
00086         *    Source to copy from
00087         *
00088         *  @return
00089         *    Reference to this instance
00090         */
00091         PLMATH_API BoundingBox &operator =(const BoundingBox &cSource);
00092 
00093         /**
00094         *  @brief
00095         *    Returns the size of the bounding box
00096         *
00097         *  @param[out] fX1
00098         *    Receives the x position of corner 1
00099         *  @param[out] fY1
00100         *    Receives the y position of corner 1
00101         *  @param[out] fZ1
00102         *    Receives the z position of corner 1
00103         *  @param[out] fX2
00104         *    Receives the x position of corner 2
00105         *  @param[out] fY2
00106         *    Receives the y position of corner 2
00107         *  @param[out] fZ2
00108         *    Receives the z position of corner 2
00109         */
00110         PLMATH_API void GetSize(float &fX1, float &fY1, float &fZ1, float &fX2, float &fY2, float &fZ2) const;
00111 
00112         /**
00113         *  @brief
00114         *    Set the size of the bounding box
00115         *
00116         *  @param[in] fX1
00117         *    X position of corner 1
00118         *  @param[in] fY1
00119         *    Y position of corner 1
00120         *  @param[in] fZ1
00121         *    Z position of corner 1
00122         *  @param[in] fX2
00123         *    X position of corner 2
00124         *  @param[in] fY2
00125         *    Y position of corner 2
00126         *  @param[in] fZ2
00127         *    Z position of corner 2
00128         */
00129         PLMATH_API void SetSize(float fX1, float fY1, float fZ1, float fX2, float fY2, float fZ2);
00130 
00131         /**
00132         *  @brief
00133         *    Returns corner 1 (min -> world space)
00134         *
00135         *  @param[in] bRotate
00136         *    Rotate corner corresponding to the bounding box?
00137         *
00138         *  @return
00139         *    Corner 1
00140         */
00141         PLMATH_API Vector3 GetCorner1(bool bRotate = true) const;
00142 
00143         /**
00144         *  @brief
00145         *    Returns corner 2 (max -> world space)
00146         *
00147         *  @param[in] bRotate
00148         *    Rotate corner corresponding to the bounding box?
00149         *
00150         *  @return
00151         *    Corner 2
00152         */
00153         PLMATH_API Vector3 GetCorner2(bool bRotate = true) const;
00154 
00155         /**
00156         *  @brief
00157         *    Returns the radius of the bounding sphere
00158         *
00159         *  @return
00160         *    Bounding sphere radius
00161         */
00162         PLMATH_API float GetBoundingSphere() const;
00163 
00164         /**
00165         *  @brief
00166         *    Returns the current position
00167         *
00168         *  @return
00169         *    Current position
00170         */
00171         PLMATH_API const Vector3 &GetPos() const;
00172 
00173         /**
00174         *  @brief
00175         *    Set the current position
00176         *
00177         *  @param[in] fX
00178         *    New x position
00179         *  @param[in] fY
00180         *    New y position
00181         *  @param[in] fZ
00182         *    New z position
00183         */
00184         PLMATH_API void SetPos(float fX = 0.0f, float fY = 0.0f, float fZ = 0.0f);
00185 
00186         /**
00187         *  @brief
00188         *    Set the current position
00189         *
00190         *  @param[in] vPos
00191         *    New position
00192         */
00193         PLMATH_API void SetPos(const Vector3 &vPos);
00194 
00195         /**
00196         *  @brief
00197         *    Returns the current scale
00198         *
00199         *  @return
00200         *    Current scale
00201         */
00202         PLMATH_API const Vector3 &GetScale() const;
00203 
00204         /**
00205         *  @brief
00206         *    Set the current scale
00207         *
00208         *  @param[in] fX
00209         *    New x scale
00210         *  @param[in] fY
00211         *    New y scale
00212         *  @param[in] fZ
00213         *    New z scale
00214         */
00215         PLMATH_API void SetScale(float fX = 1.0f, float fY = 1.0f, float fZ = 1.0f);
00216 
00217         /**
00218         *  @brief
00219         *    Set the current scale
00220         *
00221         *  @param[in] vScale
00222         *    New scale
00223         */
00224         PLMATH_API void SetScale(const Vector3 &vScale);
00225 
00226         /**
00227         *  @brief
00228         *    Returns the current final rotation matrix
00229         *
00230         *  @return
00231         *    Current final rotation matrix
00232         */
00233         PLMATH_API const Matrix3x3 &GetFinalRot() const;
00234 
00235         /**
00236         *  @brief
00237         *    Returns the current rotation matrix
00238         *
00239         *  @return
00240         *    Current rotation matrix
00241         */
00242         PLMATH_API const Matrix3x3 &GetRot() const;
00243 
00244         /**
00245         *  @brief
00246         *    Set the current rotation matrix
00247         *
00248         *  @param[in] mRot
00249         *    New rotation matrix
00250         */
00251         PLMATH_API void SetRot(const Matrix3x3 &mRot);
00252 
00253         /**
00254         *  @brief
00255         *    Returns the current base rotation matrix
00256         *
00257         *  @return
00258         *    Current base rotation matrix
00259         */
00260         PLMATH_API const Matrix3x3 &GetBaseRot() const;
00261 
00262         /**
00263         *  @brief
00264         *    Set the current base rotation matrix
00265         *
00266         *  @param[in] mBaseRot
00267         *    New base rotation matrix
00268         */
00269         PLMATH_API void SetBaseRot(const Matrix3x3 &mBaseRot);
00270 
00271 
00272     //[-------------------------------------------------------]
00273     //[ Private functions                                     ]
00274     //[-------------------------------------------------------]
00275     private:
00276         /**
00277         *  @brief
00278         *    Updates the bounding box values
00279         */
00280         void Update();
00281 
00282 
00283     //[-------------------------------------------------------]
00284     //[ Private data                                          ]
00285     //[-------------------------------------------------------]
00286     private:
00287         // Object space definition of the box
00288         Vector3     m_vCorner1, m_vCorner2;     /**< Corners of the box */
00289         float       m_fW, m_fH, m_fD;           /**< Size of the box (from one corner to the other) */
00290         float       m_fExtX, m_fExtY, m_fExtZ;  /**< Size of the box (extends from the center of the box) */
00291 
00292         // World space coordinates
00293         Vector3     m_vPos;                     /**< Box position */
00294         Vector3     m_vScale;                   /**< Box scale */
00295         Matrix3x3   m_mRot;                     /**< Box rotation */
00296         Matrix3x3   m_mBaseRot;                 /**< Box base rotation */
00297         Matrix3x3   m_mFinalRot;                /**< Box final rotation */
00298         Vector3     m_vCenter;                  /**< Center of the box */
00299         float       m_fRadius;                  /**< Bounding sphere radius */
00300         Vector3     m_vX, m_vY, m_vZ;           /**< Local axis */
00301 
00302 
00303 };
00304 
00305 
00306 //[-------------------------------------------------------]
00307 //[ Namespace                                             ]
00308 //[-------------------------------------------------------]
00309 } // PLMath
00310 
00311 
00312 #endif // __PLMATH_BOUNDINGBOX_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:51
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported