/* Copyright (c) 2021 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __WalkCamera_H__ #define __WalkCamera_H__ #ifdef __cplusplus extern "C" { #endif typedef struct WalkCamera WalkCamera; #define WalkCamera_superclass Camera #include "gamemath/Camera.h" #include "gamemath/MoveInput.h" #define WalkCamera_ivars \ Camera_ivars \ \ Vector3f position; \ Vector3f velocity; \ Vector2f lookAngle; \ MoveInputState moveInput; \ float lookUpLimit; \ float lookDownLimit; \ float lookSensitivity; \ float acceleration; \ float deceleration; \ float speedMax; #define WalkCamera_vtable(self_type) \ Camera_vtable(self_type) stemobject_declare(WalkCamera) // lookAngle is a pair of radians, where x is yaw (positive is counterclockwise), y is pitch (positive is up) WalkCamera * WalkCamera_create(Vector3f position, Vector2f lookAngle); bool WalkCamera_init(WalkCamera * self, Vector3f position, Vector2f lookAngle); void WalkCamera_dispose(WalkCamera * self); Vector3f WalkCamera_getPosition(WalkCamera * self); Quaternionf WalkCamera_getOrientation(WalkCamera * self); Matrix4x4f WalkCamera_getTransform(WalkCamera * self); void WalkCamera_update(WalkCamera * self); void WalkCamera_adjustLook(WalkCamera * self, float deltaY, float deltaX); bool WalkCamera_startMoveInput(WalkCamera * self, MoveInput_axis axis, MoveInput_direction direction); bool WalkCamera_stopMoveInput(WalkCamera * self, MoveInput_axis axis, MoveInput_direction direction); #ifdef __cplusplus } #endif #endif