2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#include "CTriangleBBSelector.h"
|
|
|
|
#include "ISceneNode.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! constructor
|
2007-12-21 07:41:51 -08:00
|
|
|
CTriangleBBSelector::CTriangleBBSelector(const ISceneNode* node)
|
2007-05-20 11:03:49 -07:00
|
|
|
: CTriangleSelector(node)
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
setDebugName("CTriangleBBSelector");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Triangles.set_used(12); // a box has 12 triangles.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Gets all triangles.
|
2009-01-22 07:50:06 -08:00
|
|
|
void CTriangleBBSelector::getTriangles(core::triangle3df* triangles,
|
2007-09-18 07:01:28 -07:00
|
|
|
s32 arraySize, s32& outTriangleCount,
|
2009-01-22 07:50:06 -08:00
|
|
|
const core::matrix4* transform) const
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
|
|
|
if (!SceneNode)
|
2009-01-22 07:50:06 -08:00
|
|
|
return;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
// construct triangles
|
2007-12-21 07:41:51 -08:00
|
|
|
const core::aabbox3d<f32>& box = SceneNode->getBoundingBox();
|
2007-05-20 11:03:49 -07:00
|
|
|
core::vector3df edges[8];
|
|
|
|
box.getEdges(edges);
|
|
|
|
|
|
|
|
Triangles[0].set( edges[3], edges[0], edges[2]);
|
|
|
|
Triangles[1].set( edges[3], edges[1], edges[0]);
|
|
|
|
|
|
|
|
Triangles[2].set( edges[3], edges[2], edges[7]);
|
|
|
|
Triangles[3].set( edges[7], edges[2], edges[6]);
|
|
|
|
|
|
|
|
Triangles[4].set( edges[7], edges[6], edges[4]);
|
|
|
|
Triangles[5].set( edges[5], edges[7], edges[4]);
|
|
|
|
|
|
|
|
Triangles[6].set( edges[5], edges[4], edges[0]);
|
|
|
|
Triangles[7].set( edges[5], edges[0], edges[1]);
|
|
|
|
|
|
|
|
Triangles[8].set( edges[1], edges[3], edges[7]);
|
|
|
|
Triangles[9].set( edges[1], edges[7], edges[5]);
|
|
|
|
|
|
|
|
Triangles[10].set(edges[0], edges[6], edges[2]);
|
|
|
|
Triangles[11].set(edges[0], edges[4], edges[6]);
|
|
|
|
|
|
|
|
// call parent
|
|
|
|
CTriangleSelector::getTriangles(triangles, arraySize, outTriangleCount, transform);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|