2017-01-14 17:14:23 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "math_types.h"
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "imgui_protot_ext.h"
|
2017-02-22 21:35:14 +01:00
|
|
|
#include "rbdl/rbdl.h"
|
|
|
|
#include "rbdl/addons/luamodel/luamodel.h"
|
|
|
|
|
|
|
|
namespace RigidBodyDynamics {
|
|
|
|
struct Model;
|
|
|
|
}
|
2017-01-14 17:14:23 +01:00
|
|
|
|
|
|
|
struct CharacterController {
|
|
|
|
enum ControllerState {
|
|
|
|
ControlStateJump,
|
|
|
|
ControlStateLast
|
|
|
|
};
|
|
|
|
|
2017-02-22 21:35:14 +01:00
|
|
|
bool mState[ControlStateLast];
|
2017-01-14 17:14:23 +01:00
|
|
|
|
2017-02-22 21:35:14 +01:00
|
|
|
Vector3f mDirection = Vector3f::Zero();
|
2017-01-14 17:14:23 +01:00
|
|
|
|
|
|
|
void reset() {
|
|
|
|
for (int i = 0; i < ControlStateLast; i++) {
|
2017-02-22 21:35:14 +01:00
|
|
|
mState[i] = false;
|
2017-01-14 17:14:23 +01:00
|
|
|
}
|
|
|
|
|
2017-02-22 21:35:14 +01:00
|
|
|
mDirection.setZero();
|
2017-01-14 17:14:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CharacterController() {
|
|
|
|
reset();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CharacterEntity {
|
|
|
|
/// Render entity
|
|
|
|
Entity *entity = nullptr;
|
2017-02-22 21:35:14 +01:00
|
|
|
Vector3f mPosition;
|
|
|
|
Vector3f mVelocity;
|
|
|
|
CharacterController mController;
|
|
|
|
|
|
|
|
RigidBodyDynamics::Model* mRigModel = nullptr;
|
2017-01-14 17:14:23 +01:00
|
|
|
|
|
|
|
CharacterEntity ();
|
|
|
|
~CharacterEntity ();
|
|
|
|
|
2017-02-22 22:44:05 +01:00
|
|
|
void Reset() {
|
2017-02-22 21:35:14 +01:00
|
|
|
mPosition.setZero();
|
|
|
|
mVelocity.setZero();
|
|
|
|
mController.reset();
|
2017-01-14 17:14:23 +01:00
|
|
|
}
|
|
|
|
|
2017-02-22 22:44:05 +01:00
|
|
|
bool LoadRig (const char* filename);
|
|
|
|
|
|
|
|
void Update(float dt);
|
2017-01-14 17:14:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void ShowCharacterPropertiesWindow (CharacterEntity* character);
|