f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Add support of Quake 1 MDL files.

Open malespiaut opened this issue 11 months ago • 17 comments

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.

malespiaut avatar Mar 12 '24 11:03 malespiaut

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

mwestphal avatar Mar 12 '24 11:03 mwestphal

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?

Meakk avatar Mar 12 '24 11:03 Meakk

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!

malespiaut avatar Mar 12 '24 14:03 malespiaut

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.

malespiaut avatar Mar 12 '24 14:03 malespiaut

Can you open a PR with the changes ? it would help us identify the issue.

mwestphal avatar Mar 12 '24 15:03 mwestphal

How do you run F3D in that case ? could you share the output and the errors ? Run with --verbose :)

mwestphal avatar Mar 12 '24 15:03 mwestphal

Hey @malespiaut , need any help with that ? Please open a PR so we can help :)

mwestphal avatar Mar 22 '24 07:03 mwestphal

After a quick investigation by @malespiaut , it looks like assimp will not cut it. We need a dedicated implementation.

mwestphal avatar Mar 31 '24 07:03 mwestphal

@malespiaut any news on that front ? :)

mwestphal avatar Apr 21 '24 14:04 mwestphal

hey @malespiaut , any news on that issue ?

mwestphal avatar May 26 '24 17:05 mwestphal

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?

malespiaut avatar May 27 '24 08:05 malespiaut

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.

Meakk avatar May 27 '24 10:05 Meakk

hey @malespiaut , what is the status of this ?

mwestphal avatar Jul 13 '24 16:07 mwestphal

With no feedback from @malespiaut , I'm remove the assignee

mwestphal avatar Aug 10 '24 13:08 mwestphal

Hello, I will look into this issue.

Youva avatar Aug 10 '24 20:08 Youva