/******************************************************************************* Copyright (c) 2005-2009 David Williams This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. *******************************************************************************/ #ifndef __BasicExample_OpenGLWidget_H__ #define __BasicExample_OpenGLWidget_H__ #pragma once #include "PolyVoxCore/Raycast.h" #include "PolyVoxCore/MaterialDensityPair.h" #include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h" #include "PolyVoxCore/SurfaceMesh.h" #include "PolyVoxCore/SimpleVolume.h" #include "PolyVoxCore/MarchingCubesSurfaceExtractor.h" #include "PolyVoxCore/MeshDecimator.h" //#include #include "RaycastIntersectionFinder.h" #include "fmod.hpp" #include "fmod_errors.h" #include //Use the PolyVox namespace using namespace PolyVox; class OpenGLWidget : public QGLWidget { Q_OBJECT public slots: void setRadius(int angle); //void setYRotation(int angle); //void setZRotation(int angle); signals: void radiusChanged(int angle); //void yRotationChanged(int angle); //void zRotationChanged(int angle); public: //Constructor OpenGLWidget(QWidget *parent=0); RaycastIntersectionFinder rayCallback; int radius; QSize minimumSizeHint() const; QSize sizeHint() const; //FMOD SoundSystem FMOD::System *fmodSys; FMOD::Sound *soundBG, *soundCarve; FMOD::Channel *channel; FMOD_RESULT result; void ERRCHECK(FMOD_RESULT result); //Convert a SrfaceMesh to OpenGL index/vertex buffers void setSurfaceMeshToRender(SurfaceMesh* surfaceMesh, int i); void createSphereInVolume(SimpleVolume* volData,float fRadius); void createCubeInVolume(SimpleVolume* volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner); SimpleVolume* updateVolData(float fRadius, Vector3DInt32 intersectVoxel); //SimpleVolume* updateVolDataKnife(Vector3DInt32 intersectVoxel); void whichAreaToRender(Vector3DInt32 intersectionVoxel); void generateMeshBasedOnflags(); protected: //Qt OpenGL functions void initializeGL(); void resizeGL(int w, int h); void paintGL(); //Mouse handling void mouseMoveEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event); private: //Index/vertex buffer data GLuint m_uBeginIndex; GLuint m_uEndIndex[8]; //GLuint noOfIndices; GLuint indexBuffer[8]; GLuint vertexBuffer[8]; //pen radius //Mouse data QPoint m_LastFrameMousePos; QPoint m_CurrentMousePos; int m_xRotation; int m_yRotation; public: //simple Volume SimpleVolume *volData; //SurfaceMesh *mesh; SurfaceMesh*subdivisionMesh[8]; bool subdivisionFlag[8]; //polyvox_shared_ptr> *mesh; MarchingCubesSurfaceExtractor> *surfaceExtractor; Region subdivisionReg[8]; }; #endif //__BasicExample_OpenGLWidget_H__