diff --git a/bazaar/SurfaceCtrl/BoundingBox.h b/bazaar/SurfaceCtrl/BoundingBox.h index da32d6f11..f730d4501 100644 --- a/bazaar/SurfaceCtrl/BoundingBox.h +++ b/bazaar/SurfaceCtrl/BoundingBox.h @@ -6,32 +6,6 @@ namespace Upp{ class BoundingBox { - private: - bool loaded = false; - - glm::vec3 min; - glm::vec3 max; - - GLuint BoundingBoxVAO = 0; - GLuint BoundingBoxVBO = 0; - - void loadBoundingBox(){ - Vector BoundingBoxVertices = GetVertices(); - - if(BoundingBoxVAO > 0) glDeleteVertexArrays(1,&BoundingBoxVAO); - if(BoundingBoxVBO > 0) glDeleteBuffers(1,&BoundingBoxVBO); - - glGenVertexArrays(1,&BoundingBoxVAO); - glGenBuffers(1,&BoundingBoxVBO); - - glBindVertexArray(BoundingBoxVAO); - glBindBuffer(GL_ARRAY_BUFFER,BoundingBoxVBO); - glBufferData(GL_ARRAY_BUFFER,BoundingBoxVertices.GetCount() * sizeof(float),&(BoundingBoxVertices[0]),GL_STATIC_DRAW); - glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,3*sizeof(float),(void*)0); - glEnableVertexAttribArray(0); - loaded = true; - } - public: BoundingBox(){ loaded = false; @@ -43,12 +17,12 @@ class BoundingBox { BoundingBox(glm::vec3 min_, glm::vec3 max_){ min = min_; max = max_; - loadBoundingBox(); + LoadBoundingBox(); } BoundingBox(float minX,float minY, float minZ, float maxX,float maxY,float maxZ){ min = glm::vec3(minX,minY,minZ); max = glm::vec3(maxX,maxY,maxZ); - loadBoundingBox(); + LoadBoundingBox(); } BoundingBox& operator=(const BoundingBox& copy){ @@ -60,7 +34,7 @@ class BoundingBox { return *this; } - BoundingBox& ReloadBoundingBox(){loadBoundingBox();return *this;} + BoundingBox& ReloadBoundingBox(){LoadBoundingBox();return *this;} BoundingBox& UnloadBoundingBox(){glDeleteVertexArrays(1,&BoundingBoxVAO);glDeleteBuffers(1,&BoundingBoxVBO);loaded =false;return *this;} Vector GetVertices(){ @@ -94,13 +68,13 @@ class BoundingBox { BoundingBox& SetBoundingBox(glm::vec3 min_, glm::vec3 max_){ min = min_; max = max_; - loadBoundingBox(); + LoadBoundingBox(); return *this; } BoundingBox& SetBoundingBox(float minX,float minY, float minZ, float maxX,float maxY,float maxZ){ min = glm::vec3(minX,minY,minZ); max = glm::vec3(maxX,maxY,maxZ); - loadBoundingBox(); + LoadBoundingBox(); return *this; } @@ -175,6 +149,31 @@ class BoundingBox { } return *this; } + private: + bool loaded = false; + + glm::vec3 min; + glm::vec3 max; + + GLuint BoundingBoxVAO = 0; + GLuint BoundingBoxVBO = 0; + + void LoadBoundingBox(){ + Vector BoundingBoxVertices = GetVertices(); + + if(BoundingBoxVAO > 0) glDeleteVertexArrays(1,&BoundingBoxVAO); + if(BoundingBoxVBO > 0) glDeleteBuffers(1,&BoundingBoxVBO); + + glGenVertexArrays(1,&BoundingBoxVAO); + glGenBuffers(1,&BoundingBoxVBO); + + glBindVertexArray(BoundingBoxVAO); + glBindBuffer(GL_ARRAY_BUFFER,BoundingBoxVBO); + glBufferData(GL_ARRAY_BUFFER,BoundingBoxVertices.GetCount() * sizeof(float),&(BoundingBoxVertices[0]),GL_STATIC_DRAW); + glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,3*sizeof(float),(void*)0); + glEnableVertexAttribArray(0); + loaded = true; + } }; } diff --git a/bazaar/SurfaceCtrl/Definition.h b/bazaar/SurfaceCtrl/Definition.h index 91f39ee41..a5a4dee44 100644 --- a/bazaar/SurfaceCtrl/Definition.h +++ b/bazaar/SurfaceCtrl/Definition.h @@ -23,7 +23,7 @@ #define SHADER(version, shader) "#version " #version "\n" STRINGIFY(shader) namespace Upp{ - enum class Camera_Movement {FORWARD,BACKWARD,LEFT,RIGHT};// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods + enum class CameraMovementDirection {FORWARD,BACKWARD,LEFT,RIGHT};// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods enum class CameraType{PERSPECTIVE = 0 ,ORTHOGRAPHIC = 1};//,CT_FRUSTUM = 2}; //Type of camera rendering enum class DrawType { TRIANGLE, QUAD }; enum class TexturesMaterial { WATER, STONE, BRICK, METAL, WOOD}; diff --git a/bazaar/SurfaceCtrl/MagicCamera.h b/bazaar/SurfaceCtrl/MagicCamera.h index 2c566f20b..c199ab7ed 100644 --- a/bazaar/SurfaceCtrl/MagicCamera.h +++ b/bazaar/SurfaceCtrl/MagicCamera.h @@ -4,13 +4,7 @@ #include "Object3D.h" namespace Upp{ - class MagicCamera : public UOGL_Camera{ - private: - bool OnObject = false; - glm::vec3 focus; - - glm::vec3 UnProject2(float winX, float winY,float winZ)const noexcept; - bool PickFocus(float x, float y); +class MagicCamera : public UOGL_Camera{ public: MagicCamera(){} MagicCamera& Init(){transform.SetPosition(0, 0, 20); focus = glm::vec3(0.0f,0.0f,0.0f); return *this;} @@ -33,9 +27,15 @@ namespace Upp{ MagicCamera& MouseWheelMouvement(float xoffset,float yoffset)noexcept; //Rotate arround axis MagicCamera& ProcessMouseScroll(float zdelta, float multiplier = 1.0f)noexcept; //Zoom or move via MouseWheel depending on OnObject Boolean - - MagicCamera& ProcessKeyboardMouvement(Camera_Movement direction){return *this;} //Handler for keyboard, Useless in this kind of camera + MagicCamera& ProcessKeyboardMouvement(CameraMovementDirection direction){return *this;} //Handler for keyboard, Useless in this kind of camera bool ProcessKeyBoard(unsigned long Key,int count)noexcept{return true;} //Handler for keyboard, Useless in this kind of camera + + private: + bool OnObject = false; + glm::vec3 focus; + + glm::vec3 UnProject2(float winX, float winY,float winZ)const noexcept; + bool PickFocus(float x, float y); }; } diff --git a/bazaar/SurfaceCtrl/Mesh.h b/bazaar/SurfaceCtrl/Mesh.h index f1c7b8c5c..7d3ca6405 100644 --- a/bazaar/SurfaceCtrl/Mesh.h +++ b/bazaar/SurfaceCtrl/Mesh.h @@ -4,11 +4,6 @@ namespace Upp{ struct Material{ - private: - glm::vec3 Diffuse = glm::vec3(0.30f, 0.30f, 0.30f); - glm::vec3 Specular = glm::vec3(0.1f, 0.1f, 0.1f); - float Shininess = 12.0f; - bool update = true; public: Material(){} Material(const glm::vec3& diffuse_, const glm::vec3& speculare_, float shininess_){Diffuse = diffuse_;Specular = speculare_;Shininess = shininess_;} @@ -23,32 +18,15 @@ struct Material{ bool ShouldBeUpdated()const noexcept{return update;} void HaveBeenUpdated()noexcept{update = false;} + private: + glm::vec3 Diffuse = glm::vec3(0.30f, 0.30f, 0.30f); + glm::vec3 Specular = glm::vec3(0.1f, 0.1f, 0.1f); + float Shininess = 12.0f; + bool update = true; }; //Mesh contain vertex and how it's read class Mesh : public Moveable{ - private: - String name =""; //Possible name of Mesh - bool loaded = false; - - Vector vertices; - Vector normals; - Vector colors; - Vector texCoords; - - GLuint vao = 0; - GLuint verticesVBO = 0; - GLuint normalsVBO = 0; - GLuint colorsVBO = 0; - GLuint texCoordsVBO = 0; - - Material material; //The material object is a representation of material property of the object (it change how light affect it) - - unsigned int textureIndice = 0; - - /** - All stuff about texture - **/ public: Mesh(){} Mesh(Mesh&& obj){*this = pick(obj);} @@ -193,11 +171,25 @@ class Mesh : public Moveable{ } loaded = false; } + + private: + String name =""; //Possible name of Mesh + bool loaded = false; - - - - + Vector vertices; + Vector normals; + Vector colors; + Vector texCoords; + + GLuint vao = 0; + GLuint verticesVBO = 0; + GLuint normalsVBO = 0; + GLuint colorsVBO = 0; + GLuint texCoordsVBO = 0; + + Material material; //The material object is a representation of material property of the object (it change how light affect it) + + unsigned int textureIndice = 0; }; } diff --git a/bazaar/SurfaceCtrl/Object3D.cpp b/bazaar/SurfaceCtrl/Object3D.cpp index 7d9d97e98..98ebd1ca7 100644 --- a/bazaar/SurfaceCtrl/Object3D.cpp +++ b/bazaar/SurfaceCtrl/Object3D.cpp @@ -323,7 +323,7 @@ bool Object3D::InitMaterials(const aiScene* pScene, const String& Filename){ if (pMaterial->GetTexture(aiTextureType_NONE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) LOG("None texture : " + AppendFileName(GetFileFolder(Filename), String(Path.data))); }else{ - for(int e = 0; e < pMaterial->mNumProperties; e++){ + /*for(int e = 0; e < pMaterial->mNumProperties; e++){ aiMaterialProperty* aiMp = pMaterial->mProperties[e]; LOG("Property number " + AsString(e) +" :"); LOG("mKey : " + String((*aiMp).mKey.data)); @@ -334,7 +334,7 @@ bool Object3D::InitMaterials(const aiScene* pScene, const String& Filename){ String str = String((*aiMp).mData); LOG("mData count : " + AsString(str.GetCount())); LOG("---------------------------------"); - } + }*/ } } return true; diff --git a/bazaar/SurfaceCtrl/Object3D.h b/bazaar/SurfaceCtrl/Object3D.h index f416d4e70..1fb0ec1d7 100644 --- a/bazaar/SurfaceCtrl/Object3D.h +++ b/bazaar/SurfaceCtrl/Object3D.h @@ -37,64 +37,9 @@ struct Texture : public Moveable{ id = t.id; return *this; } - }; class Object3D : public Upp::Moveable{ - private: - static int GlobalID; - int ID; - - Transform transform; - BoundingBox boundingBox; - Material material; //The material object is a representation of material property of the object (it change how light affect it) - - Vector meshes; - Vector textures; //Vector carrying all texture of the object, every meshes refer to it via one iterator - Vector program; - VectorMap objectValues; //In case data need to be used in Init() Clear() and Draw(); - - bool loaded = false; - bool moved = false; - bool visible = true; - bool showBoundingBox = false; - - int programNoLight = 0;//The program will draw figure without light - int programLine = 0;//THe program will draw figure line - int programNormal = 0;//The program will draw Normal - int programLight = 0;//the program will draw figure with light - - GLenum drawType = GL_TRIANGLES; - - //All this value are here by default - Color lineColor = Black(); - float lineOpacity = 0.5f; - float lineWidth = 1.0f; - - Color normalColor = Red(); - float normalOpacity = 1.0f; - float normalLength = 1.0f; - - bool showMesh = true; - bool showMeshLine = false; - bool showMeshNormal = false; - bool showLight = true; - public: - Function WhenInit; - Function WhenDraw; - Function WhenClear; - Function WhenReload; - private: - bool UpdateBuffer(GLuint buffer, int SurfaceCount , int SurfaceNumber,int count ,int numberOfElement, const float * data)noexcept; - Vector ReadBuffer(GLuint buffer, int SurfaceCount , int SurfaceNumber,int count, int numberOfElement)noexcept; - //Texture loading function - //Return position of the texture object carrying this texture - int LoadTexture(const Image& img , const String& name, int indiceWhereInsert = -1); - - //Assimp loading function - bool InitFromScene(const aiScene* pScene, const String& Filename); - void InitMesh(unsigned int Index, const aiMesh* paiMesh); - bool InitMaterials(const aiScene* pScene, const String& Filename); public: Object3D(); Object3D(Object3D&& obj):ID(GlobalID++){*this = pick(obj);} @@ -105,6 +50,11 @@ class Object3D : public Upp::Moveable{ int GetID()const{return ID;} + Function WhenInit; + Function WhenDraw; + Function WhenClear; + Function WhenReload; + bool IsLoaded(){return loaded;} Object3D& Show(){visible = true;return *this;} Object3D& Hide(){visible = false;return *this;} @@ -221,18 +171,62 @@ class Object3D : public Upp::Moveable{ void Draw(const glm::mat4& projectionMatrix,const glm::mat4& viewMatrix,const glm::vec3& viewPosition)noexcept{WhenDraw(projectionMatrix,viewMatrix,viewPosition, *this);} void Clear(){WhenClear(*this); loaded = false;} void Reload(){WhenReload(*this);} + + + private: + static int GlobalID; + int ID; + + Transform transform; + BoundingBox boundingBox; + Material material; //The material object is a representation of material property of the object (it change how light affect it) + + Vector meshes; + Vector textures; //Vector carrying all texture of the object, every meshes refer to it via one iterator + Vector program; + VectorMap objectValues; //In case data need to be used in Init() Clear() and Draw(); + + bool loaded = false; + bool moved = false; + bool visible = true; + bool showBoundingBox = false; + + int programNoLight = 0;//The program will draw figure without light + int programLine = 0;//THe program will draw figure line + int programNormal = 0;//The program will draw Normal + int programLight = 0;//the program will draw figure with light + + GLenum drawType = GL_TRIANGLES; + + //All this value are here by default + Color lineColor = Black(); + float lineOpacity = 0.5f; + float lineWidth = 1.0f; + + Color normalColor = Red(); + float normalOpacity = 1.0f; + float normalLength = 1.0f; + + bool showMesh = true; + bool showMeshLine = false; + bool showMeshNormal = false; + bool showLight = true; + + bool UpdateBuffer(GLuint buffer, int SurfaceCount , int SurfaceNumber,int count ,int numberOfElement, const float * data)noexcept; + Vector ReadBuffer(GLuint buffer, int SurfaceCount , int SurfaceNumber,int count, int numberOfElement)noexcept; + //Texture loading function + //Return position of the texture object carrying this texture + int LoadTexture(const Image& img , const String& name, int indiceWhereInsert = -1); + + //Assimp loading function + bool InitFromScene(const aiScene* pScene, const String& Filename); + void InitMesh(unsigned int Index, const aiMesh* paiMesh); + bool InitMaterials(const aiScene* pScene, const String& Filename); + }; class Skybox { - private: - unsigned int ID = 0; - GLuint VBO, VAO; - bool show = false; - - OpenGLProgram program; - Skybox& Init(const Vector& images); //Load this vector of image as Skybox public: - Skybox(){} ~Skybox(){Clear();} @@ -243,7 +237,13 @@ class Skybox { Skybox& Init(const Image& skybox_right,const Image& skybox_left,const Image& skybox_top,const Image& skybox_bottom,const Image& skybox_front,const Image& skybox_back); //Load all image provided as skybox Skybox& Clear(); Skybox& Draw(const glm::mat4& projectionMatrix,const glm::mat4& viewMatrix); - + private: + unsigned int ID = 0; + GLuint VBO, VAO; + bool show = false; + + OpenGLProgram program; + Skybox& Init(const Vector& images); //Load this vector of image as Skybox }; } diff --git a/bazaar/SurfaceCtrl/Shader.h b/bazaar/SurfaceCtrl/Shader.h index 5d2506a5d..8d28b3e66 100644 --- a/bazaar/SurfaceCtrl/Shader.h +++ b/bazaar/SurfaceCtrl/Shader.h @@ -4,6 +4,18 @@ //#include namespace Upp{ class OpenGLShader{ + public: + OpenGLShader(GLenum type,const char * data) : shaderType{type} { + ID = glCreateShader(shaderType); + glShaderSource(ID, 1, &data, NULL); + glCompileShader(ID); + if(CheckForCompilationError())compiled = true; + } + ~OpenGLShader(){glDeleteShader(ID);} + + GLuint GetID()const noexcept{return ID;} + GLenum GetType()const noexcept{return shaderType;} + bool IsCompiled()const noexcept{return compiled;} private: GLenum shaderType; GLuint ID = 0; @@ -40,49 +52,8 @@ class OpenGLShader{ } return true; } - public: - OpenGLShader(GLenum type,const char * data) : shaderType{type} { - ID = glCreateShader(shaderType); - glShaderSource(ID, 1, &data, NULL); - glCompileShader(ID); - if(CheckForCompilationError())compiled = true; - } - ~OpenGLShader(){glDeleteShader(ID);} - - GLuint GetID()const noexcept{return ID;} - GLenum GetType()const noexcept{return shaderType;} - bool IsCompiled()const noexcept{return compiled;} }; - class OpenGLProgram : public Moveable{ - private: - GLuint vertex = 0; - GLuint TCS = 0; //Tesselation control shader - GLuint TES = 0; //Tesselation evaluation shader - GLuint geometry = 0; - GLuint fragment = 0; - - String name=""; - GLuint ID = 0; - bool linked = false; - bool copied = false; //if the shader is copied then is deletion wont occure a clear in OpenGL data - - GLint GetUniformLocation(Upp::String name){ - GLint location = glGetUniformLocation(ID, name.ToStd().c_str()); - if(location == -1)RLOG("Warning : uniform named " + name +" can't be find in program number " + AsString(ID)); - return location; - } - - bool CheckForLinkingError()noexcept{ - int success; - char infoLog[512]; - glGetProgramiv(ID, GL_LINK_STATUS, &success); - if (!success) { - glGetProgramInfoLog(ID, 512, NULL, infoLog); - LOG("ERROR::SHADER::PROGRAM::LINKING_FAILED\n" + String(infoLog)); - return false; - } - return true; - } +class OpenGLProgram : public Moveable{ public: OpenGLProgram(){} OpenGLProgram(const String& n){name = n;} @@ -172,6 +143,37 @@ class OpenGLShader{ OpenGLProgram& SetMat2(Upp::String name, const glm::mat2 &mat)noexcept{if(linked)glUniformMatrix2fv(GetUniformLocation(name), 1, GL_FALSE, &mat[0][0]);return *this;} OpenGLProgram& SetMat3(Upp::String name, const glm::mat3 &mat)noexcept{if(linked)glUniformMatrix3fv(GetUniformLocation(name), 1, GL_FALSE, &mat[0][0]);return *this;} OpenGLProgram& SetMat4(Upp::String name, const glm::mat4 &mat)noexcept{if(linked)glUniformMatrix4fv(GetUniformLocation(name), 1, GL_FALSE, &mat[0][0]);return *this;} + + + private: + GLuint vertex = 0; + GLuint TCS = 0; //Tesselation control shader + GLuint TES = 0; //Tesselation evaluation shader + GLuint geometry = 0; + GLuint fragment = 0; + + String name=""; + GLuint ID = 0; + bool linked = false; + bool copied = false; //if the shader is copied then is deletion wont occure a clear in OpenGL data + + GLint GetUniformLocation(Upp::String name){ + GLint location = glGetUniformLocation(ID, name.ToStd().c_str()); + if(location == -1)RLOG("Warning : uniform named " + name +" can't be find in program number " + AsString(ID)); + return location; + } + + bool CheckForLinkingError()noexcept{ + int success; + char infoLog[512]; + glGetProgramiv(ID, GL_LINK_STATUS, &success); + if (!success) { + glGetProgramInfoLog(ID, 512, NULL, infoLog); + LOG("ERROR::SHADER::PROGRAM::LINKING_FAILED\n" + String(infoLog)); + return false; + } + return true; + } }; } diff --git a/bazaar/SurfaceCtrl/SurfaceCtrl.h b/bazaar/SurfaceCtrl/SurfaceCtrl.h index 1874fd050..2442cf232 100644 --- a/bazaar/SurfaceCtrl/SurfaceCtrl.h +++ b/bazaar/SurfaceCtrl/SurfaceCtrl.h @@ -12,41 +12,6 @@ static const String GetSurfaceCtrlDirectory(){ } class SurfaceCtrl : public GLCtrl{ - typedef SurfaceCtrl CLASSNAME; - private: - bool loaded = false; - Object3DProvider objProvider; - - Upp::Vector allObjects; - Upp::Vector allSelected; - - Object3D Axis; - Object3D CameraFocus; - Skybox skybox; - - MagicCamera camera; - - OpenGLProgram DrawMeshNoLight; - OpenGLProgram DrawMeshLight; - OpenGLProgram DrawMeshLine; - OpenGLProgram DrawMeshNormal; - - bool showAxis = true; - bool depthAxis = false; - bool showCameraFocus = false; - - float sizeW = 800.0f; - float sizeH = 600.0f; - - bool TimerStarted = false; - std::chrono::time_point start,end; //High resolution clock - double DeltaTime=0.0f,LastTime=0.0f,lastFrame =0.0f,Timer=0.0f; - int bufferFrame =0,frameCount = 0; //used to calculate FPS - void ProcessTime()noexcept; - - bool fastMode = false; - - void InitShader(); //Load default shader public: SurfaceCtrl(); ~SurfaceCtrl(); @@ -81,9 +46,9 @@ class SurfaceCtrl : public GLCtrl{ Skybox& GetSkybox()noexcept{return skybox;} //Change Object selected - void MoveAllSelectedObjects(glm::vec3 move)noexcept; //Move all selected object - void RotateAllSelectedObjects(glm::quat rotation)noexcept; //Rotate all selected object - void DeleteAllSelectedObjects()noexcept; //Delete all selected object + void MoveAllSelectedObjects(glm::vec3 move)noexcept; + void RotateAllSelectedObjects(glm::quat rotation)noexcept; + void DeleteAllSelectedObjects()noexcept; //Camera getter const MagicCamera& GetCamera()const noexcept{return camera;} @@ -125,16 +90,8 @@ class SurfaceCtrl : public GLCtrl{ virtual void GLResize(int w, int h); //Action on resize //Input event - /*virtual void MouseMove(Point p, dword); //Action on mouse move - virtual void MouseWheel(Point p,int zdelta,dword keyflags); //action on Mouse wheel - virtual void LeftDown(Point p, dword); //Action on Left Down mouse - virtual void LeftUp(Point p, dword); //Action on Up down mouse - virtual void MiddleDown(Point p, dword keyflags); //Action Middle down (wheel down) mouse - virtual void MiddleUp(Point p, dword keyflags);//Action Middle up (wheel up) mouse - virtual void MouseLeave(); //action when mouse leave*/ virtual bool Key(dword key,int count); //Action when key press - int buttonRotation = Ctrl::MIDDLE; int buttonDrag = Ctrl::LEFT; int buttonMenu = Ctrl::RIGHT; @@ -147,13 +104,46 @@ class SurfaceCtrl : public GLCtrl{ void OnTypeImage(FileSel *_fs); virtual Image HandleEvent(int event, Point p, int zdelta, dword); - - - + //Menu bar Image MouseEvent(int event, Point p, int zdelta, dword keyflags); void ContextMenu(Bar& bar,const Point& p); + + private: + typedef SurfaceCtrl CLASSNAME; + bool loaded = false; + Object3DProvider objProvider; + Upp::Vector allObjects; + Upp::Vector allSelected; + + Object3D Axis; + Object3D CameraFocus; + Skybox skybox; + + MagicCamera camera; + + OpenGLProgram DrawMeshNoLight; + OpenGLProgram DrawMeshLight; + OpenGLProgram DrawMeshLine; + OpenGLProgram DrawMeshNormal; + + bool showAxis = true; + bool depthAxis = false; + bool showCameraFocus = false; + + float sizeW = 800.0f; + float sizeH = 600.0f; + + bool TimerStarted = false; + std::chrono::time_point start,end; //High resolution clock + double DeltaTime=0.0f,LastTime=0.0f,lastFrame =0.0f,Timer=0.0f; + int bufferFrame =0,frameCount = 0; //used to calculate FPS + void ProcessTime()noexcept; + + bool fastMode = false; + + void InitShader(); //Load default shader }; #include "Object3D.h" } diff --git a/bazaar/SurfaceCtrl/Transform.h b/bazaar/SurfaceCtrl/Transform.h index 1554d2f0b..46ffa44b6 100644 --- a/bazaar/SurfaceCtrl/Transform.h +++ b/bazaar/SurfaceCtrl/Transform.h @@ -6,24 +6,6 @@ */ namespace Upp{ class Transform{ - private: - glm::vec3 Front = glm::vec3(0.0f, 0.0f, -1.0f); - glm::vec3 Up = glm::vec3(0.0f, 1.0f, 0.0f); - glm::vec3 Right = glm::vec3(1.0f, 0.0f, 0.0f); - - glm::vec3 WorldFront = glm::vec3(0.0, 0.0, -1.0); - glm::vec3 WorldUp = glm::vec3(0.0f, 1.0f, 0.0f); - glm::vec3 WorldRight = glm::vec3(1.0f, 0.0f, 0.0f); - - glm::vec3 Position = glm::vec3(0.0f); - glm::quat Rotation = Transform::GetQuaterion(0.0f,glm::vec3(0.0f,0.0f,0.0f)); - glm::vec3 Scale = glm::vec3(1.0f); - - void RecalculateFURW(){ - Front = glm::rotate(glm::inverse(Rotation), WorldFront); - Right = glm::rotate(glm::inverse(Rotation), WorldRight); - Up = glm::rotate(glm::inverse(Rotation), WorldUp); - } public: Transform(){} Transform(const Transform& _transform){*this = _transform;} @@ -108,6 +90,24 @@ class Transform{ ret.z = (vector[0]*matrix[0][2]+vector[1]*matrix[1][2]+vector[2]*matrix[2][2]+matrix[3][2])/w; return ret; } + private: + glm::vec3 Front = glm::vec3(0.0f, 0.0f, -1.0f); + glm::vec3 Up = glm::vec3(0.0f, 1.0f, 0.0f); + glm::vec3 Right = glm::vec3(1.0f, 0.0f, 0.0f); + + glm::vec3 WorldFront = glm::vec3(0.0, 0.0, -1.0); + glm::vec3 WorldUp = glm::vec3(0.0f, 1.0f, 0.0f); + glm::vec3 WorldRight = glm::vec3(1.0f, 0.0f, 0.0f); + + glm::vec3 Position = glm::vec3(0.0f); + glm::quat Rotation = Transform::GetQuaterion(0.0f,glm::vec3(0.0f,0.0f,0.0f)); + glm::vec3 Scale = glm::vec3(1.0f); + + void RecalculateFURW(){ + Front = glm::rotate(glm::inverse(Rotation), WorldFront); + Right = glm::rotate(glm::inverse(Rotation), WorldRight); + Up = glm::rotate(glm::inverse(Rotation), WorldUp); + } }; } #endif diff --git a/bazaar/SurfaceCtrl/UOGL_Camera.h b/bazaar/SurfaceCtrl/UOGL_Camera.h index 7687cac26..8a48f32d3 100644 --- a/bazaar/SurfaceCtrl/UOGL_Camera.h +++ b/bazaar/SurfaceCtrl/UOGL_Camera.h @@ -7,26 +7,7 @@ namespace Upp{ class UOGL_Camera{ - protected: - Transform transform; //The Camera Transform object - - CameraType type = CameraType::PERSPECTIVE; - - float MaxFOV = 160.0f; - float MinFOV = 10.0f; - bool LimiteFOV = true; - float FOV =45.0f; - - float DrawDisanceMax = 10000.0f; - float DrawDistanceMin = 0.1f; - - float MouvementSpeed = 0.09f; - float MouseSensitivity = 0.08f; - float ZoomSpeed = 10.0f; - - Upp::Sizef ScreenSize; public: - Point lastPress; bool MouseLeftPressed = false; bool MouseMiddlePressed = false; @@ -149,7 +130,24 @@ class UOGL_Camera{ Upp::Sizef GetScreenSize()const noexcept{return ScreenSize;} UOGL_Camera& SetScreenSize(float width, float height)noexcept{ScreenSize = Sizef(width,height);return *this;} + protected: + Transform transform; //The Camera Transform object + + CameraType type = CameraType::PERSPECTIVE; + float MaxFOV = 160.0f; + float MinFOV = 10.0f; + bool LimiteFOV = true; + float FOV =45.0f; + + float DrawDisanceMax = 10000.0f; + float DrawDistanceMin = 0.1f; + + float MouvementSpeed = 0.09f; + float MouseSensitivity = 0.08f; + float ZoomSpeed = 10.0f; + + Upp::Sizef ScreenSize; }; } #endif