Somewhat improved wrapping
This commit is contained in:
parent
2a12a1f119
commit
7651923ee8
@ -13,3 +13,13 @@ Transform::Transform(Vector3 position, Vector3 rotation) {
|
|||||||
void Transform::Translate(cfloat x, cfloat y, cfloat z) {
|
void Transform::Translate(cfloat x, cfloat y, cfloat z) {
|
||||||
position = position + Vector3(x, y, z);
|
position = position + Vector3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Vector3 Transform::Forward() {
|
||||||
|
Vector3 forward(0.0f, 0.0f, -1.0f);
|
||||||
|
Matrix mat(1.0f);
|
||||||
|
mat = glm::rotate(mat, this->rotation.x, Vector3(1.0f, 0.0f, 0.0f));
|
||||||
|
mat = glm::rotate(mat, this->rotation.y, Vector3(0.0f, 1.0f, 0.0f));
|
||||||
|
mat = glm::rotate(mat, this->rotation.z, Vector3(0.0f, 0.0f, 1.0f));
|
||||||
|
return mat * glm::vec4(forward, 1.0f);
|
||||||
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef TRANSFORM_H
|
#ifndef TRANSFORM_H
|
||||||
#define TRANSFORM_H
|
#define TRANSFORM_H
|
||||||
|
|
||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
struct Transform {
|
struct Transform {
|
||||||
@ -9,6 +11,7 @@ struct Transform {
|
|||||||
Vector3 position;
|
Vector3 position;
|
||||||
Vector3 rotation;
|
Vector3 rotation;
|
||||||
void Translate(cfloat x, cfloat y, cfloat z);
|
void Translate(cfloat x, cfloat y, cfloat z);
|
||||||
|
Vector3 Forward();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TRANSFORM_H */
|
#endif /* TRANSFORM_H */
|
||||||
|
5
main.lua
5
main.lua
@ -31,7 +31,10 @@ function init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function update(delta)
|
function update(delta)
|
||||||
camera.transform:Translate(vx * delta, 0.0, vz * delta)
|
local cam_forwards = camera.transform:Forward()
|
||||||
|
--local vec1 = couch.Vector3() + couch.Vector3()
|
||||||
|
--camera.transform.position = camera.transform.position + cam_forwards
|
||||||
|
--camera.transform:Translate(vx * delta, 0.0, vz * delta)
|
||||||
camera.transform.rotation.y = camera.transform.rotation.y - cam_rot_x * delta
|
camera.transform.rotation.y = camera.transform.rotation.y - cam_rot_x * delta
|
||||||
cam_rot_x = 0.0
|
cam_rot_x = 0.0
|
||||||
camera.transform.rotation.x = camera.transform.rotation.x - cam_rot_y * delta
|
camera.transform.rotation.x = camera.transform.rotation.x - cam_rot_y * delta
|
||||||
|
4
scripting/.dir-locals.el
Normal file
4
scripting/.dir-locals.el
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
;;; Directory Local Variables
|
||||||
|
;;; For more information see (info "(emacs) Directory Variables")
|
||||||
|
|
||||||
|
((c-mode . ((mode . c++))))
|
@ -1,9 +1,9 @@
|
|||||||
%module couch
|
%module couch
|
||||||
|
|
||||||
%typemap(in) cfloat {
|
%include "typemaps.i"
|
||||||
$1 = (cfloat) lua_tonumber(L, $input);
|
|
||||||
}
|
|
||||||
%{
|
%{
|
||||||
|
#include "types.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "Transform.h"
|
#include "Transform.h"
|
||||||
#include "Spatial.h"
|
#include "Spatial.h"
|
||||||
@ -12,10 +12,17 @@
|
|||||||
#include "Ball.h"
|
#include "Ball.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
typedef float cfloat;
|
typedef float cfloat;
|
||||||
struct Vector3 {
|
%ignore "cfloat";
|
||||||
|
|
||||||
|
class Vector3 {
|
||||||
|
public:
|
||||||
cfloat x, y, z;
|
cfloat x, y, z;
|
||||||
};
|
};
|
||||||
|
%ignore "Vector3";
|
||||||
|
|
||||||
|
%include "types.h"
|
||||||
%include "Node.h"
|
%include "Node.h"
|
||||||
%include "Spatial.h"
|
%include "Spatial.h"
|
||||||
%include "Transform.h"
|
%include "Transform.h"
|
||||||
@ -23,3 +30,4 @@ struct Vector3 {
|
|||||||
%include "Mesh.h"
|
%include "Mesh.h"
|
||||||
%include "Ball.h"
|
%include "Ball.h"
|
||||||
%include "Camera.h"
|
%include "Camera.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user