Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE #515 FBX rotated on axis #668

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ matrix:
- tar -zxf testData/bouncer/ext_libs/focal/mongo-cxx-driver.tgz
- export MONGO_ROOT=$PWD/mongo-cxx-driver
- echo ============ ASSIMP INSTALL =============
- tar -zxf testData/bouncer/ext_libs/focal/assimp.tgz
- tar -zxf testData/bouncer/ext_libs/focal/assimp-5.0.1.tgz
- export ASSIMP_ROOT=$PWD/assimp
- echo ============ IFCOPENSHELL INSTALL =============
- tar -zxf testData/bouncer/ext_libs/focal/IfcOpenShell_v0.6.0/OCCT_3drepoFix.tgz
Expand Down Expand Up @@ -126,7 +126,7 @@ matrix:
- tar -zxf testData/focal/mongo-cxx-driver.tgz
- export MONGO_ROOT=$PWD/mongo-cxx-driver
- echo ============ ASSIMP INSTALL =============
- tar -zxf testData/focal/assimp.tgz
- tar -zxf testData/focal/assimp-5.0.1.tgz
- export ASSIMP_ROOT=$PWD/assimp
- echo ============ IFCOPENSHELL INSTALL =============
- tar -zxf testData/focal/IfcOpenShell_v0.6.0/OCCT_3drepoFix.tgz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,26 @@ namespace repo {
{
private:
bool applyReductions;
bool rotateModel;
bool importAnimations;
int lod;
std::string timeZone;
ModelUnits targetUnits;
public:
ModelImportConfig(
const bool applyReductions = true,
const bool rotateModel = false,
const bool importAnimations = true,
const ModelUnits targetUnits = ModelUnits::UNKNOWN,
const std::string timeZone = "",
const int lod = 0) :
applyReductions(applyReductions),
rotateModel(rotateModel),
importAnimations(importAnimations),
targetUnits(targetUnits),
timeZone(timeZone),
applyReductions(applyReductions),
importAnimations(importAnimations),
targetUnits(targetUnits),
timeZone(timeZone),
lod(lod) {}

~ModelImportConfig() {}

bool shouldApplyReductions() const { return applyReductions; }
bool shouldRotateModel() const { return rotateModel; }
bool shouldImportAnimations() const { return importAnimations; }
std::string getTimeZone() const { return timeZone; }
ModelUnits getTargetUnits() const { return targetUnits; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ repo::core::model::RepoScene* ModelImportManager::ImportFromFile(
error = REPOERR_NO_MESHES;
}
else {
if (config.shouldRotateModel() || modelConvertor->requireReorientation()) {
if (modelConvertor->requireReorientation()) {
repoTrace << "rotating model by 270 degress on the x axis...";
scene->reorientateDirectXModel();
}
Expand Down
28 changes: 3 additions & 25 deletions client/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ int32_t importFileAndCommit(
timeZone = jsonTree.get<std::string>("timezone", "");
units = jsonTree.get<std::string>("units", "");
lod = jsonTree.get<int>("lod", 0);
rotate = jsonTree.get<bool>("dxrotate", rotate);
importAnimations = jsonTree.get<bool>("importAnimations", importAnimations);
fileLoc = jsonTree.get<std::string>("file", "");
auto revIdStr = jsonTree.get<std::string>("revId", "");
Expand All @@ -453,33 +452,13 @@ int32_t importFileAndCommit(

if (command.nArgcs > 3)
{
//If 3rd argument is "dxrotate", we need to rotate the X axis
//Otherwise the user is trying to name the owner, rotate is false.
std::string arg3 = command.args[3];
if (arg3 == "dxrotate")
{
rotate = true;
}
else
{
owner = command.args[3];
}
}
if (command.nArgcs > 4)
{
//If the last argument is rotate, this is owner
//otherwise this is configFile (confusing, I know.)
if (rotate)
{
owner = command.args[4];
}
owner = command.args[3];
}
}

boost::filesystem::path filePath(fileLoc);
std::string fileExt = filePath.extension().string();
std::transform(fileExt.begin(), fileExt.end(), fileExt.begin(), ::toupper);
rotate |= fileExt == FBX_EXTENSION;

auto targetUnits = repo::manipulator::modelconvertor::ModelUnits::UNKNOWN;

Expand All @@ -491,12 +470,11 @@ int32_t importFileAndCommit(
//Something like this: http://stackoverflow.com/questions/15541498/how-to-implement-subcommands-using-boost-program-options

repoLog("File: " + fileLoc + " database: " + database
+ " project: " + project + " target units: " + (units.empty() ? "none" : units) + " rotate: "
+ (rotate ? "true" : "false") + " owner :" + owner + " importAnimations: " + (importAnimations ? "true" : "false")
+ " project: " + project + " target units: " + (units.empty() ? "none" : units) + " owner :" + owner + " importAnimations: " + (importAnimations ? "true" : "false")
+ " lod: " + std::to_string(lod)
);

repo::manipulator::modelconvertor::ModelImportConfig config(true, rotate, importAnimations, targetUnits, timeZone, lod);
repo::manipulator::modelconvertor::ModelImportConfig config(true, importAnimations, targetUnits, timeZone, lod);
uint8_t err;
repo::core::model::RepoScene *graph = controller->loadSceneFromFile(fileLoc, err, config);
if (graph)
Expand Down
4 changes: 2 additions & 2 deletions cmake_modules/FindASSIMPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ if(DEFINED ENV{ASSIMP_ROOT})
find_path(ASSIMP_INCLUDE_DIR assimp
${ASSIMP_ROOT}/include
)
find_library(ASSIMP_LIBRARIES_RELEASE NAMES assimp-vc120-mt assimp-vc130-mt assimp-vc140-mt assimp
find_library(ASSIMP_LIBRARIES_RELEASE NAMES assimp-vc120-mt assimp-vc130-mt assimp-vc140-mt assimp-vc143-mt assimp
PATHS
${ASSIMP_ROOT}/lib
)
find_library(ASSIMP_LIBRARIES_DEBUG NAMES assimp-vc120-mtd assimp-vc130-mtd assimp-vc130-mt assimp-vc140-mt assimp-vc140-mtd assimp-vc120-mt assimpd assimp
find_library(ASSIMP_LIBRARIES_DEBUG NAMES assimp-vc120-mtd assimp-vc130-mtd assimp-vc130-mt assimp-vc140-mt assimp-vc140-mtd assimp-vc143-mtd assimp-vc143-mt assimp-vc120-mt assimpd assimp
PATHS
${ASSIMP_ROOT}/lib
)
Expand Down
11 changes: 0 additions & 11 deletions test/src/unit/repo/ut_repo_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ TEST(RepoControllerTest, LoadSceneFromFile) {
EXPECT_TRUE(sceneNoReduction->getAllTransformations(defaultG).size()
> scene->getAllTransformations(defaultG).size());

//Import the scene with root trans rotated
auto sceneRotated = controller->loadSceneFromFile(getDataPath(simpleModel), errCode, repo::manipulator::modelconvertor::ModelImportConfig(true, true, true));
EXPECT_EQ(errCode, 0);
EXPECT_TRUE(sceneRotated);
ASSERT_TRUE(sceneRotated->getRoot(defaultG));
EXPECT_TRUE(sceneRotated->getRoot(optG));
EXPECT_FALSE(sceneRotated->isMissingTexture());
//The root transformation should not be an identity
core::model::TransformationNode *rootTrans = dynamic_cast<core::model::TransformationNode*>(sceneRotated->getRoot(defaultG));
EXPECT_FALSE(rootTrans->isIdentity());

//Import the scene with non existant file
auto sceneNoFile = controller->loadSceneFromFile("thisFileDoesntExist.obj", errCode);
EXPECT_EQ(errCode, REPOERR_MODEL_FILE_READ);
Expand Down
Loading