Author Topic: [Xenogears] Unity importer!  (Read 8836 times)

Micky

  • *
  • Posts: 300
    • View Profile
[Xenogears] Unity importer!
« on: 2012-11-27 23:03:30 »
I'm playing around with Unity3d at the moment, and I like it a lot! As an experiment I implemented an importer for some of the Xenogears assets types. It is just some of my old C++/Python code converted to C# and munged together. It doesn't contain any of Akari's latest research from q-gears and I didn't make any attempt to clean up duplicate functionality, yet.
You can't actually play anything, but you can use the Unity editor as a viewer to explore some of the models and textures.
http://bin.mypage.sk/FILES/ImportXenogears.unitypackage

Usage:
- Make sure you don't need the computer for the next hour or so and have lots of free space on the HD.
- You need raw disc images of disc 1 and disc 2. (2352 byte sector format, file extension .img. The extension is only cosmetic because I didn't find a way to allow multiple extensions in Unity's file selector API.)
- You need Unity 3.5. The free version should do. I don't have Unity 4.0 at home, yet, so I can't tell if there are any problems. ( http://unity3d.com/unity/download/archive )
- Create a new project.
- Import the unity package. This should give you two scripts.
- The window menu should now have an "import xenogears" option
- Use "choose disc image" to select the disc images. The code takes a sniff at the file system and automatically detects disc1/disc2 of the US NTSC version.
- Select "Import". The importer unpacks the disc images into individual files and then imports field, battle stages, worldmap and a bunch of TIM files. This takes ages, and unfortunately I can't display a progress bar because much of the UI is blocked.

There will be unity scenes for the field and battle backgrounds and the terrains that can be opened, alternatively you can browse the models in the project view. I didn't create scenes for the imported images.

Let me know how it goes.
(I don't plan to make this playable, that time would be better invested into q-gears.)

Update:
- it's now a unity package
- tweaked the instancing code for field scenes
- added hierarchy for battle scenes
- added scene models (mostly gears and spaceships)
« Last Edit: 2012-12-09 15:33:08 by Micky »

Micky

  • *
  • Posts: 300
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #1 on: 2012-12-04 07:45:56 »
I'm going through the q gears stuff to fill in some of the newer information. I could've sworn that someone decoded the meaning of the type flags in the skeleton/hierarchy for field models, but the documentation/reverse directory in q-gears doesn't contain it, and the exporter tools don't seem to handle it. Am I imagining this, or have documents and tools been lost? (Yes, I searched the forum.)

Akari

  • *
  • Posts: 766
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #2 on: 2012-12-04 18:23:52 »
I'm going through the q gears stuff to fill in some of the newer information. I could've sworn that someone decoded the meaning of the type flags in the skeleton/hierarchy for field models, but the documentation/reverse directory in q-gears doesn't contain it, and the exporter tools don't seem to handle it. Am I imagining this, or have documents and tools been lost? (Yes, I searched the forum.)

I don't remember that there are any flags. Can you post an example?

Micky

  • *
  • Posts: 300
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #3 on: 2012-12-04 20:47:41 »
If you look in ImportXenogears.cs, from line 821 on:
Code: (C#) [Select]
int itemCount = (int)getUInt32LE(archiveData, 0x018C);
for(uint itemIndex=0; itemIndex < itemCount; itemIndex++) {
ushort flags = getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 0);
ushort rot_x = getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 2);
ushort rot_y = getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 4);
ushort rot_z = getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 6);
short pos_x = (short)getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 8);
short pos_y = (short)getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 10);
short pos_z = (short)getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 12);
ushort index = getUInt16LE(archiveData, 0x0190 + itemIndex * 16 + 14);
This positions the different parts of the field model in the world, though some positions seem to refer to other things depending on the flags field. Index is the index of the mesh to place at a position.

Or this thread that shows the original problem and solution:
http://forums.qhimm.com/index.php?topic=8334.msg100658
« Last Edit: 2012-12-05 19:33:08 by Micky »

Micky

  • *
  • Posts: 300
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #4 on: 2014-01-02 13:23:07 »
Sorry for the thread necromancy, but it will make it easier for people using the forum search.

I made a new version:
http://bin.mypage.sk/FILES/ImportXenogears.zip

I tested this with Unity3D 4.3 on Windows 7. I had to make a small fix for path names, because it looks like Unity doesn't like backslashes. This was developed on OSX, so I missed it for the first release. Sorry. This version ramps the ambient lighting up so you can see models correctly. You'll have to enable the sun icon in the scene view to enable lighting.

« Last Edit: 2014-01-02 13:44:47 by Micky »

jkrigelman

  • *
  • Posts: 1
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #5 on: 2014-03-24 07:23:13 »
Noticed while in one of the debug rooms that the room is a mirror image between the in-game and Unity room layouts.

Also a few texture tweaks required to fix mostly the really big background images in the debug rooms. Not sure why this is...

Micky

  • *
  • Posts: 300
    • View Profile
Re: [Xenogears] Unity importer!
« Reply #6 on: 2014-03-25 09:33:19 »
I guess I didn't remember that Unity is left-handed. It's a trivial fix, but it'll have to wait until there is some stuff for a new version.