ValveResourceFormat / ValveResourceFormat

🔬 Valve's Source 2 resource file format parser, decompiler, and exporter.
https://valveresourceformat.github.io
MIT License
1.61k stars 201 forks source link

fix export size/scale correct in gltf format #342

Closed pvp-by closed 3 days ago

pvp-by commented 3 years ago

Describe the bug

big size after export

What Valve game does this happen in

Dota 2

Reference file in a Valve game

*.vmdl_c

Expected behavior

export model original size

What version of VRF are you using? On what platform?

win 0.1.7.1501

i test export and decompile vmdl_c file

step by step:

  1. I create a default cube in blender (smaller and green in the picture)
  2. save it as fbx without changing the size or scale
  3. create a model in dota2 from fbx mesh - compile as vmdl_c
  4. Open this vmdl_c file in VRF
  5. export and decompile as gltf
  6. open it in blender . The result is shown in the picture below (big gray cube)

image

fix in https://github.com/SteamDatabase/ValveResourceFormat/blob/master/ValveResourceFormat/IO/GltfModelExporter.cs#L28

private readonly Matrix4x4 TRANSFORMSOURCETOGLTF = Matrix4x4.CreateScale(0.0254f) * Matrix4x4.CreateFromYawPitchRoll(0, (float)Math.PI / -2f, 0); change : private readonly Matrix4x4 TRANSFORMSOURCETOGLTF = Matrix4x4.CreateScale(0.01f) * Matrix4x4.CreateFromYawPitchRoll(0, (float)Math.PI / -2f, 0);

xPaw commented 3 years ago

Is Source 2 not using the 1 unit = 0.0254 meter conversion? I thought we tested this before.

pvp-by commented 3 years ago

Is Source 2 not using the 1 unit = 0.0254 meter conversion? I thought we tested this before.

I do not really know how to check how and in what counts as a source 2 I only in practice convinced of the incorrectness of the current behavior

xPaw commented 3 years ago

@Perryvw looked at this, and it would appear that the scaling is not consistent depending on what/how you import.

kristiker commented 3 days ago
  1. create a model in dota2 from fbx mesh - compile as vmdl_c

You need to fix the scale in model editor. The cube will be larger than blender cube in game as well.