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

Add support of Quake 1 MDL files. #1310

Open
malespiaut opened this issue Mar 12, 2024 · 12 comments
Open

Add support of Quake 1 MDL files. #1310

malespiaut opened this issue Mar 12, 2024 · 12 comments
Assignees
Labels
good first issue Good for newcomers type:enhancement New feature or request
Milestone

Comments

@malespiaut
Copy link

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.

@mwestphal
Copy link
Contributor

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

@Meakk
Copy link
Contributor

Meakk commented Mar 12, 2024

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:

f3d_plugin_declare_reader(

Can you try and tell us if it works fine with your files?

@malespiaut
Copy link
Author

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:

f3d_plugin_declare_reader(

Can you try and tell us if it works fine with your files?

I'll try that right away and tell you that!

@malespiaut
Copy link
Author

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.

@mwestphal
Copy link
Contributor

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

@mwestphal
Copy link
Contributor

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

@mwestphal
Copy link
Contributor

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

@mwestphal mwestphal added type:enhancement New feature or request good first issue Good for newcomers labels Mar 22, 2024
@mwestphal mwestphal added this to the 2.4.0 milestone Mar 22, 2024
@mwestphal
Copy link
Contributor

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

@mwestphal mwestphal modified the milestones: 2.4.0, 2.5.0 Apr 4, 2024
@mwestphal
Copy link
Contributor

@malespiaut any news on that front ? :)

@mwestphal
Copy link
Contributor

hey @malespiaut , any news on that issue ?

@malespiaut
Copy link
Author

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?

@Meakk
Copy link
Contributor

Meakk commented May 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type:enhancement New feature or request
Projects
Status: Investigate
Development

No branches or pull requests

3 participants