User:Erythros

From Valve Developer Community
Jump to: navigation, search
A member of
Spigot 37
Spigot logo.png
Joined Jan 2008
Status Active
Position Models/Textures
Links
Spigot 37

All info will pertain to Portal. The majority of the models or materials I have worked on were not created by me. I have merely decompiled and edited as needed.


Models

In my efforts to re-skin or re-model pre-existing Portal models I have learned a few things.

Decompiling

I use Cannonfodder's MDL decompiler on all of the models I work with. I have had several models cause the decompiler to crash. Upon closer inspection I found that the error seems to be with how the decompiler handled the headers of some Portal MDL files. By comparing MDLs that successfully decompiled against ones that failed, using a text editor, I noticed that the first 4 characters where consistent throughout all the models, and the first 5 where consistent in the models that decompiled. My theory is that the decompiler expects the first five characters to be a set standard, and when they deviate it errors out. I tested this by opening one of the offending MDLs in a hex editor and changing the 5th character to reflect what I thought the decompiler expected. After saving the result I ran the MDL through the decompiler without further problems. I have successfully used this method on multiple models that have otherwise failed to decompile.


The header should read:

49 44 53 54 2C

Which if read in a text editor displays as:

IDST,


Once the model has been decompiled you can sift through the files and edit as needed. I'll only discuss the three types I've edited.

  • The .qc file
    • typically mdldecompile.qc
  • The reference .smd file
    • typically *.reference.smd
  • And the physics .smd file
    • typically phymodel.smd


Editing

XSI is free so I use it to modify models. A quick read through the .qc file should tell you what materials the model uses and where to find them. In most cases I have found this file to be fairly straight forward. If you are going to edit the model you can open the reference SMD file in a text editor, and use the 'Search and Replace All' function, to update the current image's extension of .bmp to .tga. (This seems like a good option to add to the compiler). As long as you export the .tga from it's .vtf you'll be able to import your material at the same time as the model.


Once the model and textures are imported you can edit as needed. I haven't edited a model's UV mapping yet, but looking at it, via 'Alt 7', shows the UV map to be lower than the imported texture. Every model I have recompiled, with one exception, displays its texture correctly, without having touched the UV map, and I have yet to experiment with re-aligning the UV map.


I've noticed that if I import a model (reference or physics) into XSI and export it right away without making any changes, when recompiled and viewed in the HLMV or Hammer, the model is rotated 90° on the y axis. This does not seem to occur when using Milkshape, however, this is simple to correct and does not cause any other problems. When the model is rotated to the correct degree it can be compiled and viewed correctly. The materials assigned to it seem to be unaffected.


If the phymodel.smd is more complex then a square you'll need to go into the property editor and under the model select Geometry Approximation options, select the Polygon Mesh tab and then adjust the angle under Discontinuity Angle. I have had good results by simply un-checking the Auto box.


Materials

Alpha Channel

Layer Mask