核心热路径(数学/内存/字符串/性能分析)用MASM汇编(SSE/AVX2) 外围系统(窗口/渲染/ECS/音频/UI/脚本)用C语言 含自研编辑器、VisualScript积木编程、中文渲染(glyph_atlas)
55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
#pragma once
|
|
|
|
// ============================================================================
|
|
// camera.h - 摄像机
|
|
// ============================================================================
|
|
|
|
#include "../include/engine_api.h"
|
|
#include "../ASM/math_c_fallback.h"
|
|
|
|
typedef enum {
|
|
CAMERA_PERSPECTIVE,
|
|
CAMERA_ORTHOGRAPHIC,
|
|
} CameraType;
|
|
|
|
typedef struct {
|
|
CameraType type;
|
|
Vec3 position;
|
|
Vec3 target;
|
|
Vec3 up;
|
|
float fov_y;
|
|
float aspect;
|
|
float near_z;
|
|
float far_z;
|
|
float ortho_width;
|
|
float ortho_height;
|
|
Mat4 view;
|
|
Mat4 projection;
|
|
int dirty;
|
|
} Camera;
|
|
|
|
// 创建默认透视摄像机
|
|
Camera camera_perspective(float fov_y, float aspect, float near_z, float far_z);
|
|
|
|
// 创建正交摄像机
|
|
Camera camera_orthographic(float width, float height, float near_z, float far_z);
|
|
|
|
// 更新矩阵
|
|
void camera_update(Camera* camera);
|
|
|
|
// 获取矩阵
|
|
const Mat4* camera_get_view(Camera* camera);
|
|
const Mat4* camera_get_projection(Camera* camera);
|
|
|
|
// 移动
|
|
void camera_move_forward(Camera* camera, float distance);
|
|
void camera_move_right(Camera* camera, float distance);
|
|
void camera_move_up(Camera* camera, float distance);
|
|
|
|
// 旋转
|
|
void camera_rotate_yaw(Camera* camera, float angle);
|
|
void camera_rotate_pitch(Camera* camera, float angle);
|
|
|
|
// 设置目标
|
|
void camera_look_at(Camera* camera, Vec3 target);
|