Added Eigen, replacing ZMath
This commit is contained in:
1 parent
9bfe2bef89
commit
144978bfa2
20 files changed
+167
-936
No files matched your search
+9
-9
@@ -83,7 +83,7 @@ namespace ZL
|
||||
{
|
||||
Eigen::Quaternionf randomQuat = generateRandomQuaternion(gen);
|
||||
|
||||
Matrix3f randomMatrix = QuatToMatrix(randomQuat);
|
||||
Matrix3f randomMatrix = randomQuat.toRotationMatrix();
|
||||
|
||||
boxCoordsArr.emplace_back(BoxCoords{ newPos, randomMatrix });
|
||||
generatedCount++;
|
||||
@@ -205,7 +205,7 @@ namespace ZL
|
||||
//Load texture
|
||||
spaceshipTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/DefaultMaterial_BaseColor_shine.png", CONST_ZIP_FILE));
|
||||
spaceshipBase = LoadFromTextFile02("./resources/spaceship006.txt", CONST_ZIP_FILE);
|
||||
spaceshipBase.RotateByMatrix(QuatToMatrix(QuatFromRotateAroundY(M_PI / 2.0)));
|
||||
spaceshipBase.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI / 2.0, Eigen::Vector3f::UnitY())).toRotationMatrix());// QuatFromRotateAroundY(M_PI / 2.0).toRotationMatrix());
|
||||
//spaceshipBase.Move(Vector3f{ -0.52998, -13, 0 });
|
||||
//spaceshipBase.Move(Vector3f{ -0.52998, -10, 10 });
|
||||
|
||||
@@ -571,10 +571,10 @@ namespace ZL
|
||||
// Конструктор принимает (угол_в_радианах, ось_вращения)
|
||||
Eigen::Quaternionf rotateQuat(Eigen::AngleAxisf(deltaAlpha, rotationDirection));
|
||||
|
||||
Matrix3f rotateMat = QuatToMatrix(rotateQuat);
|
||||
Matrix3f rotateMat = rotateQuat.toRotationMatrix();
|
||||
|
||||
Environment::shipMatrix = MultMatrixMatrix(Environment::shipMatrix, rotateMat);
|
||||
Environment::inverseShipMatrix = InverseMatrix(Environment::shipMatrix);
|
||||
Environment::shipMatrix = Environment::shipMatrix * rotateMat;
|
||||
Environment::inverseShipMatrix = Environment::shipMatrix.inverse();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -582,7 +582,7 @@ namespace ZL
|
||||
if (fabs(Environment::shipVelocity) > 0.01f)
|
||||
{
|
||||
Vector3f velocityDirection = { 0,0, -Environment::shipVelocity * delta / 1000.f };
|
||||
Vector3f velocityDirectionAdjusted = MultMatrixVector(Environment::shipMatrix, velocityDirection);
|
||||
Vector3f velocityDirectionAdjusted = Environment::shipMatrix * velocityDirection;
|
||||
Environment::shipPosition = Environment::shipPosition + velocityDirectionAdjusted;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ namespace ZL
|
||||
if (p && p->isActive()) {
|
||||
Vector3f worldPos = p->getPosition();
|
||||
Vector3f rel = worldPos - Environment::shipPosition;
|
||||
Vector3f camPos = MultMatrixVector(Environment::inverseShipMatrix, rel);
|
||||
Vector3f camPos = Environment::inverseShipMatrix * rel;
|
||||
projCameraPoints.push_back(camPos);
|
||||
}
|
||||
}
|
||||
@@ -636,10 +636,10 @@ namespace ZL
|
||||
const float size = 0.5f;
|
||||
|
||||
Vector3f localForward = { 0,0,-1 };
|
||||
Vector3f worldForward = MultMatrixVector(Environment::shipMatrix, localForward).normalized();
|
||||
Vector3f worldForward = (Environment::shipMatrix * localForward).normalized();
|
||||
|
||||
for (const auto& lo : localOffsets) {
|
||||
Vector3f worldPos = Environment::shipPosition + MultMatrixVector(Environment::shipMatrix, lo);
|
||||
Vector3f worldPos = Environment::shipPosition + Environment::shipMatrix * lo;
|
||||
Vector3f worldVel = worldForward * projectileSpeed;
|
||||
|
||||
for (auto& p : projectiles) {
|
||||
|
||||
Reference in new issue
Block a user