Merge branch 'master' of https://github.com/worklist/hifi into shifty

This commit is contained in:
Andrzej Kapolka 2013-09-03 11:00:29 -07:00
commit 7c3bb4ecc4
12 changed files with 188 additions and 149 deletions

View file

@ -82,7 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2;
// Startup optimistically with small jitter buffer that
// will start playback on the second received audio packet.
static const float CLIPBOARD_TREE_SCALE = 1.0f;
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
fprintf(stdout, "%s", message.toLocal8Bit().constData());
@ -97,7 +96,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_frameCount(0),
_fps(120.0f),
_justStarted(true),
_clipboard(CLIPBOARD_TREE_SCALE),
_voxelImporter(_window),
_wantToKillLocalVoxels(false),
_audioScope(256, 200, true),
@ -237,6 +235,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
Application::~Application() {
NodeList::getInstance()->removeHook(&_voxels);
NodeList::getInstance()->removeHook(this);
_sharedVoxelSystem.changeTree(new VoxelTree);
}
void Application::initializeGL() {
@ -1207,15 +1207,6 @@ void Application::exportVoxels() {
void Application::importVoxels() {
if (_voxelImporter.exec()) {
qDebug("[DEBUG] Import succedded.\n");
if (_voxelImporter.getImportIntoClipboard()) {
_clipboard.killLocalVoxels();
_voxelImporter.getVoxelSystem()->copySubTreeIntoNewTree(
_voxelImporter.getVoxelSystem()->getVoxelAt(0, 0, 0, 1),
&_clipboard,
true);
_voxelImporter.reset();
}
} else {
qDebug("[DEBUG] Import failed.\n");
}
@ -1230,13 +1221,17 @@ void Application::cutVoxels() {
}
void Application::copyVoxels() {
// switch to and clear the clipboard first...
_sharedVoxelSystem.killLocalVoxels();
if (_sharedVoxelSystem.getTree() != &_clipboard) {
_clipboard.eraseAllVoxels();
_sharedVoxelSystem.changeTree(&_clipboard);
}
// then copy onto it if there is something to copy
VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
if (selectedNode) {
// clear the clipboard first...
_clipboard.killLocalVoxels();
// then copy onto it
_voxels.copySubTreeIntoNewTree(selectedNode, &_clipboard, true);
_voxels.copySubTreeIntoNewTree(selectedNode, &_sharedVoxelSystem, true);
}
}
@ -1257,12 +1252,13 @@ void Application::pasteVoxels() {
args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
}
if (_voxelImporter.getImportWaiting()) {
_voxelImporter.getVoxelSystem()->recurseTreeWithOperation(sendVoxelsOperation, &args);
_voxelImporter.reset();
} else {
_clipboard.recurseTreeWithOperation(sendVoxelsOperation, &args);
_sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args);
if (_sharedVoxelSystem.getTree() != &_clipboard) {
_sharedVoxelSystem.killLocalVoxels();
_sharedVoxelSystem.changeTree(&_clipboard);
}
_voxelEditSender.flushQueue();
if (calculatedOctCode) {
@ -1304,10 +1300,21 @@ void Application::initDisplay() {
void Application::init() {
_voxels.init();
_clipboard.init();
_clipboardViewFrustum.setKeyholeRadius(1000.0f);
_clipboardViewFrustum.calculate();
_clipboard.setViewFrustum(&_clipboardViewFrustum);
_sharedVoxelSystemViewFrustum.setPosition(glm::vec3(TREE_SCALE / 2.0f,
TREE_SCALE / 2.0f,
3.0f * TREE_SCALE / 2.0f));
_sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f);
_sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f);
_sharedVoxelSystemViewFrustum.setFieldOfView(90);
_sharedVoxelSystemViewFrustum.setOrientation(glm::quat());
_sharedVoxelSystemViewFrustum.calculate();
_sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum);
_sharedVoxelSystem.init();
VoxelTree* tmpTree = _sharedVoxelSystem.getTree();
_sharedVoxelSystem.changeTree(&_clipboard);
delete tmpTree;
_voxelImporter.init();
_environment.init();
@ -1318,6 +1325,7 @@ void Application::init() {
_headMouseX = _mouseX = _glWidget->width() / 2;
_headMouseY = _mouseY = _glWidget->height() / 2;
QCursor::setPos(_headMouseX, _headMouseY);
_myAvatar.init();
_myAvatar.setPosition(START_LOCATION);
@ -1325,7 +1333,6 @@ void Application::init() {
_myCamera.setModeShiftRate(1.0f);
_myAvatar.setDisplayingLookatVectors(false);
QCursor::setPos(_headMouseX, _headMouseY);
OculusManager::connect();
if (OculusManager::isConnected()) {
@ -2225,15 +2232,11 @@ void Application::displaySide(Camera& whichCamera) {
glTranslatef(_mouseVoxel.x * TREE_SCALE,
_mouseVoxel.y * TREE_SCALE,
_mouseVoxel.z * TREE_SCALE);
glScalef(_mouseVoxel.s * TREE_SCALE,
_mouseVoxel.s * TREE_SCALE,
_mouseVoxel.s * TREE_SCALE);
glScalef(_mouseVoxel.s,
_mouseVoxel.s,
_mouseVoxel.s);
if (_voxelImporter.getImportWaiting()) {
_voxelImporter.getVoxelSystem()->render(true);
} else {
_clipboard.render(true);
}
_sharedVoxelSystem.render(true);
glPopMatrix();
}

View file

@ -112,6 +112,8 @@ public:
Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
VoxelSystem* getVoxels() { return &_voxels; }
VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; }
VoxelTree* getClipboard() { return &_clipboard; }
Environment* getEnvironment() { return &_environment; }
SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; }
Webcam* getWebcam() { return &_webcam; }
@ -238,10 +240,11 @@ private:
Stars _stars;
VoxelSystem _voxels;
VoxelSystem _clipboard; // if I copy/paste
ViewFrustum _clipboardViewFrustum;
VoxelSystem _voxels;
VoxelTree _clipboard; // if I copy/paste
VoxelImporter _voxelImporter;
VoxelSystem _sharedVoxelSystem;
ViewFrustum _sharedVoxelSystemViewFrustum;
QByteArray _voxelsFilename;
bool _wantToKillLocalVoxels;

View file

@ -34,9 +34,9 @@ const float FIELD_OF_VIEW = 60.0f;
class GLWidget : public QGLWidget {
public:
GLWidget(QWidget* parent = NULL, VoxelSystem* voxelSystem = NULL);
GLWidget(QWidget* parent = NULL);
void setDraw(bool draw) {_draw = draw;}
void setTargetCenter(glm::vec3 targetCenter) {_targetCenter = targetCenter;}
void setTargetCenter(glm::vec3 targetCenter) { _targetCenter = targetCenter; }
protected:
virtual void initializeGL();
@ -61,9 +61,8 @@ private:
int _mouseY;
};
GLWidget::GLWidget(QWidget *parent, VoxelSystem *voxelSystem)
GLWidget::GLWidget(QWidget *parent)
: QGLWidget(parent, Application::getInstance()->getGLWidget()),
_voxelSystem(voxelSystem),
_draw(false),
_a(0.0f),
_h(VERTICAL_ANGLE),
@ -71,6 +70,7 @@ GLWidget::GLWidget(QWidget *parent, VoxelSystem *voxelSystem)
_pressed(false),
_mouseX(0),
_mouseY(0) {
_voxelSystem = Application::getInstance()->getSharedVoxelSystem();
}
void GLWidget::initializeGL() {
@ -110,7 +110,7 @@ void GLWidget::paintGL() {
UP_VECT.x, UP_VECT.y, UP_VECT.z);
if (_draw && _voxelSystem) {
if (_draw) {
glBegin(GL_LINES);
glColor3d(1, 1 ,1);
glVertex3d(0, 0, 0);
@ -134,11 +134,11 @@ void GLWidget::paintGL() {
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 0 );
glEnd();
glScalef(1.0f / TREE_SCALE, 1.0f / TREE_SCALE, 1.0f / TREE_SCALE);
_voxelSystem->render(false);
}
}
void GLWidget::mousePressEvent(QMouseEvent* event) {
_pressed = true;
_mouseX = event->globalX();
@ -158,14 +158,13 @@ void GLWidget::mouseReleaseEvent(QMouseEvent* event) {
_pressed = false;
}
ImportDialog::ImportDialog(QWidget *parent, VoxelSystem* voxelSystem)
ImportDialog::ImportDialog(QWidget *parent)
: QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, IMPORT_FILE_TYPES),
_importButton (IMPORT_BUTTON_NAME, this),
_clipboardImportBox(IMPORT_TO_CLIPBOARD_CHECKBOX_STRING, this),
_previewBox (PREVIEW_CHECKBOX_STRING, this),
_previewBar (this),
_glPreview (new GLWidget(this, voxelSystem)) {
_glPreview (new GLWidget(this)) {
setOption(QFileDialog::DontUseNativeDialog, true);
setFileMode(QFileDialog::ExistingFile);
setViewMode(QFileDialog::Detail);
@ -188,15 +187,18 @@ ImportDialog::ImportDialog(QWidget *parent, VoxelSystem* voxelSystem)
connect(this, SIGNAL(currentChanged(QString)), SLOT(saveCurrentFile(QString)));
connect(&_glTimer, SIGNAL(timeout()), SLOT(timer()));
connect(voxelSystem, SIGNAL(importSize(float,float,float)), SLOT(setGLCamera(float, float, float)));
connect(voxelSystem, SIGNAL(importProgress(int)), &_previewBar, SLOT(setValue(int)));
}
ImportDialog::~ImportDialog() {
delete _glPreview;
}
void ImportDialog::init() {
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
connect(voxelSystem, SIGNAL(importSize(float,float,float)), SLOT(setGLCamera(float,float,float)));
connect(voxelSystem, SIGNAL(importProgress(int)), &_previewBar, SLOT(setValue(int)));
}
void ImportDialog::import() {
_importButton.setDisabled(true);
_clipboardImportBox.setDisabled(true);

View file

@ -23,15 +23,16 @@ class GLWidget;
class ImportDialog : public QFileDialog {
Q_OBJECT
public:
ImportDialog(QWidget* parent = NULL, VoxelSystem* voxelSystem = NULL);
ImportDialog(QWidget* parent = NULL);
~ImportDialog();
void init();
void reset();
bool getWantPreview() const { return _previewBox.isChecked(); }
QString getCurrentFile() const { return _currentFile; }
bool getImportIntoClipboard() const { return _clipboardImportBox.isChecked(); }
void reset();
signals:
void previewToggled(bool);
void accepted();

View file

@ -125,9 +125,15 @@ void SerialInterface::initializePort(char* portname) {
tcflush(_serialDescriptor, TCIOFLUSH);
// this disables streaming so there's no garbage data on reads
write(_serialDescriptor, "SD\n", 3);
if (write(_serialDescriptor, "SD\n", 3) != 3) {
qDebug("Failed.\n");
return;
}
char result[4];
read(_serialDescriptor, result, 4);
if (read(_serialDescriptor, result, 4) != 4) {
qDebug("Failed.\n");
return;
}
tty_set_file_descriptor(_serialDescriptor);
mpu_init(0);

View file

@ -7,29 +7,24 @@
//
#include <VoxelImporter.h>
#include <Application.h>
#include <QFileInfo>
#include <QThreadPool>
static const int IMPORT_SYSTEM_SCALE = 1.0f;
static const int MAX_VOXELS_PER_IMPORT = 2000000;
class ImportTask : public QObject, public QRunnable {
public:
ImportTask(VoxelSystem* voxelSystem, const QString &filename);
ImportTask(const QString &filename);
void run();
private:
VoxelSystem* _voxelSystem;
QString _filename;
QString _filename;
};
VoxelImporter::VoxelImporter(QWidget* parent)
: QObject(parent),
_voxelSystem(IMPORT_SYSTEM_SCALE, MAX_VOXELS_PER_IMPORT),
_initialized(false),
_importWaiting(false),
_importDialog(parent, &_voxelSystem),
_voxelTree(true),
_importDialog(parent),
_currentTask(NULL),
_nextTask(NULL) {
@ -38,6 +33,10 @@ VoxelImporter::VoxelImporter(QWidget* parent)
connect(&_importDialog, SIGNAL(accepted()), SLOT(import()));
}
void VoxelImporter::init() {
_importDialog.init();
}
VoxelImporter::~VoxelImporter() {
if (_nextTask) {
delete _nextTask;
@ -46,16 +45,15 @@ VoxelImporter::~VoxelImporter() {
if (_currentTask) {
disconnect(_currentTask, 0, 0, 0);
_voxelSystem.cancelImport();
_voxelTree.cancelImport();
_currentTask = NULL;
}
}
void VoxelImporter::reset() {
_voxelSystem.killLocalVoxels();
_voxelTree.eraseAllVoxels();
_importDialog.reset();
_filename = "";
_importWaiting = false;
if (_nextTask) {
delete _nextTask;
@ -63,17 +61,11 @@ void VoxelImporter::reset() {
}
if (_currentTask) {
_voxelSystem.cancelImport();
_voxelTree.cancelImport();
}
}
int VoxelImporter::exec() {
if (!_initialized) {
_voxelSystem.init();
_importViewFrustum.calculate();
_voxelSystem.setViewFrustum(&_importViewFrustum);
_initialized = true;
}
reset();
int ret = _importDialog.exec();
@ -82,7 +74,15 @@ int VoxelImporter::exec() {
reset();
} else {
_importDialog.reset();
_importWaiting = true;
if (_importDialog.getImportIntoClipboard()) {
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
voxelSystem->copySubTreeIntoNewTree(voxelSystem->getTree()->rootNode,
Application::getInstance()->getClipboard(),
true);
voxelSystem->changeTree(Application::getInstance()->getClipboard());
}
}
return ret;
@ -102,11 +102,11 @@ int VoxelImporter::preImport() {
delete _nextTask;
}
_nextTask = new ImportTask(&_voxelSystem, _filename);
_nextTask = new ImportTask(_filename);
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
if (_currentTask != NULL) {
_voxelSystem.cancelImport();
_voxelTree.cancelImport();
} else {
launchTask();
}
@ -138,12 +138,12 @@ int VoxelImporter::import() {
delete _nextTask;
}
_nextTask = new ImportTask(&_voxelSystem, _filename);
_nextTask = new ImportTask(_filename);
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
connect(_nextTask, SIGNAL(destroyed()), &_importDialog, SLOT(accept()));
if (_currentTask != NULL) {
_voxelSystem.cancelImport();
_voxelTree.cancelImport();
} else {
launchTask();
}
@ -153,28 +153,36 @@ int VoxelImporter::import() {
void VoxelImporter::launchTask() {
if (_nextTask != NULL) {
_voxelSystem.killLocalVoxels();
_currentTask = _nextTask;
_nextTask = NULL;
if (Application::getInstance()->getSharedVoxelSystem()->getTree() != &_voxelTree) {
Application::getInstance()->getSharedVoxelSystem()->changeTree(&_voxelTree);
}
QThreadPool::globalInstance()->start(_currentTask);
} else {
_currentTask = NULL;
}
}
ImportTask::ImportTask(VoxelSystem* voxelSystem, const QString &filename)
: _voxelSystem(voxelSystem),
_filename(filename) {
ImportTask::ImportTask(const QString &filename)
: _filename(filename) {
}
void ImportTask::run() {
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
voxelSystem->killLocalVoxels();
if (_filename.endsWith(".png", Qt::CaseInsensitive)) {
_voxelSystem->readFromSquareARGB32Pixels(_filename.toLocal8Bit().data());
voxelSystem->readFromSquareARGB32Pixels(_filename.toLocal8Bit().data());
} else if (_filename.endsWith(".svo", Qt::CaseInsensitive)) {
_voxelSystem->readFromSVOFile(_filename.toLocal8Bit().data());
voxelSystem->readFromSVOFile(_filename.toLocal8Bit().data());
} else if (_filename.endsWith(".schematic", Qt::CaseInsensitive)) {
_voxelSystem->readFromSchematicFile(_filename.toLocal8Bit().data());
voxelSystem->readFromSchematicFile(_filename.toLocal8Bit().data());
} else {
qDebug("[ERROR] Invalid file extension.\n");
}
voxelSystem->getTree()->reaverageVoxelColors(voxelSystem->getTree()->rootNode);
}

View file

@ -22,11 +22,11 @@ class VoxelImporter : public QObject {
public:
VoxelImporter(QWidget* parent = NULL);
~VoxelImporter();
void init();
void reset();
bool getImportWaiting() const { return _importWaiting; }
VoxelSystem* getVoxelSystem() { return &_voxelSystem; }
bool getImportIntoClipboard() const { return _importDialog.getImportIntoClipboard(); }
VoxelTree* getVoxelTree() { return &_voxelTree; }
public slots:
int exec();
@ -37,14 +37,10 @@ private slots:
void launchTask();
private:
VoxelSystem _voxelSystem;
ViewFrustum _importViewFrustum;
bool _initialized;
bool _importWaiting;
VoxelTree _voxelTree;
ImportDialog _importDialog;
QString _filename;
QString _filename;
ImportTask* _currentTask;
ImportTask* _nextTask;

View file

@ -115,6 +115,10 @@ void VoxelSystem::clearFreeBufferIndexes() {
}
VoxelSystem::~VoxelSystem() {
glDeleteBuffers(1, &_vboVerticesID);
glDeleteBuffers(1, &_vboNormalsID);
glDeleteBuffers(1, &_vboColorsID);
glDeleteBuffers(1, &_vboIndicesID);
delete[] _readVerticesArray;
delete[] _writeVerticesArray;
delete[] _readColorsArray;
@ -416,7 +420,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) {
bool shouldRender = false; // assume we don't need to render it
// if it's colored, we might need to render it!
shouldRender = node->calculateShouldRender(_viewFrustum);
node->setShouldRender(shouldRender);
// let children figure out their renderness
if (!node->isLeaf()) {
@ -627,6 +631,18 @@ void VoxelSystem::init() {
_perlinModulateProgram->release();
}
void VoxelSystem::changeTree(VoxelTree* newTree) {
disconnect(_tree, 0, this, 0);
_tree = newTree;
_tree->setDirtyBit();
connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
setupNewVoxelsForDrawing();
}
void VoxelSystem::updateFullVBOs() {
updateVBOSegment(0, _voxelsInReadArrays);

View file

@ -34,19 +34,21 @@ public:
VoxelSystem(float treeScale = TREE_SCALE, int maxVoxels = MAX_VOXELS_PER_SYSTEM);
~VoxelSystem();
void setDataSourceID(int dataSourceID) { _dataSourceID = dataSourceID; };
int getDataSourceID() const { return _dataSourceID; };
void setDataSourceID(int dataSourceID) { _dataSourceID = dataSourceID; }
int getDataSourceID() const { return _dataSourceID; }
int parseData(unsigned char* sourceBuffer, int numBytes);
virtual void init();
void simulate(float deltaTime) { };
void simulate(float deltaTime) { }
void render(bool texture);
ViewFrustum* getViewFrustum() const {return _viewFrustum;}
void setViewFrustum(ViewFrustum* viewFrustum) {_viewFrustum = viewFrustum;}
unsigned long getVoxelsUpdated() const {return _voxelsUpdated;};
unsigned long getVoxelsRendered() const {return _voxelsInReadArrays;};
void changeTree(VoxelTree* newTree);
VoxelTree* getTree() const { return _tree; }
ViewFrustum* getViewFrustum() const { return _viewFrustum; }
void setViewFrustum(ViewFrustum* viewFrustum) { _viewFrustum = viewFrustum; }
unsigned long getVoxelsUpdated() const { return _voxelsUpdated; }
unsigned long getVoxelsRendered() const { return _voxelsInReadArrays; }
void loadVoxelsFile(const char* fileName,bool wantColorRandomizer);
void writeToSVOFile(const char* filename, VoxelNode* node) const;
@ -118,10 +120,11 @@ protected:
float _treeScale;
int _maxVoxels;
VoxelTree* _tree;
void setupNewVoxelsForDrawing();
glm::vec3 computeVoxelVertex(const glm::vec3& startVertex, float voxelScale, int index) const;
void setupNewVoxelsForDrawing();
virtual void updateNodeInArrays(glBufferIndex nodeIndex, const glm::vec3& startVertex,
float voxelScale, const nodeColor& color);

View file

@ -423,6 +423,7 @@ void ViewFrustum::printDebugDetails() const {
qDebug("_right=%f,%f,%f\n", _right.x, _right.y, _right.z );
qDebug("_fieldOfView=%f\n", _fieldOfView);
qDebug("_aspectRatio=%f\n", _aspectRatio);
qDebug("_keyHoleRadius=%f\n", _keyholeRadius);
qDebug("_nearClip=%f\n", _nearClip);
qDebug("_farClip=%f\n", _farClip);
qDebug("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z );

View file

@ -24,50 +24,50 @@ const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
class ViewFrustum {
public:
// setters for camera attributes
void setPosition (const glm::vec3& p) { _position = p; };
void setOrientation (const glm::quat& orientationAsQuaternion);
void setPosition(const glm::vec3& p) { _position = p; }
void setOrientation(const glm::quat& orientationAsQuaternion);
// getters for camera attributes
const glm::vec3& getPosition() const { return _position; };
const glm::quat& getOrientation() const { return _orientation; };
const glm::vec3& getDirection() const { return _direction; };
const glm::vec3& getUp() const { return _up; };
const glm::vec3& getRight() const { return _right; };
const glm::vec3& getPosition() const { return _position; }
const glm::quat& getOrientation() const { return _orientation; }
const glm::vec3& getDirection() const { return _direction; }
const glm::vec3& getUp() const { return _up; }
const glm::vec3& getRight() const { return _right; }
// setters for lens attributes
void setFieldOfView ( float f ) { _fieldOfView = f; };
void setAspectRatio ( float a ) { _aspectRatio = a; };
void setNearClip ( float n ) { _nearClip = n; };
void setFarClip ( float f ) { _farClip = f; };
void setEyeOffsetPosition (const glm::vec3& p) { _eyeOffsetPosition = p; };
void setEyeOffsetOrientation (const glm::quat& o) { _eyeOffsetOrientation = o; };
void setFieldOfView(float f) { _fieldOfView = f; }
void setAspectRatio(float a) { _aspectRatio = a; }
void setNearClip(float n) { _nearClip = n; }
void setFarClip(float f) { _farClip = f; }
void setEyeOffsetPosition(const glm::vec3& p) { _eyeOffsetPosition = p; }
void setEyeOffsetOrientation(const glm::quat& o) { _eyeOffsetOrientation = o; }
// getters for lens attributes
float getFieldOfView() const { return _fieldOfView; };
float getAspectRatio() const { return _aspectRatio; };
float getNearClip() const { return _nearClip; };
float getFarClip() const { return _farClip; };
const glm::vec3& getEyeOffsetPosition() const { return _eyeOffsetPosition; };
const glm::quat& getEyeOffsetOrientation() const { return _eyeOffsetOrientation;};
float getFieldOfView() const { return _fieldOfView; }
float getAspectRatio() const { return _aspectRatio; }
float getNearClip() const { return _nearClip; }
float getFarClip() const { return _farClip; }
const glm::vec3& getEyeOffsetPosition() const { return _eyeOffsetPosition; }
const glm::quat& getEyeOffsetOrientation() const { return _eyeOffsetOrientation; }
const glm::vec3& getOffsetPosition() const { return _offsetPosition; };
const glm::vec3& getOffsetDirection() const { return _offsetDirection;};
const glm::vec3& getOffsetUp() const { return _offsetUp; };
const glm::vec3& getOffsetRight() const { return _offsetRight; };
const glm::vec3& getOffsetPosition() const { return _offsetPosition; }
const glm::vec3& getOffsetDirection() const { return _offsetDirection; }
const glm::vec3& getOffsetUp() const { return _offsetUp; }
const glm::vec3& getOffsetRight() const { return _offsetRight; }
const glm::vec3& getFarTopLeft() const { return _farTopLeft; };
const glm::vec3& getFarTopRight() const { return _farTopRight; };
const glm::vec3& getFarBottomLeft() const { return _farBottomLeft; };
const glm::vec3& getFarBottomRight() const { return _farBottomRight; };
const glm::vec3& getFarTopLeft() const { return _farTopLeft; }
const glm::vec3& getFarTopRight() const { return _farTopRight; }
const glm::vec3& getFarBottomLeft() const { return _farBottomLeft; }
const glm::vec3& getFarBottomRight() const { return _farBottomRight; }
const glm::vec3& getNearTopLeft() const { return _nearTopLeft; };
const glm::vec3& getNearTopRight() const { return _nearTopRight; };
const glm::vec3& getNearBottomLeft() const { return _nearBottomLeft; };
const glm::vec3& getNearBottomRight() const { return _nearBottomRight;};
const glm::vec3& getNearTopLeft() const { return _nearTopLeft; }
const glm::vec3& getNearTopRight() const { return _nearTopRight; }
const glm::vec3& getNearBottomLeft() const { return _nearBottomLeft; }
const glm::vec3& getNearBottomRight() const { return _nearBottomRight; }
// get/set for keyhole attribute
void setKeyholeRadius(float keyholdRadius) { _keyholeRadius = keyholdRadius; };
float getKeyholeRadius() const { return _keyholeRadius; };
void setKeyholeRadius(float keyholdRadius) { _keyholeRadius = keyholdRadius; }
float getKeyholeRadius() const { return _keyholeRadius; }
void calculate();
@ -81,7 +81,7 @@ public:
// some frustum comparisons
bool matches(const ViewFrustum& compareTo, bool debug = false) const;
bool matches(const ViewFrustum* compareTo, bool debug = false) const { return matches(*compareTo, debug); };
bool matches(const ViewFrustum* compareTo, bool debug = false) const { return matches(*compareTo, debug); }
void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const;

View file

@ -1581,7 +1581,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
bool VoxelTree::readFromSVOFile(const char* fileName) {
std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate);
if(file.is_open()) {
emit importSize(1.0f, 1.0f, 1.0f);
emit importProgress(0);
@ -1607,15 +1606,15 @@ bool VoxelTree::readFromSVOFile(const char* fileName) {
}
bool VoxelTree::readFromSquareARGB32Pixels(const char* filename) {
emit importSize(1.0f, 1.0f, 1.0f);
emit importProgress(0);
int minAlpha = INT_MAX;
QImage pngImage = QImage(filename);
for (int x = 0; x < pngImage.width() * pngImage.height(); ++x) {
minAlpha = std::min(qAlpha(pngImage.color(x)) , minAlpha);
for (int i = 0; i < pngImage.width(); ++i) {
for (int j = 0; j < pngImage.height(); ++j) {
minAlpha = std::min(qAlpha(pngImage.pixel(i, j)) , minAlpha);
}
}
int maxSize = std::max(pngImage.width(), pngImage.height());
@ -1624,6 +1623,8 @@ bool VoxelTree::readFromSquareARGB32Pixels(const char* filename) {
while (maxSize > scale) {scale *= 2;}
float size = 1.0f / scale;
emit importSize(size * pngImage.width(), 1.0f, size * pngImage.height());
QRgb pixel;
int minNeighborhoodAlpha;
@ -1692,14 +1693,13 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) {
while (max > scale) {scale *= 2;}
float size = 1.0f / scale;
int create = 1;
int red = 128, green = 128, blue = 128;
int count = 0;
emit importSize(size * schematics.getWidth(),
size * schematics.getHeight(),
size * schematics.getLength());
emit importProgress(0);
int create = 1;
int red = 128, green = 128, blue = 128;
int count = 0;
for (int y = 0; y < schematics.getHeight(); ++y) {
for (int z = 0; z < schematics.getLength(); ++z) {