[WIP] rFactor Import/Export Scripts for Blender

Discussion in 'Third Party Content' started by Traveller, Jun 17, 2015.

  1. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    866
    Likes Received:
    497
    Select the parent (empty) object(s) in the outliner, then rFactor Menu/ Export without directories.
     
    Last edited: Mar 3, 2018
  2. I_Bellett

    I_Bellett Registered

    Joined:
    Jan 12, 2012
    Messages:
    203
    Likes Received:
    285
    Are there plans to correspond to Billboard?
     
  3. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    866
    Likes Received:
    497
    What billboard is not working? Example GMT.
     
  4. I_Bellett

    I_Bellett Registered

    Joined:
    Jan 12, 2012
    Messages:
    203
    Likes Received:
    285
    I was short on words, I'm sorry.
    Is there a way to add attributes to a tree that is not a billboard and output it?
     
  5. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    866
    Likes Received:
    497
    As in a "regular" GMT? I'd say, "yes". Unless something has changed of which I am not aware. Which is not all that far fetched, by the way. I've been away from this for a while, awaiting 2.8.
     
    ir Sindaco likes this.
  6. Jan Polak

    Jan Polak Registered

    Joined:
    Sep 1, 2018
    Messages:
    8
    Likes Received:
    1
    Hi, huge thanks for the amazing plugin, works amazing on most GMTs. At the moment though I need to import a rigged one, the default driver model in particular, in the patch notes I see a mention of rigged GMT support but after a quick look into the code it doesn't seem to be there at all. I don't need the bones, just the mesh, is there a way to enable importing of them?

    Thanks in advance.
     
  7. SmashingPants67

    SmashingPants67 Registered

    Joined:
    Oct 9, 2015
    Messages:
    80
    Likes Received:
    17
    [​IMG]
    I'm trying to convert a mod and this happens when I try to export...
    Already went to rFactor Menu->Change Target Version->rFactor 2 then Change rFactor Objects version.
    For those that can't see images, the error lines and scripts are:
    rF_Menu_Stuff.py, line 341 in execute
    rF_GMT_Export, line 3026 in save_rf_override
    rF_GMT_Export, line 2981 in save_gmt
    rF_GMT_Export, line 1665 in PutrF2GMT
    rF_GMT_Export, line 1436 in PutMeshes_rF2
    rF_GMT_Export, line 1012 in Triangulate
    IndexError: BMLayerCollection[index]: index 3 out of range
    @Traveller , which errors can you see in these lines?
     
    Last edited: Oct 24, 2018
  8. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    I need help, anyone could suggest me why I have lost UV map ? I am still very big noob, but I had very basic appearance for road and trackside yesterday in Gjed, today I launched gjed after tweaking some little things, and noticed that appearance of those objects has gone, I thin checked that in blender and saw that my UV maps are gone, also there were a lot of new UV maps. I think it happened so after I selected a new shader in blender, but I have also done the same for some other objects and they kept their UV's...

    At the moment I am having a lot of difficulties, just beginning to explore rF2 modding, after modding for AC. Everything seems so much more complex now. For example vertex colors, multiple UV chanels, so many settings and I am also a bit lost with shaders.. But I am moving forward, and slowly learning.

    Big thanks for this tool @Traveller ! Now there is a possibility to make something with Blender.
     
  9. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    866
    Likes Received:
    497
    Do you remember the FROM/TO shaders? UV's should be copied over.

    Oh, and always save. Take it from a veteran computer user who has been bitten a time or hundred. Heck, I've bitten myself far too many times with save mistakes or not saving because I thought I had.
     
  10. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    I pretty much went from none [select] to 2B-Road Shader Two.... I also just recreated that that.

    Also same was with 2B-Blended Grass Infields....

    Weirdly it didn't happen with 2B-T1 alpha Test...

    Another weird thing is that in my new project "select new shader" window is not accessible.

    Here is my new project, something like it was in previous, it is not bad, I'm just beginning conversion, but at first I expected better workflow lol:

    [​IMG] [​IMG]

    Here is my first attempt, which gone wrong, ton of UV channels got added and UV information was lost:
    [​IMG]
    [​IMG]

    This particular shader kept the UV, perhaps because it didn't add new UV channels, I made the screenshot with first UV channel on, but UV map is in 2nd channel so it doesn't show here but it is not lost.
    [​IMG]

    I actually also have pretty heavy clicking "save" habbit, I also do backups, but it is only beggining right now, it is not worth for me to do backups each hour, I'm used to maybe each week, while staying aware of things :D But at the beginning things are unexpected to me, I also watched some gJed tutorials, I saw how often it has to be restarted in order to show things correctly, perhaps thats why it is not included to official files at the moment ? In tutorials it was also mentioned to constantly do gjed file backups, but come-on, not each session ?
     
  11. dxp_rlong

    dxp_rlong Registered

    Joined:
    Nov 5, 2018
    Messages:
    26
    Likes Received:
    24
    The reason gJED is no longer included is it is no longer supported by S397. It uses the old DX9 render system, not the newer DX11. Hopefully S397 will provide a modern replacement for gJED.

    It isn't clear what your workflow is, so a few thoughts.

    I've found the gJED/Blender connection to be troublesome, especially UVs, depending on the sequence used. My first thought is remove gJED from your workflow because it is unsupported and very unlikely to be updated any time soon, if at all. Building a track entirely in Blender is most definitely possible. Use S397's Viewer or Dev Mode to view the GMTs that are completed in and exported from Blender.

    Sounds like you are doing a conversion. If so, your method of converting may play a big part in your issues.

    As for the UVs, what you are finding with the T1 Alpha Test material shader is that it only needs one UV channel because there is only one texture being used. When you apply the Real Road or Blended Grass material shaders, they have several textures and each needs its own UV map, thus the need for several UV maps/channels.

    In your new project (the one in the first image) there are no rF_Objects, they all appear to be basic Blender objects. rF_Objects are created by Travller's scripts. rF_Objects add rFactor specific parameters, like shaders, to the basic Blender object. To be able to select a shader for your basic Blender object, select the object and then select rFactor Menu>Add rFactor Material. This will add the needed rFactor parameters and allow you to select a shader for your rF_Object. This will also parent the object to a Blender Empty, which represents a GMT file.

    One way to understand how the UV maps are assigned for each shader, start a new project, from the rFactor Menu>Add rFactor Object, select it and assign a shader (T1 is a good start), check the UV Maps list to see what UV maps have been added. Then assign a different shader (Real Road is good choice), then look at the UV Maps list. Notice how the UV map list changes. Also, check the Texture list each time (checkerboard icon). The number of textures in the texture list will change as you change shaders depending on the shader's required textures.
     
    adamfarmer, Mauro and mantasisg like this.
  12. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    Thank you ! :)

    It is unclear to me either whats the workflow, and not even what way to choose, as I'm just learning searching, but it is getting clearer, yesterday managed to get something in game for the first time, I mean in dev mode.

    I'll try to do things by skipping gjed, will be interesting to check how it will workout, though I actually like gjed despite some troubles. gJed definitelly has issues, and could be improved, but essentially I don't think it is bad.

    Yes I am converting my own track which I made for AC (I also have some more, and few cars), I'm really looking for most optimal way to do stuff. Was very happy to find about Travellers addon, because at first I thought it all ends at the beginning because of focus to 3Ds max.

    So far it is known to me, that I can just add "rFactor material" then it adds a lot of settings in object data, material and texture. In object data I get to see new UV channel, and the old UV channel gets renamed from "UV map" to "Diffuse #1 UV Layer" and keeps the UV map which is kool, then new added UV channel is named "UV map" and is unmaped. Then, if i understand correctly, I have to choose shader from material tab to enamble needed UV layers and adjust maps for each. But if there are different new layers of UV's, then my current UV's gets totally overwritten and my maps are lost, why it can't be kept, why I still have them after adding rF material ? Weirdly in my second attempt of the project, I don't even get to choose shader at all as seen in my screens. I have tried your suggestion with adding rF_object, and it really gives me choise of shader now, but i still have to understand what it does, so i have to read what you wrote few more times :D

    If I understand correctly I'll need rF_objects in order to skip gJed ? because so far i didn't find them necessary. I also have extracted and opened Oulton track as an example, I don't see any parents/childs there, so i suppose hierarchy is used just to export to gmt from blender ?

    I also wonder how can I get multiple materials on one object to work ? I'm pretty confused now at the beginning.
     
  13. dxp_rlong

    dxp_rlong Registered

    Joined:
    Nov 5, 2018
    Messages:
    26
    Likes Received:
    24
    From looking @ your new project screenshot above, it appears you are importing your FBX files (that have the UVs already set) into Blender. Then adding the rFactor material. That's a sequence I haven't used. I've imported FBX files without any UVs set, added a rFactor material and then set UVs in Blender without any problems. So finding a workable import method is what I believe needs to happen. Since I've not done this with UVs, I can only offer an experiment.

    While I've said do not use gJED, the following step is one function that seems to work.

    The test would be a sequence like:

    - start with a FBX object with only one UV map (I'll call it: Obj_UV.FBX)
    - import Obj_UV.FBX into gJED
    - export it as a GMT (Obj_UV.GMT)
    - exit gJED
    - Open a new project in Blender
    - Select rFactor Menu>Import rFactor (*.GMT, *.GEN and *.SCN)
    - import Obj_UV.GMT
    - DO NOT use Add rFactor Material

    If this works like I expect it to, this sequence will create the rF_Object as a part of the import process. There will be a Blender Empty with the imported mesh as a child. The child mesh will have one UV Map named: Diffuse #1 UV Layer and one (diffuse) Texture channel. This diffuse UV layer should contain the UV map from the original Obj_UV.FBX (which should have been exported as a part of the GMT). The scripts should make an attempt to assign a usable shader as part of the import.

    If the assigned shader is not the one you want, since it is already a rF_Object, changing shaders will retain the UV map from the original FBX file - for the diffuse texture (color/albedo) - even if the new shader uses additional textures/UV maps.

    This is the first test I would run. Let me know if this works.
     
    adamfarmer, mantasisg and Mauro like this.
  14. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    Big thanks ! I will try it, sounds very good.

    One thing is that I don't import .fbx into blender, I have the source .blend file, but it doesn't change the sequence you described.
     
  15. dxp_rlong

    dxp_rlong Registered

    Joined:
    Nov 5, 2018
    Messages:
    26
    Likes Received:
    24
    oh, okay, what I suggested is probably more than I would try if you already have your objects in Blender.

    My first thought considering that info is to maybe copy your UVs (using an add-on: CopyPaste UV or Magic UV; both included in 2.79) before you Add rFactor Material, then paste those UVs after you Add rFactor Material. Not sure if that would work, but try it as a test.
     
    adamfarmer and mantasisg like this.
  16. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    Well thats even better, I didn't know it was possible to coppy paste UV maps, that has to be a good reason to move from 2.78a to 2.79 :)

    Edit: I have installed magic UV addon to 2.78, and it is wonderful, really saves me there, thanks.
     
    Last edited: Nov 9, 2018
    Mauro and adamfarmer like this.
  17. Martin Lacina

    Martin Lacina Registered

    Joined:
    Nov 13, 2018
    Messages:
    10
    Likes Received:
    3
    Excuse my very basic question but i tried to import and export several tracks or cars with blender using this script but im still not undersand if this script also generate the scn or gen file during exporting new gmt's. I tried to study the manual which is on the top of this topic but i didnt find anything about it or i could overlooked it. Thank you.
     
  18. mantasisg

    mantasisg Registered

    Joined:
    Aug 17, 2016
    Messages:
    3,106
    Likes Received:
    4,288
    I am here with some problems too, I have not build a lot of confidence to skip gjed yet, but I am having rather good progress. But I am still stuck at basic stage. I have problems with some particular UV channels. My goal is to nail road and terrain before going forward, but i have these problems:

    1. With "real road two diffuse maps" shader my detail seems to always be mapped on wrong map, I tried a lot of things, and still didn't improve. In short multi detail, and specular map seems not to use their maps..

    2. With a "multi layer grass.." shader I have similar problem. I have T1 and T2 diffuse textures tiling well just as I have scaled their maps. But T3 seems not to use its map. T3 seems to use channel of the pattern/specular map, which I have for a single 4k texture (made from satelite images).

    Any ideas where I might be doing wrong ? I have tried so many things, I started thinking that somethign could be not exporting well to fbx, or gjed not reading fbx well ? Or some specific rF2 thing ?
     
  19. dxp_rlong

    dxp_rlong Registered

    Joined:
    Nov 5, 2018
    Messages:
    26
    Likes Received:
    24
    While the scripts can read GEN and SCN files, it doesn't retain the metadata from those files, only the GMT info. Therefore, the scripts don't have that info to write back out to a new GEN or SCN file. As the scripts' title indicate, they are for GMTs only.

    If you are importing existing rFactor content, you will have an existing GEN or SCN. If you are making changes that need to go in the GEN/SCN file, you will need to do that manually in a text editor. Open the existing GEN/SCN in the text editor, make the needed changes, and save the modified GEN/SCN.

    If you do not have an existing GEN/SCN file, open an existing one, keep one of each object type (race surface, wheels, etc.), delete the rest, make changes to the the kept object to suit a prototype of each object type, and copy/paste/modify until you have all objects entered.

    At this time, I'm not aware of any other method.
     
  20. dxp_rlong

    dxp_rlong Registered

    Joined:
    Nov 5, 2018
    Messages:
    26
    Likes Received:
    24
    When importing FBX files into gJED, I found that gJED is extremely picky about what the UV channel/map is named and extremely picky about the sequence of the UV channels. After a lot testing and a lot of searching, to my knowledge this info has never been documented anywhere. gJED was started before S397 took on the development of rF2. I believe the person that wrote gJED did not move to S397.

    Attempting to use FBX with UV channels is the reason I quit using gJED. I was never able to consistently export FBX files from Blender and import them into gJED. Something was always getting messed up with the UVs. Once in a 100 tries I seemed to make gJED happy, but I would do the exact same thing a second time (based on the notes I was taking) and it would fail.

    The only method of using gJED that worked for me was to export GMTs from Blender with the Traveller scripts, then import those GMTs into gJED. In general, this sequence is very much unsupported, since GMTs are not considered exchange format files.
     

Share This Page