source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBBox.cpp @ 731

Revision 731, 2.0 KB checked in by igarcia, 19 years ago (diff)
Line 
1
2#include <IMGBBox.h>
3
4namespace IMG {
5
6BBox::BBox()
7{
8        BBox::initialize();
9}
10
11BBox::~BBox()
12{
13}
14
15void BBox::initialize()
16{
17        mMinimum.x =  BOUNDINGBOX_MAXVALUE;
18    mMinimum.y =  BOUNDINGBOX_MAXVALUE;
19    mMinimum.z =  BOUNDINGBOX_MAXVALUE;
20    mMaximum.x = -BOUNDINGBOX_MAXVALUE;
21    mMaximum.y = -BOUNDINGBOX_MAXVALUE;
22    mMaximum.z = -BOUNDINGBOX_MAXVALUE;
23}
24
25Ogre::Vector3 BBox::getMinimum()
26{
27        return mMinimum;
28}
29
30Ogre::Vector3 BBox::getMaximum()
31{
32        return mMaximum;
33}
34
35void BBox::addBoundingVector3(float x, float y, float z)
36{
37    if (x < mMinimum.x)
38        {
39                mMinimum.x = x;
40        }
41       
42        if (x > mMaximum.x)
43        {
44                mMaximum.x = x;
45        }
46
47    if (y < mMinimum.y)
48        {
49                mMinimum.y = y;
50        }
51       
52        if (y > mMaximum.y)
53        {
54                mMaximum.y = y;
55        }
56
57    if (z < mMinimum.z)
58        {
59                mMinimum.z = z;
60        }
61       
62        if (z > mMaximum.z)
63        {
64                mMaximum.z = z;
65        }
66}
67
68void BBox::print()
69{
70        Ogre::LogManager::getSingleton().logMessage("\nValor de la Caixa: (" + Ogre::StringConverter::toString(mMinimum) + ") - (" + + ") " + Ogre::StringConverter::toString(mMaximum));
71}
72
73Ogre::Vector3 BBox::getCorner(int corner) const
74{
75    Ogre::Vector3 vector;       
76    switch (corner)
77    {
78                case BOX_CORNER_xyz: vector = Ogre::Vector3(mMinimum.x, mMinimum.y, mMinimum.z ); break;
79        case BOX_CORNER_xyZ: vector = Ogre::Vector3(mMinimum.x, mMinimum.y, mMaximum.z ); break;
80        case BOX_CORNER_xYz: vector = Ogre::Vector3(mMinimum.x, mMaximum.y, mMinimum.z ); break;
81        case BOX_CORNER_xYZ: vector = Ogre::Vector3(mMinimum.x, mMaximum.y, mMaximum.z ); break;
82        case BOX_CORNER_Xyz: vector = Ogre::Vector3(mMaximum.x, mMinimum.y, mMinimum.z ); break;
83        case BOX_CORNER_XyZ: vector = Ogre::Vector3(mMaximum.x, mMinimum.y, mMaximum.z ); break;
84        case BOX_CORNER_XYz: vector = Ogre::Vector3(mMaximum.x, mMaximum.y, mMinimum.z ); break;
85        case BOX_CORNER_XYZ: vector = Ogre::Vector3(mMaximum.x, mMaximum.y, mMaximum.z ); break;
86    }
87   
88    return vector;
89}
90
91bool BBox::intersects(Ogre::Vector3 v)
92{
93        return Ogre::AxisAlignedBox::intersects(v);
94}
95
96}
Note: See TracBrowser for help on using the repository browser.