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

Feature: Support Wavefront OBJ files with TGA Textures #1719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gapry
Copy link

@gapry gapry commented Nov 17, 2024

Related Issue:

This work addresses the Issue: #1281

Current Progress

I download the free assets, DarkSider Mercy Gun 3D Model, as the input data to work the Issue: #1281

$ ./build/bin/f3d assets/DarkSiderGun/GUN_OBJ.obj

For now, I've written some tracing code to find out where to add the supported code. Here is the current tracing output.

[gapry][issues][1281][int F3DStarter::Start(int, char**)] assets/DarkSiderGun/GUN_OBJ.obj
[gapry][issues][1281][void F3DStarter::LoadFileGroup(int, bool, bool)] 000
[gapry][issues][1281][void F3DStarter::LoadFileGroup(const std::vector<std::filesystem::__cxx11::path>&, bool, const std::string&)] /home/gapry/Workspaces/f3d/assets/DarkSiderGun/GUN_OBJ.obj1(1/1)
[gapry][issues][1281][void F3DStarter::LoadFileGroup(const std::vector<std::filesystem::__cxx11::path>&, bool, const std::string&)] /home/gapry/Workspaces/f3d/assets/DarkSiderGun/GUN_OBJ.obj
[gapry][issues][1281][virtual f3d::scene& f3d::detail::scene_impl::add(const std::vector<std::filesystem::__cxx11::path>&)] /home/gapry/Workspaces/f3d/assets/DarkSiderGun/GUN_OBJ.obj
[gapry][issues][1281][void f3d::detail::scene_impl::internals::Load(const std::vector<vtkSmartPointer<vtkImporter> >&)]
[gapry][issues][1281][void vtkF3DMetaImporter::AddImporter(const vtkSmartPointer<vtkImporter>&)]

I'm sorry, I haven't finished yet. I will keep trying, I think the key is this->Pimpl->Importers. I think I need to know who used it.

void vtkF3DMetaImporter::AddImporter(const vtkSmartPointer<vtkImporter>& importer)
{
  F3DLog::Print(F3DLog::Severity::Info, std::string("[gapry][issues][1281][") + __PRETTY_FUNCTION__ + "] ");

  this->Pimpl->Importers.emplace_back(vtkF3DMetaImporter::Internals::ImporterPair {importer, false}); // [gapry][issues][1281]
  
  ... 
}  

@mwestphal
Copy link
Contributor

To fix this you need to make changes in VTK first though.

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.97%. Comparing base (ca4a69f) to head (1874f16).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1719   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files         106      106           
  Lines        8754     8763    +9     
=======================================
+ Hits         8489     8498    +9     
  Misses        265      265           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gapry
Copy link
Author

gapry commented Nov 17, 2024

Got it

I have read the document, https://gitlab.kitware.com/vtk/vtk/-/blob/master/CONTRIBUTING.md

and using the example as a starting point, https://examples.vtk.org/site/Cxx/IO/OBJImporter/

I find take a look at the testing data in vtk-example, it doesn't seem to have any TGA files.

So I will also to contribute an obj model with TGA textures to testing data in vtk-example

@mwestphal
Copy link
Contributor

Ok!

@mwestphal
Copy link
Contributor

Do you need help moving forward @gapry ?

@gapry
Copy link
Author

gapry commented Dec 10, 2024

Current Progress

  1. I have created an account on https://gitlab.kitware.com/ with the username gapry
  2. I have forked the VTK project, https://gitlab.kitware.com/vtk, to my repository, https://gitlab.kitware.com/gapry/vtk
  3. I created a new branch WavefrontOBJ-TGA to address the issue Obj's with tga textures don't get their textures displayed #1281
  4. I made the commit, https://gitlab.kitware.com/gapry/vtk/-/commit/119506e45f699d0ed74d5b7850cec406ab1a0d87, to add support for TGA images in Wavefront Obj files.
  5. I use the example, OBJImporter and the free assets DarkSider Mercy Gun to verify my implement, https://github.com/gapry/code-for-blog/tree/main/2024/OBJImporter.
    For now, it will output the following messages in the console
$ ./VTK_App.out GUN_OBJ.obj GUN_OBJ.mtl textures
There are 2 actors
data output 0 with material named blinn1SG texture file none diffuse color (0, 0, 0) ambient color (0, 0, 0) specular color (0, 0, 0) specular power 18 opacity 1
data output 1 with material named blinn1SG texture file none diffuse color (0, 0, 0) ambient color (0, 0, 0) specular color (0, 0, 0) specular power 18 opacity 1

and the rendered result does not display the GUN_OBJ.obj model with the TGA images located in the textures folder.

The current rendered result

Screenshot from 2024-12-11 01-38-07

The correct rendered result

dg

Any idea? Thanks

@mwestphal
Copy link
Contributor

Can you open a VTK MR with your branch ? It will be easier to discuss there.

In any case, does the code enter the if (bIsReadableTGA) ?

@gapry
Copy link
Author

gapry commented Dec 10, 2024

Just to confirm: does MR mean Merge requests ? If yes, I can do it.

@mwestphal
Copy link
Contributor

Yes, a MR means a Merge Request

@gapry
Copy link
Author

gapry commented Dec 10, 2024

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.

2 participants