SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
camera.h
Go to the documentation of this file.
1#ifndef LUA_CAMERA_H
2#define LUA_CAMERA_H
3
12inline int Camera::lua_cameraPosition(lua_State * lua)
13{
14 int args = lua_gettop(lua);
15 bool spherical = false;
16 if (args == 1)
17 {
18 LuaBool b;
19 b.read(lua, 1);
20 spherical = b.bit;
21 }
22
23 glm::vec3 pos = position(spherical);
24
25 lua_pushnumber(lua, pos.x);
26 lua_pushnumber(lua, pos.y);
27 lua_pushnumber(lua, pos.z);
28
29 return 3;
30}
31
42inline int Camera::lua_setCameraPosition(lua_State * lua)
43{
44 int args = lua_gettop(lua);
45 if (args != 3)
46 {
47 const std::string msg = "setCameraPosition expects r, theta, and phi as arguments.\n";
48 lua_pushlstring(lua, msg.c_str(), msg.length());
49 return lua_error(lua);
50 }
51
52 LuaNumber r, theta, phi;
53 r.read(lua, 1);
54 theta.read(lua, 2);
55 phi.read(lua, 3);
56 setPosition(glm::vec3(r.n, theta.n, phi.n));
57
58 return 0;
59}
60
69inline int Camera::lua_rotateCamera(lua_State * lua)
70{
71 int args = lua_gettop(lua);
72 if (args != 1)
73 {
74 const std::string msg = "rotateCamera expects a number as argument.\n";
75 lua_pushlstring(lua, msg.c_str(), msg.length());
76 return lua_error(lua);
77 }
78
80 dphi.read(lua, 1);
81 rotate(-dphi.n);
82
83 return 0;
84}
85
94inline int Camera::lua_zoomCamera(lua_State * lua)
95{
96 int args = lua_gettop(lua);
97 if (args != 1)
98 {
99 const std::string msg = "zoomCamera expects a number as argument.\n";
100 lua_pushlstring(lua, msg.c_str(), msg.length());
101 return lua_error(lua);
102 }
103
105 dr.read(lua, 1);
106 zoom(-dr.n);
107
108 return 0;
109}
110
119inline int Camera::lua_inclineCamera(lua_State * lua)
120{
121 int args = lua_gettop(lua);
122 if (args != 1)
123 {
124 const std::string msg = "inclineCamera expects a number as argument.\n";
125 lua_pushlstring(lua, msg.c_str(), msg.length());
126 return lua_error(lua);
127 }
128
130 dtheta.read(lua, 1);
131 incline(dtheta.n);
132
133 return 0;
134}
135
144inline int Camera::lua_setCameraFieldOfView(lua_State * lua)
145{
146 int args = lua_gettop(lua);
147 if (args != 1)
148 {
149 const std::string msg = "setCameraFieldOfView expects a number as argument.\n";
150 lua_pushlstring(lua, msg.c_str(), msg.length());
151 return lua_error(lua);
152 }
153
154 LuaNumber fov;
155 fov.read(lua, 1);
156 fieldOfView = fov.n;
157 reset();
158
159 return 0;
160}
161
169inline int Camera::lua_getCameraFieldOfView(lua_State * lua)
170{
171 lua_pushnumber(lua, fieldOfView);
172 return 1;
173}
174
175#endif /* LUA_CAMERA_H */
void reset()
Set the default view.
Definition camera.h:62
int lua_setCameraPosition(lua_State *lua)
Set Camera position.
Definition camera.h:42
void setPosition(glm::vec3 positionSpherical)
Set the camera's position.
Definition camera.h:150
int lua_cameraPosition(lua_State *lua)
Get the Camera position.
Definition camera.h:12
int lua_rotateCamera(lua_State *lua)
Rotate the Camera.
Definition camera.h:69
int lua_getCameraFieldOfView(lua_State *lua)
Set the field of view.
Definition camera.h:169
glm::vec3 position(bool spherical=false) const
Return the cartesian position vector.
Definition camera.h:163
int lua_inclineCamera(lua_State *lua)
Incline the camera.
Definition camera.h:119
void rotate(float increment)
Rotate about the y OpenGL axis.
Definition camera.h:136
int lua_setCameraFieldOfView(lua_State *lua)
Set the field of view.
Definition camera.h:144
void zoom(float increment)
Increment the zoom.
Definition camera.h:110
void incline(float increment)
Incline about the y OpenGL axis.
Definition camera.h:117
int lua_zoomCamera(lua_State *lua)
Zoom the Camera.
Definition camera.h:94
const float dr
Definition main.h:37
const float dphi
Definition main.h:39
const float dtheta
Definition main.h:38
const T phi
Golden ratio.
Definition meshes.h:12
Interop for booleans Lua.
Definition LuaBool.h:11
void read(lua_State *lua, int index)
Read the bool from stack index index.
Definition LuaBool.h:27
bool bit
Definition LuaBool.h:85
Interop for a number in Lua.
Definition LuaNumber.h:11
double n
Definition LuaNumber.h:84
void read(lua_State *lua, int index)
Read the number from stack index index.
Definition LuaNumber.h:26