Skip to content

General Notes and How Tos

aussig edited this page Apr 16, 2021 · 21 revisions

Fonts

  • OpenSceneryX font (for header, 'X', 'Enhanced By…' etc.) is Book Antiqua Bold

Checking colour behind transparent pixels

For textures with transparency, the transparent pixels should not be white or light because this causes a 'halo' effect around objects / forests etc. To check the colour behind transparent pixels in Photoshop:

  1. Load PNG
  2. Layers → Layer Mask → From Transparency
  3. Right-click layer mask and select Disable Layer Mask

Fixing White Halo in PNG Texture

To fix any white halo effect, the colour stored behind all transparent pixels should be set to black.

The first method is longer but it's easier to examine what's going on at each stage:

  1. Load PNG
  2. Duplicate layer
  3. In one of the duplicates, select Layers → Layer Mask → From Transparency (creates a layer mask for that layer)
  4. Create new solid black colour layer, underneath other layers
  5. Merge the non layer-masked layer and the solid black layer (gives a layer with black where transparent was)
  6. Drag layer mask from its layer to the merged layer
  7. Apply layer mask on the merged layer (creates a layer with transparency, but has black pixels beneath the transparent)
  8. Delete the unnecessary layer

The second method is fast and efficient:

  1. Load PNG
  2. Ensure background colour is set to black
  3. Select → Load Selection → Layer 0 Transparency (check Invert)
  4. Edit → Fill… (choose Background Colour and check Preserve Transparency)

Fixing DDS Textures that don't Load in X-Plane®

Some DDS textures, though valid, fail to load in X-Plane® throwing an error. Although xptools ought to work, DDSTool sometimes throws a png load error, so a more reliable method is to use ImageMagick.

  1. Install ImageMagick if not already present.

  2. Use the following ImageMagick command to convert the PNG to DDS:

    $ convert -format dds -define dds:compression=dxt5 <source.png> <destination.dds>

Incorporating changes from SAM Seasons SDK Library

Finding Differences

The SAM Seasons SDK Library is managed in a Git repo, we therefore pull changes into a local repo. However, this library is not fully incorporated into OpenSceneryX, so we pick and choose what we want. It's therefore useful to be able to extract a set of changed files between two of their commits so we can select what we want from those changes. This article gives a very useful command to do this:

$ git diff-tree -r --no-commit-id --name-only <first-commit-SHA> <second-commit-SHA> | xargs tar -rf test.tar

Updating Vegetation Changes

Also, a large segment of this library is based on FlyAgi's original Vegetation library. We can therefore use this to automatically update the vegetation content from SAM SDK. Follow these steps:

  1. Rename containing folder to FlyAgi_Vegetation.
  2. Remove everything not in REGION default sections (there are multiple).
  3. Replace all occurrences of EXPORT_EXCLUDE with EXPORT.
  4. Select all and sort lines unique ascending.
  5. Remove all lines that don't start SAM_Library/SAM_Seasons_SDK/Vegetation, but keep a note of these as they will need updating manually (we can only automatically process stuff that originally appeared in the FlyAgi Vegetation library). These lines will all appear at the top.
  6. Replace all occurrences of SAM_Library/SAM_Seasons_SDK/Vegetation with FlyAgi_Vegetation.
  7. Run update_thirdparty_library.py using FlyAgi_Vegetation as the 3rd party library name.

Notes on SAM SDK Seasons vs OSX Seasons

  • Season_Winterwinter_no_snow
  • Season_Deepwinterwinter_snow
  • Season_Snowytreeswinter_deep_snow

All forests are in forests/default_replacement_1000

The only vegetation objects are:

  • objects/vegetation/acer/3/*
  • objects/vegetation/corylus/1/*
  • objects/vegetation/quercus/16/*
  • objects/vegetation/quercus/17/*

Importing .obj files into Blender

Method 1 - The Best Way Via AC3D

The X-Plane® .obj importer for AC3D is excellent and preserves everything, although AC3D is a commercial product.

To use this method, import to AC3D, then save as native AC3D format, then use the Blender AC3D importer (2.80 branch) to import into Blender.

Once in Blender, follow the Blender Optimising Workflow below.

Method 2 - A Convoluted Way Without Cost Implications

There is no direct way to do this for Blender 2.8, but it can be done via the 3DS file format into Blender 2.7 (the 3DS importer has not yet been updated for Blender 2.8). However, note that this process messes up the axes. To import to 2.7:

  1. Run the xptools command-line utility ObjConverter on the .obj file:
    $ ObjConverter --obj23ds <source_file> <destination_file>
  2. Import the resulting file into Blender 2.7: FileImport3d Studio (.3ds)
  3. Clear all scaling (SPACEBAR then search for clear scale) then apply
  4. Select the object
  5. Go to texture paint mode
  6. Go to Slots in the tools panel
  7. Select Painting ModeImage
  8. Select Open below Canvas Image
  9. Navigate to the PNG or DDS texture

Finding Door Locations for Aircraft

  1. Import into Blender (see above)
  2. Position the 3D cursor at the bottom left hand corner of the door and read off the coordinates of the cursor: N3D CursorX, Y and Z
  3. As the axes are messed up by the import (if method 2 above was used), the X axis value must be changed to be negative and the Y and Z axis values must be swapped over.

Extracting Packed Textures from Blender 2.8.x

Most 3rd party Blender models (e.g. from BlendSwap) have their textures packed into the .blend file.

NOTE 1: Export using XPlane2Blender only works if you have a single texture in the model. If there are multiples, they need to be combined and some UV editing needs to be done.

NOTE 2: Standard material colours are not (currently) exported by XPlane2Blender. So to get a textured model, all faces must be UV textured.

To unpack a texture and use it for exporting an X-Plane® model:

  1. Open the Materials panel.
  2. Select the material that uses the texture, if not already selected.
  3. In the Surface sub-panel, the texture name should be shown in the Color field.
  4. Expand the Color field panel (expansion arrow to the left).
  5. Click Unpack Image (small box icon) and select Write file to current directory (overwrite existing file). This saves the texture in a textures subfolder next to the .blend file.
  6. If the unpacked image contains spaces: Rename the texture file on disk to remove these and then click Open Image (folder icon) which will have replaced the Unpack image icon. It's worth moving the texture up a folder level out of the textures folder at the same time. Browse to the renamed texture and select it.
  7. Check whether the object has a bump map texture too in the Displacement sub-panel and perform the same unpack operation if so.

Workflow for Importing and Optimising an Object via Blender

Initial Import to Blender

  1. Take copy of original and save as object_legacy.obj
  2. Import .obj to AC3D using http://www.inivis.com/forum/showthread.php?t=7032
  3. Save as .ac file
  4. Import .ac to Blender using https://github.com/NikolaiVChr/Blender-AC3D/tree/2.80
  5. Note that X-Plane® named lights are imported as legacy lights (though they are titled with the name), and they will not export correctly. So in the Light data propertiesX-Plane, change the type to Named and set the Name to be the same as the imported light title. To apply to multiple lights, select all lights then right click the field you want to replicate and choose Copy to Selected.
  6. Open the Scene Properties panel.
  7. In the X-Plane sub-panel, add the collection to Root Collections.
  8. Set the exportable collection to be either Instanced Scenery Object for non-animated objects or Scenery Object for animated objects.
  9. Browse to and select the texture in the Default texture field.
  10. Choose other options as required.
  11. Delete any lamps that were used to light the scene and are not part of the object.
  12. Click Export OBJs at the top of the panel.

Centering an Object

  1. Select the primary object in Object mode
  2. Select ObjectSet OriginOrigin to Geometry and choose Bounds Centre in the options panel for Origin to Geometry
  3. Select all objects (in case there are separate lights)
  4. Rotate all objects appropriately (align N/S)
  5. Move the primary object so its origin is at the centre of the axes. If there is just one object, this can be done by setting the X and Z to 0 in Object PropertiesTransformLocation

Reducing Vertices

  1. In Edit mode, select all vertices
  2. MeshClean upMerge by Distance. In the settings panel, Merge Distance = 0.1m works well for most objects, though if there is a lot of fine detail a lower number may be needed.
  3. MeshClean upLimited Dissolve can work well for meshes with lots of curved surfaces or strangely split surfaces. In the settings panel, Delimit = UVs must be selected.
  4. SelectSelect All By TraitInterior Faces then delete selected
  5. Import can can mess up UV mapping, so carefully review object and re-map if required (the Magic UV Plugin provides copy/paste UV, which is very useful)
  6. It can also mess up normals, most problems are fixed by MeshNormalsRecalculate Outside (SHIFT-N). A visual check can be done by showing the Face Orientation overlay in the Overlays settings. Faces are coloured by their normals.
  7. If necessary, add a Decimate modifier to the object and play with the various options and levels

Exporting to X-Plane®

  1. Set the appropriate collection as Exportable in Scene PropertiesX-Plane
  2. Assign texture(s) in the exported Collection
  3. Set export type to Instanced Scenery Object unless it has animation, in which case use Scenery Object
  4. Create LODs if required, with LOD distance levels

LODs

  1. Specify the number of LODS in Scene PropertiesX-Plane.
  2. For each LOD, define its Near and Far distance in metres.
  3. (Optional) For sensible organisation of the model, best create a Collection for each LOD and place these collections inside the master exported Collection. Organise objects into the appropriate Collection based on the complexity of the object.
  4. For each object, in Object PropertiesX-Plane, click Override LODs and choose the LOD(s) to place the object in. More complex versions should go in lower-numbered LODs.

General Blender Editing Tricks

  1. To extrude some faces, but keeping the original and effectively "solidifying" the extrusion: Select the Faces, Shift+D (duplicate), Esc (cancel), E (extrude). Can also select the type of extrusion required in the menu (Extrude Region, Extrude Along Normals, Extrude Individual)