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
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
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
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
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
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
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
136#endif /* LUA_CAMERA_H */
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
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
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
glm::vec< L, float, glm::qualifier::highp > vec
Definition commandLine.h:214
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
void read(lua_State *lua, int index)
Read the number from stack index index.
Definition LuaNumber.h:26