You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
899 B
43 lines
899 B
2 years ago
|
/*
|
||
|
* Copyright (C) 2022 Riyyi
|
||
|
*
|
||
|
* SPDX-License-Identifier: MIT
|
||
|
*/
|
||
|
|
||
2 years ago
|
#pragma once
|
||
4 years ago
|
|
||
2 years ago
|
#include "inferno/component/cameracomponent.h"
|
||
4 years ago
|
#include "inferno/script/nativescript.h"
|
||
|
|
||
4 years ago
|
#define TRANSLATE_SPEED 2.5f
|
||
|
#define ROTATE_SPEED 90.0f
|
||
|
#define ZOOM_SENSITIVITY 2.5f
|
||
|
#define MOUSE_SENSITIVITY 0.25f
|
||
|
|
||
10 months ago
|
namespace example {
|
||
4 years ago
|
|
||
10 months ago
|
class CameraController final : public Inferno::NativeScript {
|
||
2 years ago
|
public:
|
||
|
virtual void update(float deltaTime) override
|
||
|
{
|
||
10 months ago
|
m_camera = &getComponent<Inferno::CameraComponent>();
|
||
2 years ago
|
|
||
10 months ago
|
if (m_camera->type == Inferno::CameraType::Orthographic) {
|
||
2 years ago
|
updateOrthographic(deltaTime);
|
||
|
}
|
||
10 months ago
|
else if (m_camera->type == Inferno::CameraType::Perspective) {
|
||
2 years ago
|
updatePerspective(deltaTime);
|
||
4 years ago
|
}
|
||
2 years ago
|
}
|
||
4 years ago
|
|
||
2 years ago
|
void updateOrthographic(float deltaTime);
|
||
|
void updatePerspective(float deltaTime);
|
||
4 years ago
|
|
||
2 years ago
|
private:
|
||
10 months ago
|
Inferno::CameraComponent* m_camera { nullptr };
|
||
2 years ago
|
};
|
||
4 years ago
|
|
||
10 months ago
|
BIND_NATIVE(CameraController);
|
||
|
|
||
|
} // namespace example
|