1 #ifndef _SurfaceCtrl_MagicCamera_h_
2 #define _SurfaceCtrl_MagicCamera_h_
3 #include "UOGL_Camera.h"
4 #include "Object3D.h"
5 
6 namespace Upp{
7 class MagicCamera : public UOGL_Camera{
8 	public:
MagicCamera()9 		MagicCamera(){}
Init()10 		MagicCamera& Init(){transform.SetPosition(0, 0, 20); focus = glm::vec3(0.0f,0.0f,0.0f); return *this;}
11 
IsOnObject()12 		bool IsOnObject(){return OnObject;}
13 		glm::mat4 GetProjectionMatrix()const noexcept;
14 		glm::mat4 GetViewMatrix()const noexcept;
15 
GetFocus()16 		glm::vec3 GetFocus(){return focus;}
SetFocus(glm::vec3 f)17 		MagicCamera& SetFocus(glm::vec3 f){focus = f; return *this;}
SetFocus(float x,float y,float z)18 		MagicCamera& SetFocus(float x, float y , float z){focus = glm::vec3(x,y,z); return *this;}
19 
20 		int Pick(float x, float y,const Upp::Vector<Object3D>& allObjects)const noexcept; //Return Picked object ID between a vector of object
21 		MagicCamera& DetermineRotationPoint(Point& p,const Upp::Vector<Object3D>& allObjects, const Upp::Vector<int>& allSelecteds)noexcept; //Find a new focus point depending on cursor position and all Object3D
22 
23 		virtual MagicCamera& LookAt(const glm::vec3& lookat)noexcept;
24 		void ViewFromAxe(bool AxeX, bool AxeY, bool AxeZ, bool Inverse = false)noexcept; // Will set camera on axe selected axe
25 
26 		MagicCamera& ProcessMouseWheelTranslation(float xoffset,float yoffset); //Move the camera depending on X and Y offset
27 		MagicCamera& MouseWheelMouvement(float xoffset,float yoffset)noexcept; //Rotate arround axis
28 		MagicCamera& ProcessMouseScroll(float zdelta, float multiplier = 1.0f)noexcept; //Zoom or move via MouseWheel depending on OnObject Boolean
29 
ProcessKeyboardMouvement(CameraMovementDirection direction)30 		MagicCamera& ProcessKeyboardMouvement(CameraMovementDirection direction){return *this;} //Handler for keyboard, Useless in this kind of camera
ProcessKeyBoard(unsigned long Key,int count)31 		bool ProcessKeyBoard(unsigned long Key,int count)noexcept{return true;} //Handler for keyboard, Useless in this kind of camera
32 
33 	private:
34 		bool OnObject = false;
35 		glm::vec3 focus;
36 
37 		glm::vec3 UnProject2(float winX, float winY,float winZ)const noexcept;
38 		bool PickFocus(float x, float y);
39 	};
40 }
41 
42 #endif
43