Blender I/O+ Scripts- rFactor2

Discussion in 'Modding' started by Traveller, Sep 23, 2013.

  1. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    This is a thread for rF2 specific questions for my Blender scripts GMT's. I'm posting it here as a separate entity because 1) maybe not all rF2 users visit the rF1 forums, 2) these will be rF2 specific, and 3) it is more visible than posts in the "Blender- 3DSimEd- rFactor2" thread here. From the just mentioned thread, I have:

    "Alrighty, then. Asking for some help for the rF2 side of the project. This seems to be as good a place as any. Specific to this request is how the four UV coordinate sets in the Vertex data structure are determined. Also, bit flag values and meanings...." So....

    Does anyone have the meaning of the various rF2 bit flag values?

    Does anyone know how a given how a set of UV coordinates is chosen and designated as being used in the GMT?

    I'm also starting to tinker around with skeletons, so, does anyone have the bone format?
     
  2. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    I believe first question will be: "download link?" ;)

    I have some, but not all. Most of them are the same as in rF1. I have made a small tool that converts GMT files directly from rF1 to rF2, so I have some idea of GMT file layout in rF2.

    I'll look for my files later.

    It's the shader that determines which UV set is used for what.

    As for UV sets in Blender - they're named, so I think it would be nice if we could have some naming convention. It could be just "UV0", "UV1" or it could be "Diffuse0", "Diffuse1", etc.
    I don't know if order of UV sets in Blender data structures is the same as displayed in user interface. Perhaps it is, but if not, then naming is needed.
     
    Last edited by a moderator: Sep 23, 2013
  3. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Understood on the UV layers and shaders determining what they are. Presumably, for shaders using up to four textures it would be easy-- one per texture. However, for those shaders with more than four textures-- say, Real Road-- which of the UV layers are stored in which spots and what determines that? I have uniquely named my layers based on the texture they are associated with-- Diffuse01, Diffuse02, Normal, Specular, Cube, etc.
     
  4. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    Normally you would read that information from shader source code, but they're unavailable to us.

    I believe your best bet is to look at UV sets available for each shader in 3D Studio. Real road is a specific shader, but you can find information about it in track_tech.pdf ( check dev corner on rFactor 2 home page ).
     
  5. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    I don't have 3DSMax, so... I'll work it like this: for shaders with up to four textures, I'll simply use the UV layers for each texture; for shaders with more than four textures, I'll check how many different types of textures there are-- diffuse, specular, bump and cube-- then determine the UV layers based upon that.
     
  6. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Welp, my UV layers routines are in place and a quick test shows they're working. Any further work would be in adjusting the From and To strings. So...Here's what I have for flags. Any clarification is appreciated.

    Code:
    class TGMTHeader():
        MaterialsOffset = LongWord;
        Flags = LongWord
            #0x80000000 = ?
            #0x40000000 = Lit at Night
            #0x20000000 = ?
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = ?
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = ?
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = ?
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = ?
            #0x00000080 = ?
            #0x00000040 = ?
            #0x00000020 = ? (Default = Set) rF1
            #0x00000010 = ?
            #0x00000008 = ? (rF2?)
            #0x00000004 = ?
            #0x00000002 = ?
            #0x00000001 = ?
    
    
    class TGMTMesh():
        Flags = LongWord
            #0x80000000 = ?
            #0x40000000 = ?
            #0x20000000 = ? {Default = Set}
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = ?
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = ?
            #0x00008000 = ?
            #0x00004000 = ? {Default = Set}
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = ?
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = ?
            #0x00000080 = ?
            #0x00000040 = ?
            #0x00000020 = ? Specular Map UV Exists?
            #0x00000010 = ? {Default = Set}
            #0x00000008 = ?
            #0x00000004 = ? Normal Map UV Exists?
            #0x00000002 = ?
            #0x00000001 = ? {Default = Set}
    
    
    class TMaterialHeader():
        Name =  [] #array[0..63] of char
        Flags = LongWord #  {0x68900003, 0x68910023 }
            #0x80000000 = ?
            #0x40000000 = ?  {Default, Set}
            #0x20000000 = EmissiveM : True = float values, false = integer values
            #0x10000000 = ?
            #0x08000000 = ?  {Default, Set}
            #0x04000000 = SpecularM : True = float values, false = integer values
            #0x02000000 = ?
            #0x01000000 = DiffuseM : True = float values, false = integer values
            #0x00800000 = ?  {Default, Set}
            #0x00400000 = ?
            #0x00200000 = AmbientM : True = float values, false = integer values
            #0x00100000 = ?  {Default, Set}
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = Glass Material
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = Double Sided Material
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = No Clipping
            #0x00000080 = ?
            #0x00000040 = Specular
            #0x00000020 = Blend
            #0x00000010 = ?
            #0x00000008 = ?
            #0x00000004 = ?
            #0x00000002 = ? Auto
            #0x00000001 = ? Auto
    
    
    class TTexture():
        Name = [] #Array[0..63] of char
        Flags = LongWord
            #0x80000000 = ?
            #0x40000000 = ?
            #0x20000000 = ?
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = Video
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = No Texture Compression
            #0x00040000 = ?
            #0x00020000 = Mirror V
            #0x00010000 = Mirror U
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = Clamp V
            #0x00000400 = Clamp U
            #0x00000200 = ?
            #0x00000100 = Unique
            #0x00000080 = Use Color Key; Otherwise Use Alpha Channel
            #0x00000040 = ?
            #0x00000020 = ?
            #0x00000010 = ?
            #0x00000008 = MipMap
            #0x00000004 = ?
            #0x00000002 = Render
            #0x00000001 = No Reduce
    
     
  7. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    I'm not able to help you with the programming stuff but I really really hope you will be able to get the plugin working! I'm a big fan of Blender and really would love to be able to use Blender directly, and without the additional steps using 3DSimEd, to get models into rFactor ;)
     
  8. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    I've gone through some rF2 GMT's and found some flags to question. They follow:

    Driver Object: 0x4004020; lit at night, ? the 0x4000 and 0x20
    Driver Mesh: 0x20004080; ? the 0x20000000 and 0x4000 and 0x80

    Rain Plane Object: 0x20; not lit at night. Makes sense. ? the 0x20
    Rain Plane Mesh: 0x20004080; ? the same three as in the Driver mesh
    Rain Plane Material DROPS01: 0x68904003; ? the 0x4000
    Rain Plane DROPS01 Texture FRAMEBUFFER: 0x1000001a, ? the 0x10000000 and 0x2

    Windows Material WCWINDOWSOUT: 0x68940403. ? the 0x40000 and 0x400
    WCWINDOWSOUT Texture CAR_CUBE_DX9: 0x20401a. ? the 0x200000 and 0x4000
    Windows Material WCCARBODY: 0x68900403, ? the 0x400

    StartGlow Material RDLTGLOWA: 0x68900023, ? the 0x20

    There's a lot of repetition through GMT's, so I looked through several different types to find differences that might be type specific.
     
  9. Chris English

    Chris English Registered

    Joined:
    Oct 5, 2010
    Messages:
    69
    Likes Received:
    14
    Any updates Traveller?

    I'm using Blender to create my first car for rF2 (for anything in fact!) and would love something like this to help me along! :)
     
  10. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Welp, I was going to post the following down below, but since you asked here...

    As near as I can recall, it was three years ago today when I first sat down with Delphi (Pascal) to Type out the GMT format on this project. The scope of the project has changed since then. In fact, the project would have died if I had kept to the original scope of a .blend to .gmt file converter within Delphi. Moving the project to actually using Blender as the creative tool then exporting from Blender to a GMT gave the project more life. It would have died again had Blender not been improved upon. In this case, the restructuring of Blender data between 2.4x and 2.5x+ allowed the project to go forward. The project has evolved along with Blender over the course of the 2.5x to 2.6x-- and soon to be 2.7x-- development arc. I still hope to move to the use of nodes or pynodes, though that part is on hold for the time being.

    I'm still working on this project, though progress is slow. I have far too many interests. The bulk of the heavy lifting, so to speak, looks to be over-- with the exception of rigged GMT's. My tester is focusing on increasingly more specific areas of concern. For instance, the latest concern of his has lead me to look again at how the vertices are generated for export of rF2 GMT's. A GMT provided to me by blakboks in these forums has caused me to go hmmm. I still have ideas of my own for improvement. I've also started to look at rigged GMT's.

    Currently, the project is at version 0.64 of the scripts, with 0.65 already in work. Static GMT's are fairly solid. Rigged GMT's are in a very early state of support. I've no estimated date for release.

    rF_Menu_065.jpg
     
    Last edited by a moderator: Jan 21, 2014
  11. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Does anyone have a handle on the bone data format in rigged GMT's? There are two sets of sixteen float values in the data. The first looks to contain the head position of the bone. Presumably the second set contains the tail data, though I can't find it. As with just about everything else with this project, this is all brand new to me. I've never done a rig in Blender before so, of course, I'm trying to set them up via Python scripts.

    Likewise, does anyone have information on ANM files? They seem to have dynamic data structures that I've yet to fully decipher.

    PM me if you have info...

    I've attached an image of my current state of understanding with rigged GMT's-- a wiper blade with three bones.


    wiper_sample.jpg
     
  12. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Welp, SoTA R3 is over, so back to work on the scripts until the next bit of goodness comes along.

    0.65 is out the door, onwards to 0.66. It seems the first three floats in the first batch of sixteen contain the vector of bone. Maybe. It works fine for the wiper, not so much on cows and corner workers. I won't know for sure until I find the length. If I'm even on the right track.
    Wiper_2.jpg
     
  13. TOCA2FREAK

    TOCA2FREAK Registered

    Joined:
    Apr 6, 2011
    Messages:
    936
    Likes Received:
    125
    Hi Traveller. How is this coming along? I have just got into Blender and would love to make car models for rf2! Many thanks. :D
     
  14. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    I've pretty much come to a halt on the scripts. I made a little progress concerning bones after my post above-- see image-- and that's about it. I don't feel like trying to further decipher ANM files, or bones, or making sure my shader library is up to date with current rF2 build, or anything else right now. I had intended to do some rearranging and housekeeping of the four script files before the end of this month, but that hasn't happened-- and I'd say there's a 99.99999% chance it won't. So, there you have it.
    Wiper_2.jpg
     
  15. TOCA2FREAK

    TOCA2FREAK Registered

    Joined:
    Apr 6, 2011
    Messages:
    936
    Likes Received:
    125
    Thanks for the reply. Shame you won't get the chance to finish it though. :(
     
  16. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    I haven't quit, I'm just taking a break. It's not the only break from these scripts that I've taken the past three years.
     
  17. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Bringing the last week or so of posts from another thread into here, because I thought that's where they were. I shall try to be more attentive in the future.

    Do you know the nuts and bolts of GMT's? Figuratively speaking, of course, I know they don't really have nuts and bolts. That's what's needed right now
     
  18. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Alrighty, then. I think I've found what was Not Quite Right. I wrote some normals in an incorrect order. I've made corrections to the scripts-- I can look at them for the first time in three or so months and not have my temple feel numb. I've also added a little feature-- sharp edges as defined and marked in Blender can appear in GMT's. See the attached images. Time to send out the next version of the scripts to my tester and see what the result is...

    SharpEdges.jpg
    GRAB_010_Cropped.jpg
     
  19. sf4JC

    sf4JC Registered

    Joined:
    Oct 5, 2010
    Messages:
    180
    Likes Received:
    1
    THANKS, Traveller! Thanks for your continued efforts on this!

    Scott
     
  20. Raúl Cor

    Raúl Cor Registered

    Joined:
    Oct 15, 2013
    Messages:
    126
    Likes Received:
    0
    is donwloadable? this plugin?
     

Share This Page