Wing Blender (WCP/SO Blender plugin)

Discussion in 'Fan Projects & Editing' started by Kevin Caccamo, Feb 13, 2010.

  1. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    [​IMG]
    I've created an import/export script for Blender (v2.65+) that can import and export VISION engine IFF 3D models. You can get it on GitHub here: https://github.com/Talon1024/WCPBlenderExporter

    Most models from WC:SO mods are supported, as well as some models from the original game.
    Installation guides and tutorials are available on GitHub.

    Old post:
     
    Last edited: Jan 22, 2017
  2. ChrisReid

    ChrisReid Super Soaker Collector / Administrator

    Messages:
    13,616
    Likes Received:
    375
    Trophy Points:
    69,485
    Location:
    Seattle, Washington, USA
    Cool. On a tangent, is there a reason why people use exotic file packers? It seems like most files that come our way are rars, 7zips, zipz and so on, and so I have a battery of different programs to unpack everything. And then I uncompress these things and repackage them as plain zips to save everything else from having to do it, since modern computers have plain .zip compatibility built in these days. I hear reasons like how one format or another is 5-10% more efficient at compression, but most of these files are small (this one is only 11 kilobytes). Not trying to pick on this particular project, but I'm thinking that some curious people are just passing stuff over because they don't want to hassle with another file format.
     
  3. JasonRocZ

    JasonRocZ Rear Admiral

    Messages:
    1,349
    Likes Received:
    4
    Trophy Points:
    23,635
    Gender:
    Male
    Location:
    Albany NY
    Chris is right....I've found sometimes I do pass things over (Unless I really need to use it)... when it comes to certain compression styles...Although I do use 7zip for everything...you can compress .ZIP format with 7zip instead of the norm .7z or whatevers
     
  4. Wedge009

    Wedge009 Rogue Leader

    Messages:
    10,096
    Likes Received:
    42
    Trophy Points:
    69,385
    Gender:
    Male
    Location:
    Sydney, Australia
    7-Zip is fairly well known and supported now, and I use it all the time, personally. I use it to bypass e-mail servers that would otherwise strip legitimate EXEs from ZIPs when sending stuff at work, sometimes. Stupid false positives. Too, not everyone in the world has unlimited Internet transfer, so smaller files are always welcome for me.

    That being said, I still use ZIPs for small stuff, for the compatibility factor. RARs are proprietary and old-school. :) Anything besides those three formats, I would call esoteric.

    Even with the 7z format, I will usually use the self-extracting EXE option for the benefit of people who don't yet use 7-Zip - even with the added decompression code, things are often far, far smaller than the corresponding ZIP package.
     
  5. ChrisReid

    ChrisReid Super Soaker Collector / Administrator

    Messages:
    13,616
    Likes Received:
    375
    Trophy Points:
    69,485
    Location:
    Seattle, Washington, USA
    I jump between a number of different computers pretty regularly. For CIC updates these days, it's actually more likely that I'm writing them from a computer at a friend's house, (painstakingly and therefore quite rarely) from my cell phone, or from my work computer at lunch. I've got several zipz/7z/etc file-based updates in the queue right now, but they're on hold because I'm not on a machine where I can check them out. I posted this one yesterday because its technical nature makes it likely that the people who'd use it either have 7zip or would be willing to get it, and because it's a preliminary beta so I wasn't going to mirror it on the CIC server. Mainly because Windows automatically understands zips and I can't install anything else at work, if people posted and sent us normal zips, it'd make what I do easier.
     
  6. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    I made some updates to the program, including cleaning up the code a little bit, using classes in The Java 3D API, and adding some code to calculate face normals.

    The new version can be downloaded here.

    The Java 3D API needs to be installed on your computer before the program can be used.
     
  7. Michelle D

    Michelle D Captain

    Messages:
    190
    Likes Received:
    0
    Trophy Points:
    10,085
    Location:
    Hawaii
    Thanks for all the hard work you did, I hope I can make use of your program.
    Aside from just converting the model, Is there a link to a how-to on getting custom ships into the game?

    I know you posted a limit of 4096, but would you know off hand how many polys the game ships were?

    Do you have examples of imported ships, in obj or something I could use for scale when building the custom ship?

    Thanks :D
     
  8. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    Tutorial

    Before the game can use the model, you'll have to open up the .pas file in WCPPascal and click Compile -> Compile and Build IFF, and then move the iff file to the Secret Ops\mesh folder. It may take a few minutes to compile the model.

    You'll have to convert the textures to MAT format and place them in your Secret Ops\mat folder. Note that MAT files are in 8-bit (indexed) colour. I recommend converting the textures to 255 colours, using dithering, adding in an unused colour, and moving that colour to the first index of the palette (This is to prevent the texture from having unwanted transparent parts after conversion). Then, open up the texture using Texconv.exe and save it as an Origin MAT.

    Depending on what starting MAT number you used, you'll have to name the converted textures according to the starting MAT number. The textures and their corresponding MAT numbers are listed in the <modelname>-info.txt file. As an example:
    Code:
    Texture1.bmp -> 22000.mat
    Texture2.bmp -> 22001.mat
    Texture3.bmp -> 22002.mat
    This tells you that Texture1.bmp should be named 00022000.mat when it is converted, Texture2.bmp should be named 00022001.mat when it is converted, you get the idea.

    To use the model in-game, you'll have to modify one of the existing ship files or create a new ship file to use the new model. You can use WCPPascal to decompile one of the ship files (in the Secret Ops\ships folder.) The mesh name that the ship file refers to is under this part of the ship file code:
    Code:
    CHUNK "BASE"
    {
      cstring "panther"
    }
    "panther" can simply be replaced with the filename of the new model (without extension)

    At the bottom of the model source code, there are the hardpoints. The hardpoint positions are proportional to the model in 3D units, so if you want to change the hardpoints, you can place the hardpoints in your 3D program and then hand-copy the position to the hardpoint section in the model's "source code."

    The thruster positions are in the ship file under CHUNK "CONS". Like the hardpoints, the thruster cone positions are proportional to the model in 3D units.

    The default hardpoints (that OBJ2WCP uses) may not fit the model you are trying to convert, so I think you might want to play around with the hardpoints a little bit.

    Most of the game models were (IIRC) lower than 800 polys. The base mesh of the superbase is about 1600 polys. I wouldn't recommend going any higher than that, since I once tried to import a 2000-poly model and the game crashed.

    About scale, a good size for fighters would be around 18 3D units. Killerwave's site also has this:
    I do have an OBJ which I have converted before. Here it is.

    If anyone else has any suggestions about generating the hardpoints, I'd like to hear them.
     
  9. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    Update: Objects converted by OBJ2WCP now render properly in-game! I've finally been able to fix the problem which causes faces to mysteriously disappear.

    Download the updated version here.

    EDIT: The disappearing faces problem is still there, but it's a lot less noticeable. Here's a screenshot of my WCUE mod, featuring a Scimitar cockpit converted by OBJ2WCP.
    [​IMG]
     
  10. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    Update 23/12/2010

    I'm trying a bunch of different algorithms to calculate the unknown1 value. Let's see if this one doesn't totally eliminate the disappearing faces problem.

    http://www.ciinet.org/kevin/java/obj2wcp.zip
     
  11. gr1mre4per

    gr1mre4per Rear Admiral

    Messages:
    186
    Likes Received:
    61
    Trophy Points:
    22,285
    Gender:
    Male
    Location:
    Evesham, UK
    Hi Kevin,

    The unknown1 value is a D-Plane equation. This is what you need:

    Assume V is the first FVRT->VERT value called by FACE.
    Assume N is the Surface Normal called by FACE.

    D-Plane = -((N.i * V.x) + (N.j * V.y) + (N.k * V.z))

    I'm not sure, but I think the Unknown2 value could be something to do with weapon/engine brightness effect, but I'm still looking at that.

    Hope this helps :)

    -Grim
     
  12. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    Thanks a lot, gr1mre4per! I'll try to implement this and release a new version ASAP.

    The unknown2 value, AFAIK, is a true/false flag that tells the engine whether to make the face fully lit or to give the face regular shading. See Eder's post here for more info.

    EDIT: OBJ2WCP 1.2 Released!
     
  13. gr1mre4per

    gr1mre4per Rear Admiral

    Messages:
    186
    Likes Received:
    61
    Trophy Points:
    22,285
    Gender:
    Male
    Location:
    Evesham, UK
    No problem at all :)

    I've decided to teach myself C++. I'm actually in the process of making a converter of my own as my first C++ project. I did quite some investigation in to the mesh files. The D-Plane was probably the most awkward one to work out. Fortunately I had some help from the partial source code on the dev backup images to point me in the right direction.

    The unknown2 value is definately not a true/false flag. I have done some investigation today and found this:

    Bug "Green Globe" weapon polys had it set to 3
    Bug Engine polys had it set to 2
    Midway Engine was set to 10
    Midway Engine surrounding polys had it set to 8. (i guess to mimic light reflection from engine)

    I have also seen higher values in the medium and low poly versions for each mesh, I assume to make it stand out more in the distance.

    It could be just a brightness value, but I think values 2 and 3 are special to bug engines and weapons. Bug weapons textures go dim when weapons are fired and engines change brightness dependant on speed.

    I'll keep looking and let you know :)
     
  14. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    So, I was originally thinking of making a new version of OBJ2WCP that works like PCS2, in that you load a model and rig it for the game, but now I'm thinking of making OBJ2WCP into an exporter script for Blender. It'll mean less work done in OBJ2WCP and more work done in Blender.

    I'm trying to learn Python right now, and I've got a good head start on a .pas exporter.
    Edit: I do plan to make it export .IFF files eventually. .pas is being used as an "in-between" format because it's easier to debug the script with test data in plain text format.
     
  15. FekLeyrTarg

    FekLeyrTarg Commodore

    Messages:
    541
    Likes Received:
    62
    Trophy Points:
    14,635
    Sounds good.
    For which Blender versions will your script be developed?
     
  16. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    I'm developing the script for Blender 2.65+ in mind.
     
  17. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    I got my first test model for the exporter script working ingame!
    [​IMG][​IMG][​IMG][​IMG][​IMG]
    But there's still a lot of work to do, including support for models with multiple textures, support for fully lit faces, support for IFF format export, and optimizations such as deleting duplicate normals.

    The script will be released before I begin working on IFF export.
     
  18. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    The exporter script for Blender has been released! You can download it here.
     
  19. Lt.Overload

    Lt.Overload Rear Admiral

    Messages:
    668
    Likes Received:
    20
    Trophy Points:
    27,435
    Gender:
    Male
    Location:
    United States of America
    Do you have some special high-quality Vampire model in your game or something?
     
  20. Kevin Caccamo

    Kevin Caccamo Rear Admiral

    Messages:
    623
    Likes Received:
    35
    Trophy Points:
    26,785
    Gender:
    Male
    Yep, it was an experiment with the old OBJ2WCP using one of Scooby Doo's old models from here.
     
    Last edited by a moderator: May 24, 2018

Share This Page