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

Quake MDL feature #1591

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open

Quake MDL feature #1591

wants to merge 67 commits into from

Conversation

Youva
Copy link

@Youva Youva commented Aug 25, 2024

Adds class vtkQuakeMDLImporter that reads .MDL files.

The class :

  • Reads vertices and triangle data from the format to display a model.
  • Reads a texture and texture coordinates from the format to display onto the model.
  • Reads animations, stored as an array of vertices in the file, and saves them as a vector of polydata.
  • Groups animations and displays them.
  • Adds light sources to the scene.

Fix: #1310

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 97.35849% with 7 lines in your changes missing coverage. Please review.

Project coverage is 95.76%. Comparing base (13e81fa) to head (4bee8b4).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
plugins/native/module/vtkF3DQuakeMDLImporter.cxx 97.33% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1591      +/-   ##
==========================================
+ Coverage   95.72%   95.76%   +0.04%     
==========================================
  Files         128      130       +2     
  Lines       10293    10558     +265     
==========================================
+ Hits         9853    10111     +258     
- Misses        440      447       +7     

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

Copy link
Contributor

@mwestphal mwestphal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes needed

Copy link
Member

@Meakk Meakk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Youva !!
There is still some clean-up to do, especially memory leaks to fix, but they will appear in the CI when you will add a test.
90% of the job is done, and there's the annoying, yet important, finalization left :)

@mwestphal
Copy link
Contributor

@Youva any news on this ?

1 similar comment
@mwestphal
Copy link
Contributor

@Youva any news on this ?

@mwestphal
Copy link
Contributor

Hi @Youva ! Looks like you are back. First you may want to rebase on the latest master :)

Copy link

You are modifying libf3d public API! ⚠️Please update bindings accordingly⚠️!
You can find them in their respective directories: python, java, webassembly.

@mwestphal
Copy link
Contributor

Looks like your merge did not go as expected. I'd strongly suggest using rebase instead of merge. Let me know if I can help (on discord or here).

@Youva Youva force-pushed the quake-mdl-feature branch from 70ec237 to 988186a Compare December 18, 2024 22:51
@mwestphal
Copy link
Contributor

Hi @Youva

Please resolve discussions you have adressed and let us know if this is ready for review.

@Youva Youva force-pushed the quake-mdl-feature branch from 001a692 to 4bee8b4 Compare February 26, 2025 14:23
@mwestphal
Copy link
Contributor

Is this ready for review @Youva ? :)

@Youva
Copy link
Author

Youva commented Mar 1, 2025

I think it's ready for a review.

@mwestphal mwestphal requested review from Meakk and mwestphal March 10, 2025 06:01
@mwestphal
Copy link
Contributor

@malespiaut please review if you can :)

@@ -155,6 +155,7 @@ f3d_test(NAME TestVTM DATA mb.vtm)
f3d_test(NAME TestVTK DATA cow.vtk)
f3d_test(NAME TestNRRD DATA beach.nrrd ARGS -s)
f3d_test(NAME TestSPLAT DATA small.splat ARGS -osy --up=-Y --point-sprites-size=1)
f3d_test(NAME TestQuakeMDL DATA zombie.mdl ARGS --animation-index=0 --animation-autoplay=true --animation-time=0.1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f3d_test(NAME TestQuakeMDL DATA zombie.mdl ARGS --animation-index=0 --animation-autoplay=true --animation-time=0.1)
f3d_test(NAME TestQuakeMDL DATA zombie.mdl ARGS --animation-index=0 --animation-time=0.1)

"match": ".*(mdl)",
"options": {
"up": "+Z",
"animation-index": "-1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So most animated models have multiples animations baked in and all animations should be enabled by default ?

"match": ".*(mdl)",
"options": {
"up": "+Z",
"animation-index": "-1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesnt make much sense for thumbnail to have a animation related option tbh

std::string filename =
std::string(argv[1]) + "data/zombie_2.mdl"; // File was modified to add coverage.
vtkNew<vtkF3DQuakeMDLImporter> importer;
std::cout << filename;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

int TestF3DQuakeMDLImporter(int vtkNotUsed(argc), char* argv[])
{
std::string filename =
std::string(argv[1]) + "data/zombie_2.mdl"; // File was modified to add coverage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally clarify what codepath it covers ?

error ? specific feature ?

int skinWidth, int skinHeight, int nbSkins, int selectedSkinIndex)
{
constexpr int char_size = 1;
constexpr int int_size = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sizeof instead ?

ptr[1] = F3DMDLDefaultColorMap[index][1]; // G
ptr[2] = F3DMDLDefaultColorMap[index][2]; // B
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these for loops looks like they could be replace by std::copy calls

{
constexpr char char_size = 1; // Size of char in file
constexpr int int_size = 4; // Size of int in file
constexpr int float_size = 4; // Size of float in file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sizeof ?

animationId++;
frameName = meshName;
this->NumberOfAnimations++;
this->AnimationNames.emplace_back(meshName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to cover this code ?

//----------------------------------------------------------------------------
void UpdateTimeStep(double timeValue)
{
int frameIndex = static_cast<int>(floor(FrameRate * abs(timeValue))) %
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int frameIndex = static_cast<int>(floor(FrameRate * abs(timeValue))) %
int frameIndex = static_cast<int>(std::floor(FrameRate * std::abs(timeValue))) %

std::string Description;
vtkSmartPointer<vtkPolyDataMapper> Mapper;
std::vector<vtkSmartPointer<vtkPolyData>> Mesh;
std::vector<std::pair<int, float>> AnimationIds;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::map<int, float> instead ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the float represent here ?

std::vector<std::string> AnimationNames;
std::vector<int> ActiveFrames;
std::vector<int> ActiveAnimationIds;
int NumberOfAnimations = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed ? its basically the size of AnimationsIds ?

bool vtkF3DQuakeMDLImporter::GetTemporalInformation(vtkIdType animationIndex, double frameRate,
int& nbTimeSteps, double timeRange[2], vtkDoubleArray* vtkNotUsed(timeSteps))
{
this->Internals->SetFrameRate(frameRate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F3D doesnt realy care about framerate and will only use UpdateTimeStep with an actual time in seconds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Quake MDL only defines frames without an associated time ?

///@}

/**
* Get temporal information for the currently enabled animation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Get temporal information for the currently enabled animation.
* Get temporal information for the currently enabled animations.

Copy link
Contributor

@mwestphal mwestphal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and remarks. Feel free to reach out if tou have questions about animations :)

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.

Add support of Quake 1 MDL files.
4 participants