Selaa lähdekoodia

Mat4 binds for lua

mikymod 12 vuotta sitten
vanhempi
sitoutus
73b92f7539
2 muutettua tiedostoa jossa 19 lisäystä ja 9 poistoa
  1. 3 2
      src/CMakeLists.txt
  2. 16 7
      src/binds/Mat4Binds.cpp

+ 3 - 2
src/CMakeLists.txt

@@ -241,8 +241,9 @@ set (NETWORK_HEADERS
 )
 
 set (BINDS_SRC
-	binds/Vec3Bind.cpp
-	binds/QuatBind.cpp
+	binds/Vec3Binds.cpp
+	binds/QuatBinds.cpp
+	binds/Mat4Binds.cpp
 )
 
 set (CROWN_SOURCES

+ 16 - 7
src/binds/Mat4Binds.cpp

@@ -1,4 +1,6 @@
 #include "Mat4.h"
+#include "Vec3.h"
+#include "OS.h"
 
 namespace crown
 {
@@ -60,6 +62,8 @@ extern "C"
 	void				mat4_set_scale(Mat4* self, const Vec3* scale);
 
 	// Quat				mat4_to_quat();
+
+	void 				mat4_print(Mat4* self);
 }
 
 Mat4* mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3)
@@ -164,7 +168,7 @@ void mat4_build_viewpoint_billboard(Mat4* self, const Vec3* pos, const Vec3* tar
 
 void mat4_build_axis_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* axis)
 {
-	self->build_axis_billboard(*pos, *target, *up);
+	self->build_axis_billboard(*pos, *target, *axis);
 }
 
 Mat4* mat4_transpose(Mat4* self)
@@ -193,9 +197,7 @@ void mat4_load_identity(Mat4* self)
 
 Vec3* mat4_get_translation(Mat4* self)
 {
-	Vec3 tmp = self->get_translation();
-
-	return &tmp;
+	return new Vec3(self->get_translation());
 }
 
 void mat4_set_translation(Mat4* self, const Vec3* trans)
@@ -205,9 +207,7 @@ void mat4_set_translation(Mat4* self, const Vec3* trans)
 
 Vec3* mat4_get_scale(Mat4* self)
 {
-	Vec3 tmp = self->get_scale();
-
-	return &tmp;
+	return new Vec3(self->get_scale());
 }
 
 void mat4_set_scale(Mat4* self, const Vec3* scale)
@@ -215,4 +215,13 @@ void mat4_set_scale(Mat4* self, const Vec3* scale)
 	self->set_scale(*scale);
 }
 
+void mat4_print(Mat4* self)
+{
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[0], self->m[1], self->m[2], self->m[3]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[4], self->m[5], self->m[6], self->m[7]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[8], self->m[9], self->m[10], self->m[11]);
+	os::printf("|%.1f|%.1f|%.1f|%.1f|\n", self->m[12], self->m[13], self->m[14], self->m[15]);
+}
+
+
 } //namespace crown