35 lines
799 B
C
35 lines
799 B
C
|
// Copyright 2024 Bytedance Inc. All Rights Reserved.
|
||
|
// Author: tianlei.richard@bytedance.com (tianlei.richard)
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include "triangle.h"
|
||
|
#include <opencv2/core/core.hpp>
|
||
|
|
||
|
class MinusRenderer {
|
||
|
public:
|
||
|
MinusRenderer(float near, float far, float fov, float aspect_ratio,
|
||
|
std::vector<Triangle> &&primitives);
|
||
|
|
||
|
public:
|
||
|
cv::Mat render(const int resolution_width, const int resolution_height);
|
||
|
|
||
|
public:
|
||
|
void model_transform(const Triangle::AffineTransformType &m);
|
||
|
|
||
|
private:
|
||
|
static int calculate_height(const float fov, const float near);
|
||
|
static int calculate_width(const float height, const float ratio);
|
||
|
|
||
|
private:
|
||
|
float near_;
|
||
|
float far_;
|
||
|
float fov_; // In radian
|
||
|
float aspect_ratio_;
|
||
|
|
||
|
int height_;
|
||
|
int width_;
|
||
|
|
||
|
std::vector<Triangle> primitives_;
|
||
|
};
|