import_process.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. .. _doc_import_process:
  2. Import process
  3. ==============
  4. What is it for?
  5. ---------------
  6. One of the most difficult things to get right when creating game engines
  7. is managing the import process. That means, getting the assets that artists
  8. make into the game, in a way that functions optimally.
  9. Artists use certain tools and formats, and programmers would rather have
  10. their data in a different format. This is because artists put their
  11. focus on creating assets with the best quality possible, while
  12. programmers have to make sure they actually run at decent speed (or run
  13. at all), use a certain amount of memory, and don't take ages loading
  14. from disk.
  15. One would think that just writing a converter/importer would be enough,
  16. but this is not all there is to it. The same way programmers iterate
  17. several times over their code, artists keep making changes to their
  18. assets. This generates a bottleneck, because *someone* has to keep
  19. re-importing that artwork, right? And importing assets is often something
  20. that has to be agreed by both parties, as the programmer needs to decide
  21. how the artwork is imported and the artists needs to see how it looks.
  22. The goal to establishing an import process is that both can agree on how
  23. the rules under which the assets are going to be imported the first
  24. time, and the system will apply those rules automatically each time the
  25. asset is re-imported.
  26. Godot does not do the re-import process automatically, though. It gives
  27. the team the option to do it at any time ( a red icon on the top right
  28. of the screen, allows the ability to do it at any desired time).
  29. Does it always work?
  30. --------------------
  31. The aim of the import system is that it works well enough for most
  32. common cases and projects. What is there has been tested and seems to
  33. cover most needs.
  34. However, as mentioned before, this is one of the most difficult areas of
  35. writing a game engine. It may happen often (specially on large projects,
  36. ports, or projects with unusual requirement) that what is provided is
  37. not enough. It's easy to say that the engine is open source and that the
  38. programmer should make their own if they don't like what is there, but
  39. that would be making a huge disservice to the users and not the right
  40. attitude. Because of that, we made sure to provide as many tools and
  41. helpers as possible to support a custom import process, for example:
  42. - Access to the internals of almost all data structures is provided to
  43. the scripting and C++ API, as well as saving and loading in all
  44. supported file formats.
  45. - Some importers (like the 3D asset importer) support scripts to modify
  46. the data being imported.
  47. - Support for creating custom import plugins is also provided, even for
  48. replacing the existing ones.
  49. - If all else fails, Godot supports adding custom resource loaders,
  50. to load data in alternative formats, without intermediate conversion.
  51. Both the import system and the custom tools provided will improve over
  52. time as more use cases are revealed to us.
  53. Importing assets
  54. ----------------
  55. Source asset location
  56. ~~~~~~~~~~~~~~~~~~~~~
  57. To begin, it is a good idea to define where the original assets created
  58. by the artists (before they are imported) will be located. Normally,
  59. Godot does not mind much about the location, but if the project has
  60. several developers, it is a good idea to understand the simple rule for
  61. it to work for everyone.
  62. First of all, it would be really good for this location to **not** be
  63. inside the project path (where engine.cfg is located, or any
  64. sub-folder). Godot expects regular resources in there, and may consider
  65. many of the files used as source art as regular resources. This would
  66. lead to it bundling all of them when the project is exported, something
  67. which is undesired.
  68. Now that it is clear that this location must be outside the project
  69. folder, the rule that Godot uses to reference external assets can be
  70. explained. When an asset is imported, the engine stores a relative path
  71. from the project path to the asset (In windows, this works as long as
  72. they are on the same drive, otherwise an absolute path is stored). This
  73. ensures that the same asset can be re-imported in another computer.
  74. The usual approach to this, when using a VCS such as Git, Mercurial or
  75. Subversion, is to create the project in a subfolder, so both the game's
  76. project files and the source assets can be committed to a same repository.
  77. For example, the repository layout can look like this:
  78. ::
  79. source_assets/sfx/explosion.wav
  80. source_assets/sfx/crash.wav
  81. source_assets/fonts/myfont.ttf
  82. source_assets/translation/strings.csv
  83. source_assets/art/niceart.psd
  84. game/engine.cfg
  85. In the above example, artists, musician, translators, etc. can work in
  86. the source_assets/ folder, then import the assets to the game/ folder.
  87. When the repository is updated, anyone can re-import the assets if they
  88. changed.
  89. Import dialogs
  90. ~~~~~~~~~~~~~~
  91. Godot provides for importing several types of assets, all of them can be
  92. accessed from the import dialog:
  93. .. image:: /img/import.png
  94. Each of the dialogs shares a similar function, a source file (or several
  95. of them) must be provided, as well as a target destination inside the
  96. project folders. Once imported, Godot saves this information as metadata
  97. in the imported asset itself.
  98. .. image:: /img/importdialogs.png
  99. More information about each specific type of asset can be found in
  100. specific sections, such as `Importing Textures <import_textures>`__.
  101. Tracking changes and re-importing
  102. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103. Godot tracks changes in the source assets constantly. If at least one
  104. asset has been found to be modified (md5 is different than when it was
  105. imported), a small red indicator will appear in the top right corner of
  106. the screen.
  107. .. image:: /img/changes.png
  108. From that moment onward, the user can choose to re-import at any given
  109. time by clicking on the red-icon. When this action is done, a dialog
  110. will pop-up showing which resources can be re-imported (all selected
  111. by default).
  112. Accepting that dialog will immediately re-import the resources and
  113. will update any of them currently in use in the editor (like a
  114. texture, model or audio file).
  115. .. image:: /img/changed.png
  116. Manually re-importing
  117. ~~~~~~~~~~~~~~~~~~~~~
  118. The re-import process is automatic, but it may be desired at some point
  119. to change the settings of an already imported file, so it can be
  120. re-imported differently. For this, the Import Settings window is
  121. provided.
  122. .. image:: /img/isettings.png
  123. This screen allows the user to re-open the corresponding import-window
  124. to re-import that asset again, with the ability to change any of the
  125. settings.
  126. .. image:: /img/reimported.png