Rudimentary DSF parser in C#

Greetings,

Just sharing the core classes because I'm super-happy to have gotten it as far as I have.

https://gist.github.com/cyberfox/369480dd45b01829468e5c8a25a4eb1b

I actually got a native DSF object file to directly import to a mesh in Unity, based on this importer code.

--  Morgan

 

Screen Shot 2020-04-11 at 5.17.13 AM.png
1988 x 978 - 353K

Comments

  • nonesuch00nonesuch00 Posts: 17,929

    Cool. DSF is DAZ Studio Foundation class? 

  • CypherFOXCypherFOX Posts: 3,401
    edited April 2020

    Greetings,

    DSF is DSON Support File and contains the basic information about the object.  It's roughly the same as an OBJ file, but the idea is that DUF files aggregate references to DSF and image files, so those things can remain in a known location, while the DUF files move around.  Or, put more technically: Asset definitions within a DSON Support File (DSF) are pure definitions and represent information that can be shared among instances.

    What I wanted was the ability to load a scene file (DUF) directly into Unity, without having to export/import.  What I found was that DUF files reference other DUF files, which ultimately do NOT include the individual vertices, instead they reference .DSF files which do contain the vertices and polygon groups.

    So the first step in doing the whole thing was to get the DSF files to load in as meshes in Unity, the first pass of which is what I got working last night. smiley

    --  Morgan

    Post edited by CypherFOX on
  • Silver DolphinSilver Dolphin Posts: 1,593

    Nice and great work!!

  • nonesuch00nonesuch00 Posts: 17,929
    CypherFOX said:

    Greetings,

    DSF is DSON Support File and contains the basic information about the object.  It's roughly the same as an OBJ file, but the idea is that DUF files aggregate references to DSF and image files, so those things can remain in a known location, while the DUF files move around.  Or, put more technically: Asset definitions within a DSON Support File (DSF) are pure definitions and represent information that can be shared among instances.

    What I wanted was the ability to load a scene file (DUF) directly into Unity, without having to export/import.  What I found was that DUF files reference other DUF files, which ultimately do NOT include the individual vertices, instead they reference .DSF files which do contain the vertices and polygon groups.

    So the first step in doing the whole thing was to get the DSF files to load in as meshes in Unity, the first pass of which is what I got working last night. smiley

    --  Morgan

    Good job the link you gave has a problem when I try and follow it but I think the content is the same as this link?

    http://docs.daz3d.com/doku.php/public/dson_spec/start#dson_file_format_specification

     

  • CypherFOXCypherFOX Posts: 3,401

    Greetings,

    Good job the link you gave has a problem when I try and follow it but I think the content is the same as this link?

    http://docs.daz3d.com/doku.php/public/dson_spec/start#dson_file_format_specification

    Pretty much; I had automatically changed the link to `https` because...everything is https these days, and that _doesn't_ work for the docs links. :). I fixed it, but yes...that's the doc starting spot.

    --  Morgan

     

  • Nice work on this. I've also been playing around with Daz files. I got the DSF object by using "paste special" in Visual Studio. I took Genesis <version>.Dsf and selected all then copied into the source code.

    This gave me a rotoobject which I renamed and modified to suit the task.  I also did morph files, a sample I posted here (your code didn't inlcude the modifier_library).

    I hope this helps! :)

     public class Rootobject
        {
            public string file_version { get; set; }
            public Units units { get; set; }
            public Asset_Info asset_info { get; set; }
            public object[] pedigree { get; set; }
            public Modifier_Library[] modifier_library { get; set; }
            public Scene scene { get; set; }
        }

        public class Units
        {
            public int length { get; set; }
            public string angle { get; set; }
            public int time { get; set; }
        }

        public class Asset_Info
        {
            public string id { get; set; }
            public Contributor contributor { get; set; }
            public string revision { get; set; }
            public string modified { get; set; }
        }

        public class Contributor
        {
            public string author { get; set; }
            public string email { get; set; }
            public string website { get; set; }
        }

        public class Scene
        {
            public Modifier[] modifiers { get; set; }
        }

        public class Modifier
        {
            public string id { get; set; }
            public string url { get; set; }
        }

        public class Modifier_Library
        {
            public string id { get; set; }
            public string parent { get; set; }
            public Presentation presentation { get; set; }
            public Channel channel { get; set; }
            public string region { get; set; }
            public string group { get; set; }
            public Formula[] formulas { get; set; }
            public Morph morph { get; set; }
        }

        public class Presentation
        {
            public string type { get; set; }
            public string label { get; set; }
            public string description { get; set; }
            public string icon_large { get; set; }
            public float[][] colors { get; set; }
        }

        public class Channel
        {
            public string id { get; set; }
            public string label { get; set; }
            public bool visible { get; set; }
            public bool locked { get; set; }
            public int min { get; set; }
            public int max { get; set; }
            public bool clamped { get; set; }
            public bool display_as_percent { get; set; }
            public float step_size { get; set; }
            public int value { get; set; }
            public bool auto_follow { get; set; }
        }

        public class Morph
        {
            public int vertex_count { get; set; }
            public Deltas deltas { get; set; }
        }

        public class Deltas
        {
            public int count { get; set; }
            public float[][] values { get; set; }
        }

        public class Formula
        {
            public string output { get; set; }
            public Operation[] operations { get; set; }
        }

        public class Operation
        {
            public string op { get; set; }
            public string url { get; set; }
            public float val { get; set; }
        }

    Regards,

    Dorian

Sign In or Register to comment.