-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Use assimp as mesh importer and exporter #1090
Conversation
8329e3b
to
750806b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add the cmake code to build assimp like the other libs
set(ASSIMP_TARGET assimp)
set(ASSIMP_BUILD_OPTIONS -DASSIMP_BUILD_ASSIMP_TOOLS:BOOL=OFF -DASSIMP_BUILD_TESTS:BOOL=OFF)
set(ASSIMP_AV_VERSION 5.0.1)
set(ASSIMP_FILENAME v${ASSIMP_AV_VERSION}.tar.gz)
ExternalProject_Add(${ASSIMP_TARGET}
URL https://github.com/assimp/assimp/archive/${ASSIMP_FILENAME}
DOWNLOAD_NAME assimp-${ASSIMP_FILENAME}
PREFIX ${BUILD_DIR}
BUILD_IN_SOURCE 0
BUILD_ALWAYS 0
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/assimp
BINARY_DIR ${BUILD_DIR}/assimp_build
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${CMAKE_CORE_BUILD_FLAGS} ${ASSIMP_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> <SOURCE_DIR>
)
set(ASSIMP_CMAKE_FLAGS -DAssimp_DIR:PATH=${CMAKE_INSTALL_PREFIX}/lib/cmake/assimp-${ASSIMP_AV_VERSION}/)
Verify the last line as I cannot check if it still installs assimp in a folder named assimp-${ASSIMP_VERSION}
map_indices[idPoint] = pts.size(); | ||
|
||
aiVector3D v = mesh->mVertices[idPoint]; | ||
pts.push_back(Point3d(v.x, v.y, v.z)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pts.push_back(Point3d(v.x, v.y, v.z)); | |
pts.emplace_back(v.x, v.y, v.z); |
requires to add the wrapper method to StaticVector
(I think it's worth it because if we ever manage to replace StaticVector with a "pure" std:vector (ie not as member of the class) everything will be smooth)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding this to StaticVector
should work
template< class... Args >
void emplace_back( Args&&... args )
{
_data.emplace_back(std::forward<Args>(args)...);
}
int vertexId = p.first.first; | ||
int uvId = p.first.second; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int vertexId = p.first.first; | |
int uvId = p.first.second; | |
const int vertexId = p.first.first; | |
const int uvId = p.first.second; |
src/aliceVision/mesh/Texturing.cpp
Outdated
fprintf(fmtl, "# \n\n"); | ||
for(int i = 0; i < _atlases[atlasId].size(); i++) | ||
{ | ||
int triangleId = _atlases[atlasId][i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int triangleId = _atlases[atlasId][i]; | |
const int triangleId = _atlases[atlasId][i]; |
src/aliceVision/mesh/Texturing.cpp
Outdated
fprintf(fmtl, "# Wavefront material file\n"); | ||
fprintf(fmtl, "# Created with AliceVision\n"); | ||
fprintf(fmtl, "# \n\n"); | ||
for(int i = 0; i < _atlases[atlasId].size(); i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for(int i = 0; i < _atlases[atlasId].size(); i++) | |
for(int i = 0; i < _atlases[atlasId].size(); ++i) |
src/aliceVision/mesh/Texturing.cpp
Outdated
int vertexId = mesh->tris[triangleId].v[k]; | ||
int uvId = mesh->trisUvIds[triangleId].m[k]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int vertexId = mesh->tris[triangleId].v[k]; | |
int uvId = mesh->trisUvIds[triangleId].m[k]; | |
const int vertexId = mesh->tris[triangleId].v[k]; | |
const int uvId = mesh->trisUvIds[triangleId].m[k]; |
src/aliceVision/mesh/Texturing.cpp
Outdated
aimesh->mFaces[i].mNumIndices = 3; | ||
aimesh->mFaces[i].mIndices = new unsigned int[3]; | ||
|
||
for (int k = 0; k < 3; k++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (int k = 0; k < 3; k++) | |
for (int k = 0; k < 3; ++k) |
src/aliceVision/mesh/Texturing.cpp
Outdated
fprintf(fobj, "# \n"); | ||
fprintf(fobj, "mtllib %s\n\n", mtlName.c_str()); | ||
fprintf(fobj, "g TexturedMesh\n"); | ||
if (_atlases.size() == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (_atlases.size() == 0) | |
if (_atlases.empty()) |
If node is null at this step it would have crashed earlier.
Is there a way to add a message in the OBJ file that it has been generated with AliceVision and specify the version? |
I think you can add it in the |
I'm merging it for now. |
There is no way to add metadata in obj files. |
Use assimp to be able to import and export mesh instead of custom code.
Currently just replacing the obj import and export function, but maybe updated later to be more generic