8 #include "glm/gtc/quaternion.hpp" 32 Camera(
const glm::vec3 &pos=glm::vec3(3, 4, 5),
const glm::vec3 &
lookAt=glm::vec3(0),
const glm::vec3 &up=glm::vec3(0, 1, 0));
44 void setPos(
const glm::vec3 &pos=glm::vec3(3, 4, 5));
51 void setPos(
float x=3,
float y=4,
float z=5);
58 void lookAt(
const glm::vec3 &target=glm::vec3(0));
65 void lookAt(
float x=0,
float y=0,
float z=0);
70 void setUp(
const glm::vec3 &up=glm::vec3(0, 1, 0));
77 void setUp(
float x=0,
float y=1,
float z=0);
87 void setView(
const glm::mat4 &mat);
98 void rotate(
float rad=0,
const glm::vec3 &axis=glm::vec3(0),
bool around=
true);
104 void rotate(
const glm::quat &rot=glm::quat(1, 0, 0, 0),
bool around=
true);
112 void rotateX(
float rad=0,
bool around=
true,
bool safe=
true);
118 void rotateY(
float rad=0,
bool around=
true);
124 void rotateZ(
float rad=0,
bool around=
true);
129 void translate(
const glm::vec3 &d=glm::vec3(0));
136 void translate(
float dx=0,
float dy=0,
float dz=0);
162 void viewRotate(
float rad=0,
const glm::vec3 &axis=glm::vec3(0));
167 void viewScale(
const glm::vec3 &s=glm::vec3(1));
174 void viewScale(
float sx=1,
float sy=1,
float sz=1);
213 Scene(
int width=640,
int height=480,
const char *name=
"AGL");
223 void setPerspectiveProjection(
float fovDeg=45,
float aspectRatio=-1,
float near=0.1,
float far=100);
233 void setOrthographicProjection(
float left=-1,
float right=1,
float bottom=-1,
float top=1,
float near=0.1,
float far=100);
240 void setCamera(
const glm::vec3 &pos,
const glm::vec3 &
lookAt,
const glm::vec3 &up);
245 void setProjection(glm::mat4 &mat);
265 void setController(GLFWkeyfun keyCallback=
nullptr, GLFWcursorposfun cursorPosCallback=
nullptr,
266 GLFWmousebuttonfun mouseButtonCallback=
nullptr, GLFWscrollfun scrollCallback=
nullptr,
267 GLFWwindowsizefun windowSizeCallback=
nullptr);
275 void setBGcolor(
float r=0,
float g=0,
float b=0,
float a=0);
288 void enableLights(
bool enable=
true);
309 glm::mat4 getMatVP();
319 int setupGL(
const char *name);
326 void getAllEntity(std::vector<BaseEntity*> &children);
342 void defKeyCB(GLFWwindow* window,
int key,
int scancode,
int action,
int mods);
348 void defScrollCB(GLFWwindow* window,
double xoffset,
double yoffset);
The base for all Entity and Light.
Definition: entity.h:166
void rotate(float rad=0, const glm::vec3 &axis=glm::vec3(0), bool around=true)
Rotate the camera.
Definition: scene.cpp:256
int width
Width of the window.
Definition: scene.h:194
void viewScale(const glm::vec3 &s=glm::vec3(1))
Scale the view matrix.
Definition: scene.cpp:329
std::vector< Entity * > entities
Temporary store all the Entity before render.
Definition: scene.h:200
glm::vec3 _up
The up vector for the camera.
Definition: scene.h:22
std::vector< BaseEntity * > children
Stores all the Entity and Light.
Definition: scene.h:198
void lookAt(const glm::vec3 &target=glm::vec3(0))
Set the point the camera will look at.
Definition: scene.cpp:228
void defKeyCB(GLFWwindow *window, int key, int scancode, int action, int mods)
Default callback for key press.
Definition: scene.cpp:342
Definition: create_shader.cpp:4
GLFWwindow * window
The GLFW window for displaying everything.
Definition: scene.h:199
void viewTranslate(const glm::vec3 &d=glm::vec3(0))
Translate the view matrix.
Definition: scene.cpp:317
void rotateZ(float rad=0, bool around=true)
Rotate around the z-axis.
Definition: scene.cpp:297
Camera(const glm::vec3 &pos=glm::vec3(3, 4, 5), const glm::vec3 &lookAt=glm::vec3(0), const glm::vec3 &up=glm::vec3(0, 1, 0))
Creates a camera.
Definition: scene.cpp:211
glm::mat4 view
The view matrix.
Definition: scene.h:20
Camera camera
Camera for the scene.
Definition: scene.h:197
glm::vec3 _pos
The position of the camera.
Definition: scene.h:22
void setUp(const glm::vec3 &up=glm::vec3(0, 1, 0))
Set the up-vector.
Definition: scene.cpp:238
Scene class, which holds everything.
Definition: scene.h:191
void rotateY(float rad=0, bool around=true)
Rotate around the y-axis.
Definition: scene.cpp:289
std::vector< Light * > lights
Temporary store all the Light before render.
Definition: scene.h:201
void viewRotate(float rad=0, const glm::vec3 &axis=glm::vec3(0))
Rotate the view matrix.
Definition: scene.cpp:325
void defWindowSizeCB(GLFWwindow *window, int w, int h)
Default window resize callback.
Definition: scene.cpp:412
Camera class for the scene.
Definition: scene.h:17
glm::vec3 _lookAt
The point the camera looks at.
Definition: scene.h:22
void viewTransform(const glm::mat4 &m)
Transform the view matrix.
Definition: scene.cpp:337
void translate(const glm::vec3 &d=glm::vec3(0))
Translate (move, shift) the camera.
Definition: scene.cpp:305
void setPos(const glm::vec3 &pos=glm::vec3(3, 4, 5))
Sets the position of the camera.
Definition: scene.cpp:218
void setView(const glm::mat4 &mat)
Set the view matrix.
Definition: scene.cpp:248
glm::mat4 projection
Projection matrix for the render.
Definition: scene.h:196
void defScrollCB(GLFWwindow *window, double xoffset, double yoffset)
Default scroll callback.
Definition: scene.cpp:402
void rotateX(float rad=0, bool around=true, bool safe=true)
Rotate around the x-axis.
Definition: scene.cpp:279