44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
|
// Copyright 2024 Bytedance Inc. All Rights Reserved.
|
||
|
// Author: tianlei.richard@bytedance.com (tianlei.richard)
|
||
|
|
||
|
#include <opencv2/core/core.hpp>
|
||
|
#include <opencv2/highgui/highgui.hpp>
|
||
|
|
||
|
#include "spdlog/spdlog.h"
|
||
|
|
||
|
#include "common.h"
|
||
|
#include "minus_renderer.h"
|
||
|
#include "triangle.h"
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
spdlog::set_level(spdlog::level::trace);
|
||
|
|
||
|
const int resolution_width = 320;
|
||
|
const int resolution_height = 180;
|
||
|
const int far = -1000;
|
||
|
const int near = -10;
|
||
|
const float fov = 120. / 360. * M_PI;
|
||
|
const float aspect_ratio = static_cast<float>(resolution_width) /
|
||
|
static_cast<float>(resolution_height);
|
||
|
|
||
|
std::vector<Triangle> primitives{
|
||
|
{Point3d{90, 45, -2}, Point3d{180, 135, -2}, Point3d{270, 45, -2}}};
|
||
|
|
||
|
cv::namedWindow("MinusRenderer", cv::WINDOW_AUTOSIZE);
|
||
|
const auto start = std::chrono::steady_clock::now();
|
||
|
MinusRenderer renderer{near, far, fov, aspect_ratio, std::move(primitives)};
|
||
|
do {
|
||
|
const auto elapse = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||
|
std::chrono::steady_clock::now() - start)
|
||
|
.count();
|
||
|
renderer.model_transform(
|
||
|
Eigen::AngleAxisd(0.125 * M_PI, Eigen::Vector3d::UnitY())
|
||
|
.toRotationMatrix());
|
||
|
const auto &color_image =
|
||
|
renderer.render(resolution_width, resolution_height);
|
||
|
cv::imshow("MinusRenderer", color_image);
|
||
|
} while (cv::waitKey(50) == -1);
|
||
|
cv::destroyWindow("MinusRenderer");
|
||
|
|
||
|
return 0;
|
||
|
}
|