XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Tue Oct 24, 2017 5:22 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 79 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Cryengine Export tool (cgf-exporter)
PostPosted: Sun Aug 02, 2015 4:53 am 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times

Cryengine Converter

Project Location: https://github.com/Markemp/Cryengine-Converter
Current version: 0.84
Executable: https://github.com/Markemp/Cryengine-Co ... /tag/1.0.0

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.

The .obj files that it creates should have the proper material library referenced (in Cryengine terms; not usable by most .obj importers), with the proper materials assigned to each group.

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] [-smoot
h] [-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
-noconflict: Use non-conflicting naming scheme (<cgf File>_out.obj)
-allowconflict: Allows conflicts in .mtl file name
-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

Known issues:
* If you put a trailing "/" in the objectdir argument, it will not find the associated .mtl file. For example, use "e:\game\objects" and not "e:\game\objects\".

Bug Reporting:

For now, please just copy the output of the command prompt, and I may send a debugging version for additional info via PM

Future enhancements:

From the TODO file at github:
Version 0.9
* .mtl files - convert Cryengine .mtl files to .obj .mtl files, and better mtl file handling. COMPLETE
* Break classes into separate files. IN PROGRESS
* Input validation, error checking, etc. IN PROGRESS (mostly done)
* Move version, id, type and offset so they are read from the chunk table, not the chunks. COMPLETE
* add build version into the output
* Bug fix so some .obj files import properly to Blender (exploded geometry issue) COMPLETE!!!
* Output to a user defined file (default to <object name.obj>) COMPLETE
* Export to Collada (including armature) COMPLETE

Version 1.1
* Export directly to .blend files

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

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.

You can make the ads go away by registering



Last edited by Markemp on Mon Oct 09, 2017 3:36 am, edited 9 times in total.

Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Sun Aug 02, 2015 4:54 am 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
Reserved for Asset Importer and Mech Importer powershell script information.


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Sat Aug 29, 2015 5:24 pm 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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).


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Thu Sep 03, 2015 4:00 am 
Offline
mega-veteran
mega-veteran

Joined: Mon May 12, 2008 5:15 pm
Posts: 183
Has thanked: 4 times
Have thanks: 82 times
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.


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Wed Sep 16, 2015 6:52 am 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
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?


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Mon Oct 05, 2015 3:01 pm 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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. :(


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 06, 2015 8:01 pm 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
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


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 06, 2015 9:09 pm 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 06, 2015 9:51 pm 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
the problem is in the position / rotation of the elements.
In mobiglass lenses are not quite in place (see under blue glass)


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 06, 2015 9:57 pm 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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. :(


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 27, 2015 3:49 am 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
It seems not work with the new build of ( 1.3)


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Oct 27, 2015 3:58 am 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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.


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Mon Nov 16, 2015 1:07 pm 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
Any news?


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Tue Nov 17, 2015 2:02 am 
Offline
veteran

Joined: Tue Dec 24, 2013 2:42 am
Posts: 80
Has thanked: 4 times
Have thanks: 31 times
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).


Top
 Profile  
 
 Post subject: Re: Cryengine Export tool (cgf-exporter)
PostPosted: Thu Nov 19, 2015 11:13 am 
Offline
veteran

Joined: Fri Jan 20, 2012 5:43 pm
Posts: 129
Has thanked: 17 times
Have thanks: 35 times
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!



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 79 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group