コード例 #1
0
void DebugDraw::draw(const AxisAlignedBox& axisAlignedBox, const Color& color) const
{
	if (!LineGeometryManager::getInstance()->getLineGeometry("Square").get())
	{
		return;
	}

	Matrix4x4 modelMatrix;

	// Front
	modelMatrix.identity();
	modelMatrix.translate(axisAlignedBox.getCenter().getX(), axisAlignedBox.getCenter().getY(), axisAlignedBox.getCenter().getZ());
	modelMatrix.translate(0.0f, 0.0f, axisAlignedBox.getHalfDepth());
	modelMatrix.rotateRzRyRx(0.0f, 0.0f, 0.0f);
	modelMatrix.scale(axisAlignedBox.getHalfWidth(), axisAlignedBox.getHalfHeight(), 0.0f);
	LineGeometryManager::getInstance()->getLineGeometry("Square")->draw(modelMatrix, color);

	// Back
	modelMatrix.identity();
	modelMatrix.translate(axisAlignedBox.getCenter().getX(), axisAlignedBox.getCenter().getY(), axisAlignedBox.getCenter().getZ());
	modelMatrix.translate(0.0f, 0.0f, -axisAlignedBox.getHalfDepth());
	modelMatrix.rotateRzRyRx(0.0f, 0.0f, 0.0f);
	modelMatrix.scale(axisAlignedBox.getHalfWidth(), axisAlignedBox.getHalfHeight(), 0.0f);
	LineGeometryManager::getInstance()->getLineGeometry("Square")->draw(modelMatrix, color);

	// Top
	modelMatrix.identity();
	modelMatrix.translate(axisAlignedBox.getCenter().getX(), axisAlignedBox.getCenter().getY(), axisAlignedBox.getCenter().getZ());
	modelMatrix.translate(0.0f, axisAlignedBox.getHalfHeight(), 0.0f);
	modelMatrix.rotateRzRyRx(0.0f, 0.0f, 90.0f);
	modelMatrix.scale(axisAlignedBox.getHalfWidth(), axisAlignedBox.getHalfDepth(), 0.0f);
	LineGeometryManager::getInstance()->getLineGeometry("Square")->draw(modelMatrix, color);

	// Bottom
	modelMatrix.identity();
	modelMatrix.translate(axisAlignedBox.getCenter().getX(), axisAlignedBox.getCenter().getY(), axisAlignedBox.getCenter().getZ());
	modelMatrix.translate(0.0f, -axisAlignedBox.getHalfHeight(), 0.0f);
	modelMatrix.rotateRzRyRx(0.0f, 0.0f, 90.0f);
	modelMatrix.scale(axisAlignedBox.getHalfWidth(), axisAlignedBox.getHalfDepth(), 0.0f);
	LineGeometryManager::getInstance()->getLineGeometry("Square")->draw(modelMatrix, color);

	// Left and Right not needed
}