1818
1919#include " Camera.h"
2020
21+ #include " LuaHelpers.h"
22+
2123namespace ExtraUtilities ::Lua::Camera
2224{
23- int GetZoom (lua_State* L)
25+ int GetMatrix (lua_State* L)
2426 {
25- int camera = luaL_checkinteger (L, 1 );
27+ BZR::BZR_Camera* cam = mainCam.Get ();
28+ BZR::MAT_3D mat = cam->Matrix ;
2629
27- using enum BZR::Camera::View;
28- switch (camera)
29- {
30- case FIRST_PERSON:
31- lua_pushnumber (L, zoomFPP.Read ());
32- break ;
33- case THIRD_PERSON:
34- lua_pushnumber (L, zoomTPP.Read ());
35- break ;
36- default :
37- luaL_argerror (L, 1 , " Extra Utilities Error: Invalid camera" );
38- return 0 ;
39- }
40- return 1 ;
41- }
30+ // these fields need to be negated idk why probably
31+ // some 3d graphics stuff I don't understand lol
32+ mat.right_z = -mat.right_z ;
33+ mat.up_z = -mat.up_z ;
34+ mat.front_x = -mat.front_x ;
35+
36+ // the matrix field has junk data in the position fields,
37+ // but the real position is in the first field of the view pyramid
38+ mat.posit_x = cam->View_Pyramid [0 ].x ;
39+ mat.posit_y = cam->View_Pyramid [0 ].y ;
40+ mat.posit_z = cam->View_Pyramid [0 ].z ;
4241
43- int SetZoom (lua_State* L)
44- {
45- int camera = luaL_checkinteger (L, 1 );
46- float zoom = static_cast <float >(luaL_checknumber (L, 2 ));
42+ PushMatrix (L, mat);
4743
48- using enum BZR::Camera::View;
49- switch (camera)
50- {
51- case FIRST_PERSON:
52- zoomFPP.Write (zoom);
53- break ;
54- case THIRD_PERSON:
55- zoomTPP.Write (zoom);
56- break ;
57- default :
58- luaL_argerror (L, 1 , " Extra Utilities Error: Invalid camera" );
59- return 0 ;
60- }
61- return 0 ;
44+ return 1 ;
6245 }
6346
64- int GetMinZoom (lua_State* L)
47+ int GetMaxZoom (lua_State* L)
6548 {
66- lua_pushnumber (L, minZoom .Read ());
49+ lua_pushnumber (L, maxZoom .Read ());
6750 return 1 ;
6851 }
6952
70- int SetMinZoom (lua_State* L)
53+ int SetMaxZoom (lua_State* L)
7154 {
7255 float zoom = static_cast <float >(luaL_checknumber (L, 1 ));
73- minZoom .Write (zoom);
56+ maxZoom .Write (zoom);
7457 return 0 ;
7558 }
7659
77- int GetMaxZoom (lua_State* L)
60+ int GetMinZoom (lua_State* L)
7861 {
79- lua_pushnumber (L, maxZoom .Read ());
62+ lua_pushnumber (L, minZoom .Read ());
8063 return 1 ;
8164 }
8265
83- int SetMaxZoom (lua_State* L)
66+ int SetMinZoom (lua_State* L)
8467 {
8568 float zoom = static_cast <float >(luaL_checknumber (L, 1 ));
86- maxZoom .Write (zoom);
69+ minZoom .Write (zoom);
8770 return 0 ;
8871 }
8972
@@ -121,4 +104,45 @@ namespace ExtraUtilities::Lua::Camera
121104
122105 return 0 ;
123106 }
107+
108+ int GetZoom (lua_State* L)
109+ {
110+ int camera = luaL_checkinteger (L, 1 );
111+
112+ using enum BZR::Camera::View;
113+ switch (camera)
114+ {
115+ case FIRST_PERSON:
116+ lua_pushnumber (L, zoomFPP.Read ());
117+ break ;
118+ case THIRD_PERSON:
119+ lua_pushnumber (L, zoomTPP.Read ());
120+ break ;
121+ default :
122+ luaL_argerror (L, 1 , " Extra Utilities Error: Invalid camera" );
123+ return 0 ;
124+ }
125+ return 1 ;
126+ }
127+
128+ int SetZoom (lua_State* L)
129+ {
130+ int camera = luaL_checkinteger (L, 1 );
131+ float zoom = static_cast <float >(luaL_checknumber (L, 2 ));
132+
133+ using enum BZR::Camera::View;
134+ switch (camera)
135+ {
136+ case FIRST_PERSON:
137+ zoomFPP.Write (zoom);
138+ break ;
139+ case THIRD_PERSON:
140+ zoomTPP.Write (zoom);
141+ break ;
142+ default :
143+ luaL_argerror (L, 1 , " Extra Utilities Error: Invalid camera" );
144+ return 0 ;
145+ }
146+ return 0 ;
147+ }
124148}
0 commit comments