Implemented skewable and fixed translation matrix for isometric coordinates
This commit is contained in:
parent
bc0ad0b9bc
commit
0402ed2a67
4 changed files with 38 additions and 7 deletions
|
@ -34,19 +34,29 @@ set(SOURCES
|
|||
src/primitives/circle_object.cpp
|
||||
src/primitives/circle_object.h
|
||||
src/game/game_factory.cpp
|
||||
src/game/game_factory.hpp src/config.h src/debug/grid_debug_layer.cpp src/debug/grid_debug_layer.h)
|
||||
src/game/game_factory.hpp
|
||||
src/config.h
|
||||
src/debug/grid_debug_layer.cpp
|
||||
src/debug/grid_debug_layer.h
|
||||
src/game/input/input_mapper.cpp src/game/input/input_mapper.h src/game/action_controller.cpp src/game/action_controller.h)
|
||||
|
||||
set(PHYSICS_00_SOURCES
|
||||
src/prototypes/physics_00.cpp
|
||||
)
|
||||
src/prototypes/physics_00.cpp)
|
||||
|
||||
set(MATH_00_SOURCES
|
||||
src/prototypes/math_00.cpp)
|
||||
|
||||
# Add an executable target
|
||||
add_executable(Holesome ${SOURCES})
|
||||
add_executable(Physics_00 ${PHYSICS_00_SOURCES})
|
||||
|
||||
add_executable(Math_00 ${MATH_00_SOURCES})
|
||||
|
||||
# Link SFML and other libraries to your executable target
|
||||
target_link_libraries(Holesome sfml-graphics sfml-audio)
|
||||
target_link_libraries(Holesome Eigen3::Eigen)
|
||||
target_link_libraries(Holesome ReactPhysics3D::ReactPhysics3D)
|
||||
|
||||
target_link_libraries(Physics_00 ReactPhysics3D::ReactPhysics3D)
|
||||
|
||||
target_link_libraries(Math_00 Eigen3::Eigen)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define KEY_REPEAT_ENABLED false
|
||||
|
||||
// Graphic settings
|
||||
#define WORLD_TO_ISO_SCALE 50.0f
|
||||
#define ISOMETRIC_SKEW 0.3f
|
||||
#define WORLD_TO_ISO_SCALE 10.0f
|
||||
|
||||
#endif //HOLESOME_CONFIG_H
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
// Initialize matrix
|
||||
const Eigen::Matrix<float, 3, 3> CoordinateTransformer::worldToIsometricMatrix =
|
||||
(Eigen::Matrix<float, 3, 3>() << 0.5f, 0.5f, 0,
|
||||
-0.5f, 0.5f, -1,
|
||||
1, 1, 0).finished();
|
||||
(Eigen::Matrix<float, 3, 3>() <<
|
||||
-1, 1, 0,
|
||||
-ISOMETRIC_SKEW, -ISOMETRIC_SKEW, -1,
|
||||
1, 1, 0
|
||||
).finished();
|
||||
|
||||
IsometricCoordinates CoordinateTransformer::worldToIsometric(WorldCoordinates worldCoordinates)
|
||||
{
|
||||
|
|
18
src/prototypes/math_00.cpp
Normal file
18
src/prototypes/math_00.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <iostream>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto matrix = (Eigen::Matrix<float, 3, 3>() << 1, 2, 3,
|
||||
4, 5, 6,
|
||||
7, 8, 9).finished();
|
||||
|
||||
auto vector = (Eigen::Vector3f() << 1, 2, 3).finished();
|
||||
|
||||
std::cout << matrix << std::endl << std::endl;
|
||||
std::cout << vector << std::endl << std::endl;
|
||||
std::cout << "Result m*v:" << std::endl << matrix * vector << std::endl << std::endl;;
|
||||
std::cout << "Result t(v)*m:" << std::endl << vector.transpose() * matrix << std::endl << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue