-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
base: master
Are you sure you want to change the base?
Quake MDL feature #1591
Conversation
…es. Fixed texture coordinates not rendering correctly by adding more vertices. Fixed camera position and lighting, animations display properly but could still be improved.
Adds support for the .mdl format.
Fixed incorrect type at line 452.
Changed some int variables to size_t.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1591 +/- ##
==========================================
- Coverage 96.82% 93.58% -3.24%
==========================================
Files 108 110 +2
Lines 7643 7938 +295
==========================================
+ Hits 7400 7429 +29
- Misses 243 509 +266 ☔ View full report in Codecov by Sentry. |
#include <vtkNew.h> | ||
#include <vtkPolyDataAlgorithm.h> | ||
#include <vtkVersion.h> | ||
|
||
#include <memory> | ||
|
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.
no need to move this
-#include <memory> | ||
|
||
class vtkF3DAlembicReader : public vtkPolyDataAlgorithm | ||
{ |
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.
you can remove this file
- | ||
} | ||
|
||
//---------------------------------------------------------------------------- |
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.
you can remove this file
f3d_plugin_declare_reader( | ||
NAME QuakeMDL | ||
EXTENSIONS mdl | ||
MIMETYPES application/vnd.mdl |
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.
do you have a small .mdl file with a creative commons license ?
- | ||
} | ||
|
||
//---------------------------------------------------------------------------- |
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.
you can remove this file
|
||
renderer->AddLight(frontLight); | ||
renderer->AddLight(leftLight); | ||
renderer->AddLight(backLight); |
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.
any specific reason for adding lights ?
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.
same question, I don't think it's needed.
{ -0.850651f, 0.000000f, -0.525731f }, { -0.688191f, 0.587785f, -0.425325f }, | ||
{ -0.587785f, 0.425325f, -0.688191f }, { -0.425325f, 0.688191f, -0.587785f }, | ||
{ -0.425325f, -0.688191f, -0.587785f }, { -0.587785f, -0.425325f, -0.688191f }, | ||
{ -0.688191f, -0.587785f, -0.425325f } }; |
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.
what are those big number lists ?
//---------------------------------------------------------------------------- | ||
std::string vtkQuakeMDLImporter::GetAnimationName(vtkIdType animationIndex) | ||
{ | ||
return std::to_string(animationIndex); |
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.
animation are not named ?
//---------------------------------------------------------------------------- | ||
void vtkQuakeMDLImporter::DisableAnimation(vtkIdType vtkNotUsed(animationIndex)) | ||
{ | ||
return; |
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.
missing an implementation
} | ||
|
||
// Only one animation enabled at a time | ||
void EnableAnimation(vtkIdType animationIndex) |
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.
only one animation can be enabled at a time ?
{ | ||
this->Superclass::PrintSelf(os, indent); | ||
os << indent << "FileName: " << this->FileName << "\n"; | ||
} |
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.
you can remove PrintSelf method imo
* Set/Get the file name. | ||
*/ | ||
vtkSetMacro(FileName, std::string); | ||
vtkGetMacro(FileName, std::string); |
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.
you can remove this method
///@{ | ||
/** | ||
* Enable/Disable/Get the status of specific animations | ||
* Only one single animation can be enabled |
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.
this is a limitation of the assimp importer, but can it be implemented correctly here ?
* Set/Get collada fixup flag. | ||
*/ | ||
vtkSetMacro(ColladaFixup, bool); | ||
vtkGetMacro(ColladaFixup, bool); |
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.
you can remove this
roll->RotateX(270); | ||
roll->RotateZ(270); | ||
renderer->GetActiveCamera()->SetPosition(cameraPosition); | ||
renderer->GetActiveCamera()->SetModelTransformMatrix(roll->GetMatrix()); |
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.
why adding a camera ?
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.
Probably to correct the actor orientation. Are MDL files +Z up by default? Then you just need to specify it in the config files (improvements of config file is missing by the way).
- | ||
|
||
void PrintSelf(ostream& os, vtkIndent indent) override; | ||
|
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.
you can remove this file
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.
changes needed
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.
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 :)
roll->RotateX(270); | ||
roll->RotateZ(270); | ||
renderer->GetActiveCamera()->SetPosition(cameraPosition); | ||
renderer->GetActiveCamera()->SetModelTransformMatrix(roll->GetMatrix()); |
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.
Probably to correct the actor orientation. Are MDL files +Z up by default? Then you just need to specify it in the config files (improvements of config file is missing by the way).
|
||
renderer->AddLight(frontLight); | ||
renderer->AddLight(leftLight); | ||
renderer->AddLight(backLight); |
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.
same question, I don't think it's needed.
} | ||
|
||
//---------------------------------------------------------------------------- | ||
vtkSmartPointer<vtkTexture> CreateTexture(std::vector<unsigned char> buffer, int& offset, |
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.
Avoid a copy
vtkSmartPointer<vtkTexture> CreateTexture(std::vector<unsigned char> buffer, int& offset, | |
vtkSmartPointer<vtkTexture> CreateTexture(const std::vector<unsigned char>& buffer, int& offset, |
int group; | ||
unsigned char* skin; | ||
}; | ||
mixed_pointer_array* skins = new mixed_pointer_array[nbSkins]; |
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.
not deleted. But let's use a std::vector
instead.
return texture; | ||
} | ||
|
||
void CreateMesh(std::vector<unsigned char> buffer, int offset, mdl_header_t* header) |
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.
void CreateMesh(std::vector<unsigned char> buffer, int offset, mdl_header_t* header) | |
void CreateMesh(const std::vector<unsigned char>& buffer, int offset, mdl_header_t* header) |
std::pair<int, float> pair = std::make_pair(frameIndex, 0.0); | ||
GroupAndTimeVal.emplace_back(pair); |
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.
Can be simplified to
std::pair<int, float> pair = std::make_pair(frameIndex, 0.0); | |
GroupAndTimeVal.emplace_back(pair); | |
GroupAndTimeVal.emplace_back({ frameIndex, 0.0 }); |
{ | ||
for (int i = 0; i < header->numTriangles; i++) | ||
{ | ||
vtkIdType* vertexNum = new vtkIdType[3]; |
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.
memory leak? Why not using that?
vtkIdType* vertexNum = new vtkIdType[3]; | |
vtkIdType vertexNum[3]; |
{ | ||
double* v_0 = Mesh[i]->GetPoint(j); | ||
double* v_1 = Mesh[i + 1]->GetPoint(j); | ||
double* interp = new double[3]; |
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.
leak again
double* interp = new double[3]; | |
double interp[3]; |
|
||
void UpdateFrame(double timeValue) | ||
{ | ||
// Hardcoded frames per second, 60FPS |
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.
Is it always 60fps in the MDL specifications?
void ImportLights(vtkRenderer*) override; | ||
|
||
// Header definition, | ||
struct mdl_header_t |
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.
can be moved to the cpp file in the internals
@Youva any news on this ? |
Adds class vtkQuakeMDLImporter that reads .MDL files.
The class :