#include "gpuCacheUnitBoundingBox.h"
namespace GPUCache {
boost::shared_ptr<const IndexBuffer> UnitBoundingBox::fBoundingBoxIndices;
boost::shared_ptr<const VertexBuffer> UnitBoundingBox::fBoundingBoxPositions;
{
return sBoundingBox;
}
boost::shared_ptr<const IndexBuffer>& UnitBoundingBox::indices()
{
if (!fBoundingBoxIndices) {
const IndexBuffer::index_t indices[24] = {
0, 1, 1, 2, 2, 3, 3, 0,
4, 5, 5, 6, 6, 7, 7, 4,
0, 4, 1, 5, 2, 6, 3, 7
};
boost::shared_array<IndexBuffer::index_t> indicesArray(new IndexBuffer::index_t[24]);
memcpy(indicesArray.get(), indices, sizeof(IndexBuffer::index_t)*24);
fBoundingBoxIndices = IndexBuffer::create(
SharedArray<IndexBuffer::index_t>::create(indicesArray, 24));
}
return fBoundingBoxIndices;
}
boost::shared_ptr<const VertexBuffer>& UnitBoundingBox::positions()
{
if (!fBoundingBoxPositions) {
const float positions[24] = {
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
};
boost::shared_array<float> positionsArray(new float[24]);
memcpy(positionsArray.get(), positions, sizeof(float)*24);
fBoundingBoxPositions = VertexBuffer::createPositions(
SharedArray<float>::create(positionsArray, 24));
}
return fBoundingBoxPositions;
}
void UnitBoundingBox::clear()
{
fBoundingBoxIndices.reset();
fBoundingBoxPositions.reset();
}
{
boundingBox.
depth() / 2.0f);
boundingBoxMatrix[3][0] = offset[0];
boundingBoxMatrix[3][1] = offset[1];
boundingBoxMatrix[3][2] = offset[2];
boundingBoxMatrix[0][0] = scale[0];
boundingBoxMatrix[1][1] = scale[1];
boundingBoxMatrix[2][2] = scale[2];
return boundingBoxMatrix;
}
}