XeNTaX
http://forum.xentax.com/

Cryengine Converter tool (cgf-exporter)
http://forum.xentax.com/viewtopic.php?f=33&t=13137
Page 1 of 7

Author:  Markemp [ Sun Aug 02, 2015 4:53 am ]
Post subject:  Cryengine Converter tool (cgf-exporter)

Cryengine Converter

Project Location: https://github.com/Markemp/Cryengine-Converter or https://www.heffaypresents.com/GitHub
Current version: 1.0.2
Executable: https://github.com/Markemp/Cryengine-Co ... /releases/

Change log (last updated 10/07/2017):
10/07/2017: 1.0 release. Full Collada support. Support for Armature/rig with vertex weights. Support for Star Citizen 2.6 files (and earlier).
12/17/2015: 0.84 released. Most of the exploded geometry issues fixed (Thanks, Coffee!!)

Introducing a new tool designed to convert modern Cryengine games into .dae and .obj files. And eventually export them to , Blender .blend files and maybe even .fbx files if I get suitably motivated.

The current way of accessing modern Cryengine games was to use Noesis (by Mr Adults) with the cryengine_cgf.dll plug-in (by revelation). And this worked decently for most activities, but there were a number of limitations when used against the modern game files:

* Materials weren't referenced properly, so you had to manually create them and assign to the right vertex group (involved a lot of guesswork).
* Didn't work with files newer than CE 3.4.
* With some objects, the geometry was exploded and each component had to be manually placed.
* Didn't recognize .cga files, although you could rename .cgf files to .cga.
* The geometry was a bit haphazard, with tons of duplicate vertices.
* UV maps weren't normalized.

This new tool is written in C#, and although I haven't done any performance enhancements yet it is still pretty fast. You can script it up with Powershell to batch process a number of .cgf and .cga files at once. There is also an asset-importer.ps1 Powershell script I've written that assists bringing in Cryengine files into Blender, creating the proper material Node Groups, etc. That will get uploaded soon as well; more details to follow.

TUTORIAL VIDEOS
Part 1: Converting Cryengine Files: https://www.youtube.com/watch?v=6WoA2ubTZ0k
Part 2: Bulk Converting Cryengine Assets: https://www.youtube.com/watch?v=3VtZf5JS8Bs

Usage:
Copy cgf-converter.exe to the path (for convenience, unless you want to reference the location each time you run it). Then follow the usage details below:

cgf-converter [-usage] | <.cgf file> [-outputfile <output file>] [-objectdir <ObjectDir>] [-obj] [-blend] [-dae] [-smooth] [-throw]

-usage: Prints out the usage statement

<.cgf file>: Mandatory. The name of the .cgf, .cga or .skin file to process
-outputfile: The name of the file to write the output. Default is [root].obj (for .obj exporting only)
-noconflict: Use non-conflicting naming scheme (<cgf File>_out.obj) (for .obj exporting only)
-allowconflict: Allows conflicts in .mtl file name (for .obj exporting only)
-objectdir: The name where the base Objects directory is located. Used to read mtl file
Defaults to current directory.
-dae: Export Collada format files (default behavior)
-obj: Export Wavefront format files
-blend: Export Blender format files (Not Implemented)
-fbx: Export FBX format files (Not Implemented)
-smooth: Smooth Faces
-group: Group meshes into single model

-throw: Throw Exceptions to installed debugger

Bug Reporting:

Please add a new Issue at the GitHub page: https://github.com/Markemp/Cryengine-Converter/issues

Future enhancements:

Games currently tested against:
Star Citizen (through 2.6)
MechWarrior Online
Armored Warfare
Prey
Archeage

If you'd like to participate in the future development of this tool, please send me a message. Thanks!

Special thanks to shakotay2 for helping sort out some format issues.
Special thanks to Coffee for making me not stupid about transform matrices.

Author:  Markemp [ Sun Aug 02, 2015 4:54 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Cryengine Importer!

This replaces the 2 powershell scripts Asset Importer and Mech Importer. It's been consolidated into a Blender add-on, written in python, and a new Prefab Importer feature has been added.

You can find this new tool at:

https://www.heffaypresents.com/github

The tutorial video on how to use it can be found at:

https://www.youtube.com/watch?v=oBJzNdzFIxM

It's been tested heavily for MechWarrior Online. It probably doesn't work for 2.3 or newer Star Citizen files, but I'll be working on updating it to handle those game files as well. The Cryengine Converter tool does work for Star Citizen 3.0 files though!

Author:  Markemp [ Sat Aug 29, 2015 5:24 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Ok, I fixed the dreaded exploded geometry issue for Cryengine files! It turns out to be several factors:

(@revelation, if you want the code specifics for your cryengine_cgf.dll for Noesis, I'll be happy to share them with you)

1) The transform vector is in 2 places. A Vector3 called Transform, and then a 4x4 matrix where the bottom row was the same value. However occasionally the Transform vector didn't have any data, so you always had to use the matrix for this info.

2) The values needed to be divided by 100. Why? I have no idea. They just do.

3) The transform of any piece was based on where its parent was placed. So if you had an item that was 4 deep in the hierarchy, you had to add the transforms of *each* of the parents, all the way to the root node.

Anyway, between that and bug fixes (still in progress), shit be working yo!

Image

Well.. mostly. There are still some pieces that aren't playing nicely, but the vast majority do. I'll sort them out eventually.

Bonus: These should work with Armored Warfare game files too, if you want some juicy tank models!

Caveat: Cryengine has gone away from the .dds files containing all the mipmaps, and instead now creates a separate dds file with a numerical extension for each level (dds.1, dds.2, dds.etc), along with what is probably an index file. No big deal, as the format is known and I can incorporate this into my program eventually. And tools already exist to convert them.

As always, anyone who wants to participate in my github and help develop the program, your help is definitely appreciated! My next goals are armatures, animation files (.caf), and exporting directly to Blender files (.blend).

Author:  revelation [ Thu Sep 03, 2015 4:00 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

i have been following the work you have been doing. parts of my plugin were cross referenced against pyffi as well. doing some major cleanup on all my plugins. will see if i can contribute to your work when i can make some time. will be good to get all of the features sorted out for supporting this engine and its formats.

Author:  erik945 [ Wed Sep 16, 2015 6:52 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Thank you for your work!
What news about position/rotation submeshes?
I watch your sources - you use only transform matrix44 only for positions submeshes (without rotations), but class ChunkNode has Pos and Rot properties but don't use it - what is it?

Author:  Markemp [ Mon Oct 05, 2015 3:01 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

erik945 wrote:
Thank you for your work!
What news about position/rotation submeshes?
I watch your sources - you use only transform matrix44 only for positions submeshes (without rotations), but class ChunkNode has Pos and Rot properties but don't use it - what is it?


Crap, was on vacation when you asked this.

From my understanding: The Node chunk is where the scale/rot/transform info is stored for each "object". Each Node chunk has one Mesh chunk. Each Mesh chunk can have multiple Submesh chunks, which contain the actual vertex info.

There is a parent Node chunk that all other Nodes are based off of. And Nodes can have children as well, so think of a tree structure. Parent Node, its children, and the children of those children, etc. And the transform of each Node is based off of the transform of its parent, all the way to the Root. So to calculate the actual transform of any particular Node, you have to add it to all the ones all the way to the Root.

Code:
        public Vector3 GetTransform(ChunkNode chunkNode, Vector3 transform)        //  Calculate the transform of a node by getting parent's transform.
        {
            float x = chunkNode.Transform.m41 / 100;
            float y = chunkNode.Transform.m42 / 100;
            float z = chunkNode.Transform.m43 / 100;
            // if we're at the parent, we just want to return.  Otherwise we want to go up to the next level.
            // Matrix math here.  final x is x*m11 + y*m12 + z*m13.  Same for y and z
            if (chunkNode.Parent != 0xFFFFFFFF)
            {
                transform.x += x * chunkNode.Transform.m11 + y * chunkNode.Transform.m12 + z * chunkNode.Transform.m13;
                transform.y += x * chunkNode.Transform.m21 + y * chunkNode.Transform.m22 + z * chunkNode.Transform.m23;
                transform.z += x * chunkNode.Transform.m31 + y * chunkNode.Transform.m32 + z * chunkNode.Transform.m33;

                transform = GetTransform((ChunkNode)ChunkDictionary[chunkNode.Parent], transform);
            }

            return transform;
        }


This should actually calculate the rotation as well, but it's probably wrong which is why I'm having problems right now. The hatch picture (round thing on front starboard side) is in the right location (at least the parent node), but some of the internal structure (children of it) aren't. That's without applying the rotation component. When I apply the rotation, all the subcomponents end up in the right place relative to each other, but the parent node ends up on the wrong side of the ship, near the back.

There are also some other components that have weird issues, like the hatch covers on the wing fans. The can be located *relatively* close to where they are supposed to be, but just not quite rotated correctly.

Obviously I'm screwing up the calculations some how, but not quite sure what is going wrong yet. I'm *so* close to having this working that it hurts. :(

Author:  erik945 [ Tue Oct 06, 2015 8:01 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Thank you for answer.
If you be interested - two problematic models.
In GameSdk displayed normally.

https://www.dropbox.com/s/o3c9lviltmjl2 ... s.cgf?dl=0
https://www.dropbox.com/s/nsx7lveimxz5o ... _.cga?dl=0

Author:  Markemp [ Tue Oct 06, 2015 9:09 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

The mobiglass model did import into Blender without issue, although it did take a while to complete. What error did you get?

Image

I'll take a look at the other one too.

edit: The other one "worked" too, although it's having the normal issues with the position of some child Nodes not being in the right place.

Image

Author:  erik945 [ Tue Oct 06, 2015 9:51 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

the problem is in the position / rotation of the elements.
In mobiglass lenses are not quite in place (see under blue glass)

Author:  Markemp [ Tue Oct 06, 2015 9:57 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

erik945 wrote:
the problem is in the position / rotation of the elements.
In mobiglass lenses are not quite in place (see under blue glass)


Oh yeah. A number of models have that issue, since my transform & rotation math isn't right yet. I'm hoping someone can point out where I'm going wrong, otherwise a lot of models are going to require a lot of manual tweaking. :(

Author:  erik945 [ Tue Oct 27, 2015 3:49 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

It seems not work with the new build of ( 1.3)

Author:  Markemp [ Tue Oct 27, 2015 3:58 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

erik945 wrote:
It seems not work with the new build of ( 1.3)


Yup, I've heard there were issues. I'll take a look and see if I can get an updated version for this weekend.

Author:  erik945 [ Mon Nov 16, 2015 1:07 pm ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Any news?

Author:  Markemp [ Tue Nov 17, 2015 2:02 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

Try the dropbox download again. I put my latest version out there (let's call it 0.84 for lack of a better term), where I'm working on cleaning up the export, adding new chunks, etc. No major changes, but it may be a bit more reliable. Let me know what works and what doesn't work (and specifically what didn't work).

Author:  erik945 [ Thu Nov 19, 2015 11:13 am ]
Post subject:  Re: Cryengine Export tool (cgf-exporter)

don't work. Sorry.
Example files:
https://www.dropbox.com/s/lekxp9hbvj3ia ... d.zip?dl=0
Can you add option's for skip mtl files?
Thank you!

Page 1 of 7 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/