Reverted some of ker's changes to bring back the concepts of width, height, and depth.
This commit is contained in:
@ -58,9 +58,9 @@ void OpenGLWidget::setVolume(PolyVox::Volume<MaterialDensityPair44>* volData)
|
||||
//If we have any volume data then generate the new surface patches.
|
||||
if(m_volData != 0)
|
||||
{
|
||||
m_uVolumeWidthInRegions = g_uVolumeSideLength / m_uRegionSideLength;
|
||||
m_uVolumeHeightInRegions = g_uVolumeSideLength / m_uRegionSideLength;
|
||||
m_uVolumeDepthInRegions = g_uVolumeSideLength / m_uRegionSideLength;
|
||||
m_uVolumeWidthInRegions = volData->getWidth() / m_uRegionSideLength;
|
||||
m_uVolumeHeightInRegions = volData->getHeight() / m_uRegionSideLength;
|
||||
m_uVolumeDepthInRegions = volData->getDepth() / m_uRegionSideLength;
|
||||
|
||||
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
|
||||
//This three-level for loop iterates over each region.
|
||||
@ -180,9 +180,8 @@ void OpenGLWidget::paintGL()
|
||||
glMatrixMode(GL_MODELVIEW); // Select The Model View Matrix
|
||||
glLoadIdentity(); // Reset The Current Modelview Matrix
|
||||
|
||||
float diag_len = sqrtf(static_cast<float>(255 * 255 * 3));
|
||||
//Moves the camera back so we can see the volume
|
||||
glTranslatef(0.0f, 0.0f, -diag_len);
|
||||
glTranslatef(0.0f, 0.0f, -m_volData->getDiagonalLength());
|
||||
|
||||
glRotatef(m_xRotation, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(m_yRotation, 0.0f, 1.0f, 0.0f);
|
||||
@ -249,8 +248,7 @@ void OpenGLWidget::setupProjectionMatrix(void)
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
float diag_len = sqrtf(static_cast<float>(255 * 255 * 3));
|
||||
float frustumSize = diag_len / 2.0f;
|
||||
float frustumSize = m_volData->getDiagonalLength() / 2.0f;
|
||||
float aspect = static_cast<float>(width()) / static_cast<float>(height());
|
||||
|
||||
glOrtho(frustumSize*aspect, -frustumSize*aspect, frustumSize, -frustumSize, 1.0, 5000);
|
||||
|
@ -27,19 +27,17 @@ freely, subject to the following restrictions:
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
const uint16_t g_uVolumeSideLength = 128;
|
||||
|
||||
void createSphereInVolume(Volume<MaterialDensityPair44>& volData, float fRadius, uint8_t uValue)
|
||||
{
|
||||
//This vector hold the position of the center of the volume
|
||||
Vector3DFloat v3dVolCenter( g_uVolumeSideLength / 2, g_uVolumeSideLength / 2, g_uVolumeSideLength / 2);
|
||||
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
|
||||
|
||||
//This three-level for loop iterates over every voxel in the volume
|
||||
for (int z = 0; z < g_uVolumeSideLength ; z++)
|
||||
for (int z = 0; z < volData.getWidth(); z++)
|
||||
{
|
||||
for (int y = 0; y < g_uVolumeSideLength; y++)
|
||||
for (int y = 0; y < volData.getHeight(); y++)
|
||||
{
|
||||
for (int x = 0; x < g_uVolumeSideLength; x++)
|
||||
for (int x = 0; x < volData.getDepth(); x++)
|
||||
{
|
||||
//Store our current position as a vector...
|
||||
Vector3DFloat v3dCurrentPos(x,y,z);
|
||||
|
@ -72,7 +72,7 @@ void exampleLog(string message, int severity)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
logHandler = &exampleLog;
|
||||
Volume<MaterialDensityPair44> volData;
|
||||
Volume<MaterialDensityPair44> volData(g_uVolumeSideLength, g_uVolumeSideLength, g_uVolumeSideLength);
|
||||
|
||||
//Make our volume contain a sphere in the center.
|
||||
int32_t minPos = 0;
|
||||
|
Reference in New Issue
Block a user