// Copyright 2024 Bytedance Inc. All Rights Reserved. // Author: tianlei.richard@qq.com (tianlei.richard) #pragma once #include "triangle.h" #include class MinusRenderer { public: MinusRenderer(float near, float far, float fov, float aspect_ratio); public: cv::Mat render(const int resolution_width, const int resolution_height); public: bool load_mesh(const std::string &file_path); public: void model_transform(const TransformMatrix &mtx); void view_transform(const TransformMatrix &mtx); private: using Mesh = std::vector; private: static float calculate_height(const float fov, const float near); static float calculate_width(const float height, const float ratio); static TransformMatrix view_port_transform(const float width, const float height); private: TransformMatrix squish_tranform(); TransformMatrix orthographic_tranform(); private: float near_; float far_; float fov_; // In radian float aspect_ratio_; TransformMatrix projection_matrix_; std::vector meshes_; };