1 | |
---|
2 | #include <IMGBBox.h> |
---|
3 | |
---|
4 | namespace IMG { |
---|
5 | |
---|
6 | BBox::BBox() |
---|
7 | { |
---|
8 | BBox::initialize(); |
---|
9 | } |
---|
10 | |
---|
11 | BBox::~BBox() |
---|
12 | { |
---|
13 | } |
---|
14 | |
---|
15 | void 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 | |
---|
25 | Ogre::Vector3 BBox::getMinimum() |
---|
26 | { |
---|
27 | return mMinimum; |
---|
28 | } |
---|
29 | |
---|
30 | Ogre::Vector3 BBox::getMaximum() |
---|
31 | { |
---|
32 | return mMaximum; |
---|
33 | } |
---|
34 | |
---|
35 | void 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 | |
---|
68 | void BBox::print() |
---|
69 | { |
---|
70 | Ogre::LogManager::getSingleton().logMessage("\nValor de la Caixa: (" + Ogre::StringConverter::toString(mMinimum) + ") - (" + + ") " + Ogre::StringConverter::toString(mMaximum)); |
---|
71 | } |
---|
72 | |
---|
73 | Ogre::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 | |
---|
91 | bool BBox::intersects(Ogre::Vector3 v) |
---|
92 | { |
---|
93 | return Ogre::AxisAlignedBox::intersects(v); |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|