Added Eigen, replacing ZMath
This commit is contained in:
1 parent
9bfe2bef89
commit
144978bfa2
20 files changed
+167
-936
No files matched your search
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils/ZLMath.h"
|
||||
#include "utils/Perlin.h"
|
||||
#include "render/Renderer.h"
|
||||
#include <vector>
|
||||
|
||||
@@ -124,9 +124,9 @@ namespace ZL {
|
||||
// 2. Трансформируем вершины в локальное пространство экрана, чтобы найти габариты
|
||||
// Используем MultMatrixVector(Matrix, Vector).
|
||||
// Если ваша функция считает V * M, то передайте Inverse(mr).
|
||||
Vector3f rA = MultMatrixVector(mr, tr.data[0]);
|
||||
Vector3f rB = MultMatrixVector(mr, tr.data[1]);
|
||||
Vector3f rC = MultMatrixVector(mr, tr.data[2]);
|
||||
Vector3f rA = mr * tr.data[0];
|
||||
Vector3f rB = mr * tr.data[1];
|
||||
Vector3f rC = mr * tr.data[2];
|
||||
|
||||
// 3. Вычисляем реальные границы треугольника после поворота
|
||||
float minX = min(rA(0), min(rB(0), rC(0)));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils/ZLMath.h"
|
||||
#include "render/Renderer.h"
|
||||
#include "render/TextureManager.h"
|
||||
#include <vector>
|
||||
|
||||
@@ -111,9 +111,9 @@ namespace ZL {
|
||||
|
||||
/*
|
||||
// Случайный поворот (например, вокруг трех осей)
|
||||
Vector4f qx = QuatFromRotateAroundX(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qy = QuatFromRotateAroundY(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qz = QuatFromRotateAroundZ(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qx = Eigen::Quaternionf(Eigen::AngleAxisf(getRandomFloat(engine, 0.0f, 360.0f), Eigen::Vector3f::UnitX()));//QuatFromRotateAroundX(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qy = Eigen::Quaternionf(Eigen::AngleAxisf(getRandomFloat(engine, 0.0f, 360.0f), Eigen::Vector3f::UnitY()));//QuatFromRotateAroundY(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qz = Eigen::Quaternionf(Eigen::AngleAxisf(getRandomFloat(engine, 0.0f, 360.0f), Eigen::Vector3f::UnitZ()));//QuatFromRotateAroundZ(getRandomFloat(engine, 0.0f, 360.0f));
|
||||
Vector4f qFinal = slerp(qx, qy, 0.5f); // Простой пример комбинирования
|
||||
qFinal = slerp(qFinal, qz, 0.5f).normalized();
|
||||
Matrix3f rotationMatrix = QuatToMatrix(qFinal);
|
||||
@@ -320,7 +320,7 @@ namespace ZL {
|
||||
|
||||
|
||||
for (const auto& inst : allInstances[index]) {
|
||||
Matrix3f rotMat = QuatToMatrix(inst.rotation);
|
||||
Matrix3f rotMat = inst.rotation.toRotationMatrix();
|
||||
|
||||
for (size_t j = 0; j < baseStone.PositionData.size(); ++j) {
|
||||
Vector3f p = baseStone.PositionData[j];
|
||||
@@ -330,8 +330,8 @@ namespace ZL {
|
||||
p(1) *= inst.scale(1) * scaleModifier;
|
||||
p(2) *= inst.scale(2) * scaleModifier;
|
||||
|
||||
result.data.PositionData.push_back(MultMatrixVector(rotMat, p) + inst.position);
|
||||
result.data.NormalData.push_back(MultMatrixVector(rotMat, n));
|
||||
result.data.PositionData.push_back(rotMat * p + inst.position);
|
||||
result.data.NormalData.push_back(rotMat * n);
|
||||
result.data.TexCoordData.push_back(baseStone.TexCoordData[j]);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "utils/ZLMath.h"
|
||||
#include "render/Renderer.h"
|
||||
#include "PlanetData.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user