Skip to content

feat:1.add 3mf vertex color read 2.fix 3mf read texture bug - #5361

Merged
kimkulling merged 7 commits into
assimp:masterfrom
GalenXiao:feat_read_3mf_vertex_color
Feb 4, 2024
Merged

kimkulling merged 7 commits into
assimp:masterfrom
GalenXiao:feat_read_3mf_vertex_color

Conversation

@GalenXiao

@GalenXiao GalenXiao commented Dec 3, 2023 •

Copy link
Copy Markdown
Contributor

Hello, I am a 3D printing engineer and I have been following your project for a long time. It has been of great help to me. However, there are some frustrating things. Your support for 3mf files is too poor, only providing basic model data. However, for the 3D printing industry, the texture data and color information corresponding to 3mf are very important. The entire industry is currently moving towards full-color and multi-color trends. Therefore, I have hoped that you would open source these features a long time ago, but I have been waiting for a long time and there has been no update. So I thought of contributing my own strength. I have fixed these features and bugs. I hope we can promote the development of the 3D printing industry together. First of all, I want to point out that your understanding of 3mf is problematic, which may be related to your lack of understanding of the 3D printing industry. Below I want to point out the points you misunderstood:

  1. Resources actually have an inheritance relationship, for example
<‍object id="4" name="body776965" type="model" pid="3" pindex="0"> 
<‍triangles> 
<‍triangle v1="7" v2="1" v3="0"/> 

Although the face does not specify any features, it inherits the resource value of the object. When the face specifies the property, it will overwrite it, and it should inherit when it is not specified.

<‍triangle v1="213" v2="203" v3="199" pid="40" p1="0"/>
Here p1 p2 p3 means to update the corresponding vertices, p1 means to update the first vertex, p2 is used to update the second vertex, and p3 is used to update the third vertex. p1="0" means to update p1 with the value of index 0 in the resource group.
3. You ignored the color reading,

<‍m:colorgroup id="5"> 
  <‍m:color color="#FF0F8D"/> 
<‍/m:colorgroup> 

  1. When obtaining embedded textures, there is a bug. If it contains the word thumbnail, it means that it is only used for effect preview and cannot be used as a texture map. And I added jpeg. Finally, thank you for reading my statement. I hope you will seriously review my code. I don't want my pull request to be rejected in my heart, because I think it is a loss for this open source project.

@GitHubDragonFly

GitHubDragonFly commented Dec 5, 2023 •

Copy link
Copy Markdown

@GalenXiao there is something I would like to ask you about these changes.

Would any of these changes also need to be implemented and reflected in the D3MFExporter.cpp / D3MFExporter.h files?
Also, would EmbeddedTextures need to be somehow included?

I use the ASSIMP library together with ASSIMPJS, which all ends up in a JavaScript based ASSIMP Viewer, which in essence has the ASSIMP library import the model and then convert it to GLB2 format and pass it on to three.js GLTF Loader for displaying.

Just to mention that I have already tried your changes and did get vertex colors to show up but what did not work properly is the face colors (see the attached pictures) and textures still don't show, at least for me and the way I test these.

Bear in mind that my knowledge of C++ programming is rather basic and that there could be bugs in my code.

The following pictures show three.js facecolors.3mf example:

  • in the current code
  • after these new changes were applied
  • in my three.js based 3MF Viewer.

3mf FaceColors (before new changes)

3mf FaceColors (after new changes)

3mf FaceColors (three js based 3MF Viewer)

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly I'm sorry, I cannot open the 3D model you provided.
c52755b3-0f1d-41c2-afd4-7eb5d8dbae90
is html?

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly I believe it is also necessary to modify the code for exporting 3MF. I will add to it later. Thank you for the reminder. Regarding the issue of vertex colors that you mentioned, I regret to inform you that Assimp's data definition only considered one color per vertex. This works well for multiple model objects where each model object has a different color. However, for 3MF, it defines that within a mesh object, the colors of the triangular facets can be different, meaning that a vertex can have multiple colors. Therefore, after parsing, you will see the effect that you have observed. I cannot directly redefine Assimp's data structure, so it is indeed regrettable. Assimp can support multiple model objects well when the colors of the triangular facets are consistent across the object, such as with this stool.3MF.
331269b2-a59f-420e-9ee0-04347cd21dde
And then I also did a bug fix for texture reading.
7505910d-9f76-4d18-9ae0-0eb731c6daba

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly This is the corresponding 3MF file.
stool.3MF
And also the dinosaur. t-rex.3mf

@GitHubDragonFly

Copy link
Copy Markdown

@GalenXiao thank you for responding.

I will have to wait for any necessary changes to be made to the exporter since that is what my viewer relies on.

The link to facecolors.3mf file I provided in my previous response will take you to GitHub repository and you can download the file from there.

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@emaame @dnadlinger @iamsergio "Can you help me understand why the workflow has not been automatically initiated after such a long time?"

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly "Can you help me understand why the workflow has not been automatically initiated after such a long time?"

@GitHubDragonFly

Copy link
Copy Markdown

@GalenXiao besides for using ASSIMP library on my end, I don't really deal with it in this repository and cannot really answer your question.

@GitHubDragonFly

Copy link
Copy Markdown

@GalenXiao just so you are aware, my fork of ASSIMP has an updates branch which contains lots of customized code.

This "updates" branch currently includes:

  • your 3MF changes
  • most of the recent updates from the main ASSIMP repository which I added manually
  • OBJ + MTL and GLTF2 improvements currently not available in the main ASSIMP repository

My ASSIMP Viewer is using it and currently it can show your stool.3mf file properly.

If you are curious enough then try it for a test.

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly OK,I have seen it,you are great!

@iamsergio

Copy link
Copy Markdown
Contributor

@emaame @dnadlinger @iamsergio "Can you help me understand why the workflow has not been automatically initiated after such a long time?"

I don't know. Maybe ask the maintainer

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@kimkulling hello,can you help me understand why the workflow has not been automatically initiated after such a long time?

@turol

turol commented Dec 13, 2023

Copy link
Copy Markdown
Member

You're a first-time contributor so the workflow has to be manually approved. This is a GitHub -wide thing due to abuse by crypto miners.

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@kimkulling Hello,It seems like there might be an issue with the workflow, as I've noticed that the recent PRs are failing with errors related to Hunter, and the errors are consistent. Could it be possible to fix this? Also, could you help me re-trigger the workflow? This is my first time contributing code. Thank you very much!

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@turol Sure, thank you for your answer.

@GitHubDragonFly

Copy link
Copy Markdown

@GalenXiao for your information, it appears that your code is actually functional for showing single embedded texture.

My ASSIMP Viewer was importing the texture but also had material color set as (0, 0, 0) and that's why I couldn't see the texture. The attached picture below shows this as working now after changing the material color to (1, 1, 1).

I am not really sure why the material color gets set as (0, 0, 0), this is probably something that needs to be resolved in the library. Another issue that still seems to be present is importing multiple textures.

ASSIMP Viewer - 3MF

@GitHubDragonFly

Copy link
Copy Markdown

Here is a picture of the multiple textures example issue. It shows that only 1 texture is imported.

ASSIMP Viewer - 3MF Multiple Textures

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@kimkulling Why does hunter always fail to download zlib when I haven't changed cmakelist

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly assimp's data structure design only considers a mesh object corresponding to a texture map, if multiple texture maps, need to correspond to a texture in each mesh object, can only say very sorry, if you need a mesh object corresponding to multiple textures, then you may need to download the official sdk dedicated to parsing 3mf files

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GalenXiao I am sorry that I am busy at this time, so I cannot reply you in time. As for the problem that T-Rev.3MF cannot display normally, I think vertex color and texture are two things, and my own software will give priority to display texture if texture exists. Maybe you need to check your code logic below

@GalenXiao

Copy link
Copy Markdown
Contributor Author

@GitHubDragonFly assimp's data structure vertex color can only correspond to one and a mesh object can only correspond to one texture, if you want to fully support 3mf file features, I recommend you download Microsoft's official corresponding 3mf SDK.

@kimkulling

Copy link
Copy Markdown
Member

Hunter seems to be not the right solution. I am thinking to switch to vcpkg.

@kimkulling
kimkulling merged commit b7b6601 into assimp:master Feb 4, 2024
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks a lot for your contribution.

kimkulling added a commit that referenced this pull request Jul 1, 2026
* feat:1.add 3mf vertex color read 2.fix 3mf read texture bug

* fix checks failed

* Trigger CI

---------

Co-authored-by: Kim Kulling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants