f3d
f3d copied to clipboard
Add support of Quake 1 MDL files.
Is your feature request related to a problem? Please describe. I would like to open Quake 1 MDL files with F3D, because it would be much simpler than importing the models in Blender, just to view them.
Describe the solution you'd like Support of Quake 1 MDL files in F3D.
Describe alternatives you've considered As of today, this simplest solution is to import the MDL in Blender. It's not difficult, but it take unnecessary time for a simple task. It's also possible to use assimp to convert MDL to another format that F3D supports.
Additional context n/a
Contribution I'm a C developper. I would be happy to contribute this feature myself, but I know nothing about 3D programming, and very little about C++ programming.
http://tfc.duke.free.fr/coding/mdl-specs-en.html
Looks like a pretty simple and open format.
If youd like to contribute, I suggest joining our discord, we will assist you with the contribution:)
https://discord.f3d.app
Note that Assimp is supporting MDL files: https://github.com/assimp/assimp/blob/master/doc/Fileformats.md
It should be fairly easy to enable it in F3D. We just need to add the declaration here: https://github.com/f3d-app/f3d/blob/f0ecafb56b93888427e5f84e9ca4b917db85e722/plugins/assimp/CMakeLists.txt#L69
Can you try and tell us if it works fine with your files?
http://tfc.duke.free.fr/coding/mdl-specs-en.html
Looks like a pretty simple and open format.
If youd like to contribute, I suggest joining our discord, we will assist you with the contribution:)
https://discord.f3d.app
Thank you for the Discord link. I'll join the discussion here.
Note that Assimp is supporting MDL files: https://github.com/assimp/assimp/blob/master/doc/Fileformats.md It should be fairly easy to enable it in F3D. We just need to add the declaration here:
https://github.com/f3d-app/f3d/blob/f0ecafb56b93888427e5f84e9ca4b917db85e722/plugins/assimp/CMakeLists.txt#L69
Can you try and tell us if it works fine with your files?
I'll try that right away and tell you that!
I have tried adding the following into f3d/plugins/assimp/CMakeLists.txt
but, while it compiles successfully, it doesn't make F3D recognize MDL files.
f3d_plugin_declare_reader(
NAME MDL
EXTENSIONS mdl
MIMETYPES model/mdl
VTK_IMPORTER vtkF3DAssimpImporter
FORMAT_DESCRIPTION "Quake Mesh Format"
)
I may be missing a trivial step that I'm not aware of.
Can you open a PR with the changes ? it would help us identify the issue.
How do you run F3D in that case ? could you share the output and the errors ? Run with --verbose
:)
Hey @malespiaut , need any help with that ? Please open a PR so we can help :)
After a quick investigation by @malespiaut , it looks like assimp will not cut it. We need a dedicated implementation.
@malespiaut any news on that front ? :)
hey @malespiaut , any news on that issue ?
Hello @mwestphal
Yes, I've copied plugins/native/module/vtkF3DSplatReader.cxx
to plugins/native/module/vtkQuakeMDLReader.cxx
and started to modify it; but I don't get how the code is structured to read the header of a file.
A Quake1 MDL header look as follows:
// identity ("IDPO"): 4 chars (4 bytes)
// version: 1 int (4 bytes)
//
// scaling factor: 3 floats (12 bytes)
// translation vector: 3 floats (12 bytes)
// bounding radius: 1 float (4 bytes)
// eye position: 3 floats (12 bytes)
//
// number of textures: 1 int (4 bytes)
// texture width: 1 int (4 bytes)
// texture height: 1 int (4 bytes)
//
// number of vertices: 1 int (4 bytes)
// number of triangles: 1 int (4 bytes)
// number of frames: 1 int (4 bytes)
//
// sync type (0: synchron, 1: random): 1 int (4 bytes)
// state flags: 1 int (4 bytes)
// position: 3 floats (12 bytes)
// scale: 3 floats (12 bytes)
// rotation: 4 chars (4 bytes)
// color+opacity: 4 chars (4 bytes)
I'm sure it's dead simple, but I'm a C developper, and I'm quite new to the C++ synthax. I understand that you are using a C++ template to make arrays? Vectors?
Let's communicate on the PR, I'll help you there. You can just use the C code for now if you're more familiar with it and we'll move that to C++ later.
hey @malespiaut , what is the status of this ?
With no feedback from @malespiaut , I'm remove the assignee
Hello, I will look into this issue.