Author Topic: First CVR mod!  (Read 5843 times)

0 Members and 1 Guest are viewing this topic.

Offline Ford_Prefect

First CVR mod!
« on: February 06, 2014, 04:02:33 AM »
  • Publish
  • Update: !  2014-03-16    See original post bellow.
    Link to the download file: http://alphacentauri2.info/index.php?action=downloads;sa=view;down=158




    -------------- Original post------------------

    I've had a breakthrough in deciphering the CVR file format.  ;zak;

    What I've figured out: (Updated list on 2014-02-26)
    • Where the parts are located
    • Part Names
    • Object name
    • Locations - Somewhat
    • Palette codes 02/26
    • Number of animation frames 2/26
    • Number of parts 2/26
    • How the voxels are placed in the engine  :D
    • File version number
    I haven't figured out (yet):
    • How to assemble the skeleton
    • Animation
    • Absolute Locations - Somewhat
    • Normals


    Ok. Here is the nitty gritty details of what has gotten me so excited.  :D
    Example hex dump from parts section:
    Code: [Select]
    6F D2 95 6F D2 95 6F D1 95 6F D1 95 6F D1 95
    6F D1 95 6F D1 95 6F D0 95 6F D0 95 6F 76 95
    6F 75 95 6F 1C 95 6F 1C 95 B6 C3 95 6E C2 95
    5E C2 95 7E 69 95 B5 B6 95 15 5D 95 B4 AC 95
    B4 AC 95 6C AB 95 ......

    See that 95? That is the color that the voxel will use.
    That was easy part.

    Ok.  The part that was driving me nuts:  Position:  How was it calculated for each voxel?  First I thought it was an z, y with x being incremented every once and a while... but I was wrong.... So I got to toying with the numbers and ......

    byte1 byte2 byte3  If I lay the data out like this.... with byte 3 being the color code.
    60      D2     95

    Lets look closer at byte 1 shall we?
    x60 = 01100000
    01100   000       
    |-----| < this part, the first 5 bits, when it changes, changes the direction the next voxel will be located.  With 22 possible vectors.  (WARNING: Using a value larger than 11001 will cause access violations or crashes with the model viewer)

    Yes, each voxel is a set distance from the last, with the first 5 bits of data telling which direction (in 45 degree increments) to go.

    The 3 bits + byte 2 is something else.  Figuring out what they are used for is on my todo list.  :)

    « Last Edit: January 06, 2015, 02:56:59 PM by sisko »

    Offline Dio

    Re: CVR... I've had a major breakthrough today.
    « Reply #1 on: February 06, 2014, 07:00:28 PM »
  • Publish
  • First, your post was very insightful and I hope you are successful in deciphering the caviar file format for this game.

    If you are interested, this is how the cvr files are actually used inside  the game code. The method they used to create the multipart chassises in the game was to assemble them in a single procedure that had the skeleton of the chassis in one procedure and from there they would add other pieces like armor and weapons. In addition, they added a memory address and call function to some of the caviar pieces that had an animation associated with them.

    Offline Ford_Prefect

    Re: CVR... I've had a major breakthrough today.
    « Reply #2 on: February 10, 2014, 02:03:27 AM »
  • Publish
  • I've learned how single part objects store their coordinates.   ;excite;

    The general layout:
    zz zz xx xx yy yy E8 FF C7 FF EB FF 31 00 74 00 2B 00 zz zz xx xx yy yy E5 12 00 00 00 00 00 00
                             |---? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? -------|                          |--Voxels---|
    The voxel number is the number of voxels to the next jump.
    zz, xx, yy are signed shorts.

    I'm probably missing something with the coordinates as both sets have different numbers, but modifying them seemed to have the same results.

    Also, multipart pieces have a different data structure so I'm gonna have to do some more work for figuring out their layout. 

    I'm gonna take a break from looking at the hex files for a bit and try writing an exporter for single pieces.  After that I'll try to pin down where the data stores the center-point (I'll be able to do some trial and error with my own file viewer) and then start work on multi-part files.


    « Last Edit: February 12, 2014, 03:05:32 AM by Ford_Prefect »

    Offline Ford_Prefect

    Re: CVR Progress
    « Reply #3 on: February 12, 2014, 03:04:01 AM »
  • Publish
  • (click to show/hide)

    My first attempt at importing the data.  :D

    I haven't programmed in the color, so I set it to random.
    I need to get lighting to work properly in the viewer.  Learning how to program in this 3d engine will be interesting.
    « Last Edit: February 26, 2014, 10:02:58 PM by Ford_Prefect »

    Online BUncle

    • Through kittehz, I
    • Transcend
    • *
    • Posts: 42297
    • €457
    • View Inventory
    • Send /Gift
    • Someone thinks a Winrar is You!  Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  
    • AC2 is my instrument, my heart, as I play my song.
    • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
      • View Profile
      • My Custom Factions
      • Awards
    Re: CVR Progress - Now with images!
    « Reply #4 on: February 12, 2014, 04:28:12 AM »
  • Publish
  •  ;excite;

    Offline Ford_Prefect

    Re: CVR Progress - Now with images!
    « Reply #5 on: February 13, 2014, 08:57:47 PM »
  • Publish


  • Status Update:

    I've got my first cvr to convert and display!  I did try loading in some other pieces... but some of them failed halfway through the conversion.  So I guess one of my assumptions was wrong. Gonna have to take a look.

    In other news.... Looking at the performance of just plopping in cubes for each voxel seems to give really bad performance.  So I'm gonna need a better method of rendering the data.  I mean seriously, the original CVR viewer is rendering the same data at 2000 fps!  If anyone has some suggestions, I'd be happy to hear them as I'm a complete noob when it comes to working with 3d graphics.

    Offline Ford_Prefect

    Re: CVR Progress - Now with images!
    « Reply #6 on: February 14, 2014, 12:58:46 AM »
  • Publish


  • Woohooo!  Can now load more one part models!  Both the ship and the missle now load.

    Downside is that these high voxel count models really drive home the fact I need to come up with a better method of rendering them.

    Offline Ford_Prefect

    Re: CVR Progress - Now with images!
    « Reply #7 on: February 14, 2014, 04:12:34 AM »
  • Publish
  • Good news, Bad news.
    Good news - I've changed the way the engine renders the files and it can now handle them.  I've also got it loading the colors.

    Bad news - the palate color codes from the palate file are not the same as the color codes in the CVR file.   Which means I'm gonna have to reverse engineer the palette location.   :mad:

    TODO to get models into another game engine:
    • Find the color pallet location - critical for pieces having the right color
    • Normals - Probably will take quite a while if I manually change values slowly in a cvr file and noting the normals direction, because it will be hard telling which way the normal is pointed. 
    • Positions - apparently some single-part locations are failing.  Gonna have to figure out why.

    TODO:  To make it easier to get into another game engine
    • Figure out how multi-part/animated models are rigged - I might take a stab at figuring this out.  If worse, comes to worse, one can always manually place the individual pieces
    • Animation - No.  Someone else can spend the time figuring this out.  If you do, post your discoveries! 
    « Last Edit: February 14, 2014, 09:55:21 PM by Ford_Prefect »

    Offline Ford_Prefect

    Update
    « Reply #8 on: February 26, 2014, 07:11:34 PM »
  • Publish
  • I'm back!

    I've been playing dungeon keeper 2 in my free time... which is why you guys haven't heard from me in a while. :-D

    So, I spent half a day trying to pin down why the positional data appears and disapears in this one part.... and I haven't figured it out yet, but I did pin down some other data.

    New stuff I can read:
    • Number of frames
    • Number of parts - Somewhat useful, as I had found a workaround, but this will probably make it less glitchy.
    • Center of rotation - will probably be useful in the future
    • Another positional data set? - Not sure need to dink around with the number more to make sure
    • Where the palate is located, but haven't figure out how colors are numbered yet

    I also know where the value for units per 3d voxel is stored.  I don't know how to read it yet.

    What's next?
    I'll probably try to read in the new data, and try to get both non-animated files to convert properly.  Sadly, I think I already figured out all the easy stuff.  I think all that's left is manually changing values or formulas and seeing what changes, which is slow.  I'll probably make some changes to my renderer so that I don't have to open and close it to view different models.
    « Last Edit: February 26, 2014, 07:28:22 PM by Ford_Prefect »

    Online BUncle

    • Through kittehz, I
    • Transcend
    • *
    • Posts: 42297
    • €457
    • View Inventory
    • Send /Gift
    • Someone thinks a Winrar is You!  Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  
    • AC2 is my instrument, my heart, as I play my song.
    • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
      • View Profile
      • My Custom Factions
      • Awards
    Re: CVR Progress - Now with images!
    « Reply #9 on: February 26, 2014, 07:23:11 PM »
  • Publish
  • If this ultimately results in a .cvr editor so art modders could, for example, make appropriate-looking units for a Middle Earth mod --- the SMACX modding world will be laid at your feet.  I can't do a lot to sweeten the deal for you, but there's definitely a .cvr King badge for your postbit in it.  And the community would respect and owe you.

    Offline Geo

    Re: CVR Progress - Now with images!
    « Reply #10 on: February 26, 2014, 08:15:42 PM »
  • Publish

  • Online BUncle

    • Through kittehz, I
    • Transcend
    • *
    • Posts: 42297
    • €457
    • View Inventory
    • Send /Gift
    • Someone thinks a Winrar is You!  Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  
    • AC2 is my instrument, my heart, as I play my song.
    • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
      • View Profile
      • My Custom Factions
      • Awards
    Re: CVR Progress - Now with images!
    « Reply #11 on: February 26, 2014, 08:26:31 PM »
  • Publish
  • ;b;

    Offline Ford_Prefect

    CVR Editor?
    « Reply #12 on: February 26, 2014, 10:02:30 PM »
  • Publish
  • Picture of my work with ACP00.cvr



    Spent some more time on it and I think I've figured out how to grab the color palate.   :D
    I'm also making progress on the positional data.  The main issue currently is that I think its supposed to have a different rotation location.  This is the simplist of the cvr files in alpha centari.  It was converted from a single mesh.  Infuriating me is the fact that this stores its location data differently than every other single part (but converted from multiple meshes) files.  So... I have to figure out how to detect this anomoly, or just stick in an exception for the ACP0# files.

    Quote
    .cvr editor

      Ok.  A .cvr editor... I wasn't originally planning on writing one.... but....
    With what I know currently, I or someone else could write a "texture" editor for the models. 
    I could also probably make it possible to move some parts relative to each other.

    Without knowing how normals are stored, mesh editing wouldn't work.  As things would be very, very, very, ugly.




     


    Online BUncle

    • Through kittehz, I
    • Transcend
    • *
    • Posts: 42297
    • €457
    • View Inventory
    • Send /Gift
    • Someone thinks a Winrar is You!  Because there are times when people just need a cute puppy  Soft kitty, warm kitty, little ball of fur  
    • AC2 is my instrument, my heart, as I play my song.
    • Planet tales writer Smilie Artist Custom Faction Modder AC2 Wiki contributor Downloads Contributor
      • View Profile
      • My Custom Factions
      • Awards
    Re: CVR Progress - Now with images!
    « Reply #13 on: February 26, 2014, 10:15:41 PM »
  • Publish
  • Y'know, I gather from your work that the files are true 3D - all I could tell from the .cvr viewer lo, all those many years ago, was that eight different positions displayed.  That's all the game needs anyway.  If, then, it was possible to substitute eight 2D flat shots of a covered wagon in place of the eight angles the colony pods display depending on which way they went - it would be a lot of work, but totally doable, and make that wild west mod someone dreamed of SO much better...

    Offline Ford_Prefect

    Re: CVR Progress - Now with images!
    « Reply #14 on: February 26, 2014, 10:21:59 PM »
  • Publish
  • Actually, it would be more like spray painting the desired image onto the model using the palette colors.  Not sure what a different color palette would do to the object models in the game.  They both use a 256 color palette.  If you change the games color palette, does it change the colors of the units as well or does the game just crash?

     

    * User

    Welcome, Guest. Please login or register.
    Did you miss your activation email?


    Login with username, password and session length

    Select language:

    * Community poll

    SMAC v.4 SMAX v.2 (or previous versions)
    -=-
    14 (6%)
    XP Compatibility patch
    -=-
    7 (3%)
    Gog version for Windows
    -=-
    45 (22%)
    Scient (unofficial) patch
    -=-
    22 (10%)
    Kyrub's latest patch
    -=-
    13 (6%)
    Yitzi's latest patch
    -=-
    77 (38%)
    AC for Mac
    -=-
    2 (0%)
    AC for Linux
    -=-
    5 (2%)
    Gog version for Mac
    -=-
    7 (3%)
    No patch
    -=-
    9 (4%)
    Total Members Voted: 201
    AC2 Wiki Logo

    * Random quote

    The Warrior's bland acronym, MMI, obscures the true horror of this monstrosity. Its inventors promise a new era of genius, but meanwhile unscrupulous power brokers use its forcible installation to violate the sanctity of unwilling human minds. They are creating their own private army of demons.
    ~Commissioner Pravin Lal 'Report on Human Rights'

    * Select your theme

    *

    Facebook Comments