Skip to content

Commit

Permalink
make GL mfunctions part of ebarkit namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 6, 2023
1 parent e3997cb commit ad15a7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion WebARKit/WebARKitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cv::Mat WebARKitManager::getPoseMatrix() {

std::array<double, 16> WebARKitManager::getTransformationMatrix() {
std::array<double, 16> transformationMatrix;
arglCameraViewRHf(m_tracker->getPoseMatrix(), transformationMatrix, 1.0f);
webarkit::arglCameraViewRHf(m_tracker->getPoseMatrix(), transformationMatrix, 1.0f);
return transformationMatrix;
}

Expand Down
31 changes: 17 additions & 14 deletions WebARKit/include/WebARKitGL.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef WEBARKITGL_H
#define WEBARKITGL_H
#ifndef WEBARKIT_GL_H
#define WEBARKIT_GL_H

#include <opencv2/core.hpp>

namespace webarkit {

void arglCameraViewRHf(float para[3][4], float m_modelview[16], const float scale) {
m_modelview[0 + 0 * 4] = para[0][0]; // R1C1
m_modelview[0 + 1 * 4] = para[0][1]; // R1C2
Expand All @@ -28,18 +30,18 @@ void arglCameraViewRHf(float para[3][4], float m_modelview[16], const float scal
}

void arglCameraViewRHf(cv::Mat para, std::array<double, 16>& m_modelview, const double scale) {
m_modelview[0 + 0 * 4] = para<double>.at(0, 0); // R1C1
m_modelview[0 + 1 * 4] = para<double>.at(0, 1); // R1C2
m_modelview[0 + 2 * 4] = para<double>.at(0, 2);
m_modelview[0 + 3 * 4] = para<double>.at(0, 3);
m_modelview[1 + 0 * 4] = -para<double>.at(1, 0); // R2
m_modelview[1 + 1 * 4] = -para<double>.at(1, 1);
m_modelview[1 + 2 * 4] = -para<double>.at(1, 2);
m_modelview[1 + 3 * 4] = -para<double>.at(1, 3);
m_modelview[2 + 0 * 4] = -para<double>.at(2, 0); // R3
m_modelview[2 + 1 * 4] = -para<double>.at(2, 1);
m_modelview[2 + 2 * 4] = -para<double>.at(2, 2);
m_modelview[2 + 3 * 4] = -para<double>.at(2, 3);
m_modelview[0 + 0 * 4] = para.at<double>(0, 0); // R1C1
m_modelview[0 + 1 * 4] = para.at<double>(0, 1); // R1C2
m_modelview[0 + 2 * 4] = para.at<double>(0, 2);
m_modelview[0 + 3 * 4] = para.at<double>(0, 3);
m_modelview[1 + 0 * 4] = -para.at<double>(1, 0); // R2
m_modelview[1 + 1 * 4] = -para.at<double>(1, 1);
m_modelview[1 + 2 * 4] = -para.at<double>(1, 2);
m_modelview[1 + 3 * 4] = -para.at<double>(1, 3);
m_modelview[2 + 0 * 4] = -para.at<double>(2, 0); // R3
m_modelview[2 + 1 * 4] = -para.at<double>(2, 1);
m_modelview[2 + 2 * 4] = -para.at<double>(2, 2);
m_modelview[2 + 3 * 4] = -para.at<double>(2, 3);
m_modelview[3 + 0 * 4] = 0.0f;
m_modelview[3 + 1 * 4] = 0.0f;
m_modelview[3 + 2 * 4] = 0.0f;
Expand All @@ -50,5 +52,6 @@ void arglCameraViewRHf(cv::Mat para, std::array<double, 16>& m_modelview, const
m_modelview[14] *= scale;
}
}
} // namespace webarkit

#endif // WEBARKITGL_H

0 comments on commit ad15a7f

Please sign in to comment.