Skip to content

Commit

Permalink
SCENEGRAPH: added more coordinate system types
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Nov 12, 2024
1 parent 9dc8a90 commit 81a633c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/modules/scenegraph/CoordinateSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ enum class CoordinateSystem {
Vengi,
MagicaVoxel,
VXL,
DirectX,
OpenGL,
Maya,
Autodesk3dsmax,
Max,

};
Expand Down
33 changes: 25 additions & 8 deletions src/modules/scenegraph/CoordinateSystemUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,44 @@ namespace scenegraph {
//
// Generate right, forward and up direction vectors to express the desired coordinate system for vengi
//
// MV/VXL GL VENGI
// Blender Maya
// Right handed Left handed
// -----------------------------------------------
// Magicavoxel OpenGL VENGI
// VXL Maya DirectX12
// Blender
// 3dsmax
//
// Z Y Y
// | Y | | Z
// |/ | |/
// o----X o----X o----X
// /
// Z
// Z Y Y
// | Y | | Z
// |/ | |/
// o----X o----X o----X
// /
// Z
//
bool coordinateSystemToMatrix(CoordinateSystem sys, glm::mat4 &matrix) {
// read the assignment as: our right is your ... (and so on)
// so right = glm::right() is a no-op, but right = glm::vec3(-1, 0, 0)
// would mean: our right is your left (with your left given in opengl
// coordinate system)
glm::vec3 right;
glm::vec3 up;
glm::vec3 forward;
switch (sys) {
case CoordinateSystem::DirectX:
case CoordinateSystem::Vengi:
// no-op for conversion to vengi
right = glm::right();
up = glm::up();
forward = glm::forward();
break;
case CoordinateSystem::Maya:
case CoordinateSystem::OpenGL:
// opengl forward is the vengi backward
right = glm::vec3(1.0f, 0.0f, 0.0f);
up = glm::vec3(0.0f, 1.0f, 0.0f);
forward = glm::vec3(0.0f, 0.0f, 1.0f);
break;
case CoordinateSystem::Autodesk3dsmax:
case CoordinateSystem::MagicaVoxel:
case CoordinateSystem::VXL:
// Z-up coordinate system (like 3dsmax).
Expand Down

0 comments on commit 81a633c

Please sign in to comment.