An open API service indexing awesome lists of open source software.

https://github.com/johnnyjf10/tgabuilder

Texture Panel Building tool for TRLE
https://github.com/johnnyjf10/tgabuilder

texture-atlas texture-editor texture-extrator texture-tool tga tomb-raider tombraider trle

Last synced: about 2 months ago
JSON representation

Texture Panel Building tool for TRLE

Awesome Lists containing this project

README

          

# TgaBuilder
### **Texture Panel Building Tool for TRLE**

[Latest Releases](https://github.com/JohnnyJF10/TgaBuilder/releases) | [Github Page](https://johnnyjf10.github.io/TgaBuilder/)

![LatestReleaseBuildStatus](https://github.com/JohnnyJF10/TgaBuilder/actions/workflows/dotnet-release.yml/badge.svg)
![Github All Releases](https://img.shields.io/github/downloads/JohnnyJF10/TgaBuilder/total.svg)
![CodeFactor Review](https://www.codefactor.io/Content/badges/AMinus.svg)

![Logo](Screenshots/TgaBuilder_logo.png)

## Description

![Overview](Screenshots/Overview.png)
TgaBuilder is a Texture Panel Building tool for TRLE, which is intended to facilitate the process of texture panel creation. The tool is inspired by TBuilder by IceBerg but programmed from scratch in .NET, C# WPF for Windows and Avalonia UI (cross-platform, experimental).

If you have already worked with TBuilder in the past, you should get familiar with TgaBuilder very quickly. It should cover most of the features TBuilder also has and introduces a few things more, most prominently:
- Texture Panel Panning and Zooming
- Undo / Redo
- Window Resizable
- Extended dimensioning with panel hights up to 128 pages, panel widths up to 16 pages
- Better support for 128x128 or 256x256 pix texture sets
- Batch Loader to create texture panels from multiple single texture files at once
- Imported texture repacking to remove TE compiled atlas padding
- and others…

### New in Version 2.2.0
![SmoothTransitions](Screenshots/TransitionHelperButton.png)

- New **Transition Helper Windows** to generate blend-ready transition tiles directly from selections.

- **Smooth Transition Helper** for soft directional transitions with adjustable **Pivot** and **Hardness**.

- **Brick Transition Helper** for marker-based brick/background transitions based on a watershed algorithm with **Pivot**, **Reverse Pivot**, **Marker Radius**, optional **Slice Corners**, and expandable label-map preview.

## Installation
Move over to [GitHub Releases](https://github.com/JohnnyJF10/TgaBuilder/releases).

**Windows**:

For the latest releases there are two tool versions per release: The *.NET 6.0* version of the tool and the *.NET 8.0* version of the tool.
- Download the ***.NET 6.0*** version of the tool (TgaBuilder-dotnet6), if you already have Tomb Editor Version 1.9 installed on your system and you do not wish to install another .NET runtime (as Tomb Editor Version 1.9 is using *.NET 6.0* runtime as well)
- Download the ***.NET 8.0*** version of the tool (TgaBuilder-dotnet8), if you have the *.NET 8.0* runtime installed or do not mind to install it. This version has the slightly better performance.

Extract the files and start *TgaBuilder.exe*.

**Linux**:

There is also an experimental cross-platform version of the tool based on Avalonia UI instead of WPF. It has been tested only on Linux Mint (and Windows) currently.
Please note that this version is highly experimental and contains bugs with zoom panel and some controls. They will be fixed in future when there is realy need for TRLE building tools on other platforms than Windows. For any productive purposes, use the regular versions of TgaBuilder for Windows.

To run the Avalonia UI version on Linux, move ober to the directory where you extracted the files and run:

`dotnet TgaBuilderAvaloniaUi.dll`

### Requirements
- Windows 10/11
- 64-bit architecture
- *.NET 6* or *.NET 8* runtime installed (with Tomb Editor Version 1.9, you have the *.NET 6* runtime already installed)

Please note that, as a .net WPF tool, TgaBuilder has significantly higher system resource requirements, particularly for RAM, than TBuilder, which was written in Delphi. If you are still satisfied using TBuilder, please continue using it. TgaBuilder is not intended as a substitute for it.

For the experimental Avalonia UI version for Linux:
- *.NET 8* runtime on the target device.

## Usage

### Title Bar

![TitleBar](Screenshots/TitleBar.png)

#### Source Loading

- Open image files as source texture panel
_Supported formats:_ **TGA, DDS, PNG, BMP, JPG, JPEG, PSD** (`Ctrl + E`)
- ... or simply **drop** a supported image file on source panel.
- Reopen recently used source image files
- Reload the current file in case of changes to load settings (Import Tab) or file changes
- Open previous file in current folder
- Open next file in current folder

#### Undo / Redo

- Undo: `Ctrl + Z`
- Redo: `Ctrl + Y`

#### Destination Loading / Saving

- Create a new texture panel: `Ctrl + N`
- Open image files as destination texture panel
_Supported formats:_ **TGA, DDS, PNG, BMP, JPG, JPEG, PSD** (`Ctrl + D`)
- ... or simply **drop** a supported image file on destination panel.
- Reopen recently used destination image files
- Save the destination texture
_Supported formats:_ **TGA, DDS, PNG, BMP, JPG, JPEG** (`Ctrl + S`)
- Save to a specified file
_Formats:_ **TGA, DDS, PNG, BMP, JPG, JPEG** (`Ctrl + Shift + S`)

### Source Panel (Left)

- **Left click** a tile: copy into selection
- **Left click + drag**: copy area into selection
- **Right click** a tile: preview UV rotate (river rotate)
- **Right click + drag**: preview range-based animation of `AnimRange`
- **Left click + Alt + drag**: copy ignoring grid
- **Left click + Ctrl + drag**: move panel
- **Mouse wheel**: scroll vertically
- **Mouse wheel + Ctrl**: zoom in/out

### Destination Panel (Rigth)

#### Picking Mode

- **Left click**: copy into selection or apply transformation
- **Left click + drag**: copy area into selection
- **Right click**: preview UV rotate
- **Right click + drag**: preview animation range
- **Middle click**: move to Placing Mode directly

#### Placing Mode

- **Left click**: place selected tile and return to picking
- **Right click**: return to picking without placing

#### General Controls

- **Left click + Ctrl + drag**: move panel
- **Mouse wheel**: scroll vertically
- **Mouse wheel + Ctrl**: zoom
- **Mouse wheel + Shift**: change picker size

### Selection Area

![SelectionArea](Screenshots/Selection.png)
- With a click on the **Preview Image** you can manually switch to the **Placing Mode** on the Destination Panel
- Buttons to copy entire contents from Source to Destination panels or vice versa
- Fill selection with chosen color
- Copy selection to clipboard (`Ctrl + C`)
- Paste clipboard into selection (`Ctrl + V`)
- Auto-copy new selections to clipboard
- Auto-paste clipboard into selection when it has new image data
- Open **Smooth Transition Helper** and **Brick Transition Helper** from the center action buttons to combine two selections and generate transition results quickly

### Transition Helpers (New in 2.2.0)

The transition helper tools open in separate windows and allow you to build transition textures from two input selections.

#### Smooth Transition Helper

- Load two source selections and preview the blended result in real time
- Choose transition direction: **Top, Right, Bottom, Left, Diagonal Top-Left, Diagonal Top-Right**
- Fine-tune blend behavior with:
- **Hardness** (blend sharpness)
- **Pivot** (transition center)
- Press **OK** to apply the generated result

#### Brick Transition Helper

- Load two source selections as **Bricks** and **Background**
- Generate structured transitions with the same transition-direction controls
- Tune the result with:
- **Pivot** and **Reverse Pivot**
- **Marker Radius**
- **Slice Corners** toggle
- Optional expandable **Label Map** preview for debugging marker regions
- Press **OK** to apply the generated result

### AnimationArea

![Animation Area](Screenshots/Animation.png)
- Set animation speed
- Start / stop animation
- Close animation preview

### Import Tab (Source Panel)

![Import Tab](Screenshots/TabImport.png)

From left to rigth:
- Import atlas from Classic TR levels
_Supports:_ **TR1–TRC, TRLE, TRNG, TEN** (`Ctrl + Q`)
- Enable remapping for imports (removes padding in TE-built atlases)
![Repacking](Screenshots/Repacking.png)
- Set horizontal page count (1, 2, 4, 8, 16 pages)
![PageSizeImport](Screenshots/PageSizeImport.png)
- Open Batch Loader (`Ctrl + W`)

Please use Imports carefully and conscientiously when building own custom levels.
Specifically, clarify with the creator whether you are authorised to use custom assets.
If in doubt, use assets that are guaranteed to be acceptable for use in your own custom levels instead.
Please also note that this tool is licensed under the MIT licence.

### Batch File Loader

![Batch Loader](Screenshots/BatchLoader.png)
- Import multiple image files from folder
_Supported formats:_ **TGA, DDS, PNG, BMP, JPG, JPEG**
- Select or reopen folder
- ... or simply **drop** a set of supported image files on preview panel.
- Set Range:
- **First Texture Index**
- **Number of Textures**
- Define square resize size for textures

### Grid Tab (Source Panel)

![Offset Tab](Screenshots/TabGrid.png)

From left to rigth:
- Set **X offset**
- Set **Y offset**
- Reset offset
- Toggle grid on/off
- Change layout

### Format Tab (Source and Destination Panel)

This tab allows you to modify the format of the destination texture panel. TgaBuilder now fully supports the opening, modification and writing of both **24-bit** and **32-bit** pixel formats.

![Format Tab](Screenshots/TabFormat.png)

From left to rigth:
- BPP toggle
- Eyedropper to set color to replace
- Selected color to replace
- Replace selected color with **magenta** or **transparency**
- Auto-apply magenta or transparency replacement for new selections

The BPP toggle will be set automatically depending on the input after loading. You can then set it manually if you wish. If you select **RGB 24 BPP**, magenta will be used for transparent parts. If you select **BGRA 32 BPP**, you will have a real alpha channel. Switching between the two settings will set the pixel values appropriately (e.g. alpha = 0 areas will be converted to magenta areas, and so on).

![Format](Screenshots/Format.png)

Switching from **BGRA 32 BPP** to **RGB 24 BPP** will set the magenta colour correctly, but since pixels with an alpha value other than **0** or **255** are not supported by **RGB 24 BPP**, information will be lost, possibly making the switching step irreversible.

### View Tab (Source and Destination Panel)

![View Tab](Screenshots/TabView.png)

From left to rigth:
- Fit panel **width** to viewport
- Fit panel **height** to viewport
- Set zoom to **100%**

### Placing Tab (Destination Panel)

From left to rigth:

![Placing Tab](Screenshots/TabPlacing.png)

From left to rigth:
- Enable **Resize to Picker** mode (resize selection to destination picker size)
- Enable **Continuously Placing** mode (does not switch back to Picking mode automatically after placing)
- Enable **Swap and Place** mode (put replaced tile into selection)
- Enable transparent overlay (do not draw magenta/alpha 0 to destination)
![TransparentOverlay](Screenshots/OverlayTransparent.png)
- Set **Opacity** for placed tile
![Opacity](Screenshots/Opacity.png)

### Size Tab (Destination Panel)

From left to rigth:

![Size Tab](Screenshots/TabSize.png)
- Set destination panel **height** (in pages, max 128 pages)
- Set destination panel **width** (in pages, possible values 1, 2, 4, 8 or 16 pages)
- Enable texture **rearranging during width changes**
![TextureRearanging](Screenshots/ResizeSorted.png)

### Mode Tab (Destination Panel)

Same functions as in TBuilder.
From left to rigth:

![Mode Tab](Screenshots/TabMode.png)
- Standard tile placing
- Rotate tile
- Mirror tile **horizontally**
- Mirror tile **vertically**
- **Tile Rally mode**: move one tile and shift all tiles inbetween
- **Swap Tile mode**: swap two tiles

### Keyboard Shortcuts
| Key Combination | Description |
|--------------------|-----------------------------------------------------------|
| Ctrl + A | Create a new texture panel |
| Ctrl + C | Copy selection to clipboard |
| Ctrl + V | Paste from clipboard to selection |
| Ctrl + Z | Undo |
| Ctrl + Y | Redo |
| Ctrl + S | Save destination texture panel |
| Ctrl + Shift + S | Save destination texture panel to new / other file |
| Ctrl + E | Open source texture panel |
| Ctrl + D | Open destination texture panel |
| Ctrl + Q | Import from TR Level |
| Ctrl + W | Open batch loader |

## Limitations

- The height of any bitmap/texture panel handled by this tool is currently capped at **32,768 px** or **128 pages** (~256 px length per page). This limitation is required to avoid issues with the .NET WPF Bitmap containers.
- The height is always a **multiple of 256 px**, the standard TR page width, to ensure divisibility by picker sizes.
- Current supported destination texture panel widths: **256, 512, 1024, 2048, 4096 px** (corresponding to 1, 2, 4, 8, and 16 pages).
- Current supported picker sizes: **8, 16, 32, 64, 128, 256 px**
- Image files that do not meet these requirements will be **automatically expanded or cropped**. But you will always be able to open them.

## License
This project is licensed under the MIT License.

### Third-Party Libraries

For WPFZoomPanel I did some custom modifications and adapted it to .net 8. This modified project is included in this reporsitory as well.

| Package | Version | Source | License | Project URL |
|----------------------------------|---------|-------------|-----------------------|----------------------------------------------------------------------|
| WPFZoomPanel | - | GitHub | MIT | [GitHub](https://github.com/Moravuscz/WPFZoomPanel) |
| Pfim | 0.11.3 | NuGet | MIT | [GitHub](https://github.com/nickbabcock/Pfim) |
| bzPSD | 0.1.0 | NuGet | BSD-3-Clause license | [GitHub](https://github.com/DsonKing/System.Drawing.PSD) |
| WPF UI | 4.0.3 | NuGet | MIT | [GitHub](https://github.com/lepoco/wpfui) |
| Microsoft Dependency Injection | 9.0.6 | NuGet | MIT | [Microsoft](https://dotnet.microsoft.com/en-us/) |
| SharpZipLib | 1.4.2 | NuGet | MIT | [GitHub](https://github.com/icsharpcode/SharpZipLib) |
| *For the Avalonia UI Port:* | | | | |
| Avalonia UI | 11.3.7 | Avalonia UI | MIT | [Avalonia UI](https://avaloniaui.net/) |
| PanAndZoom | 11.3.6 | NuGet | MIT | [GitHub](https://github.com/wieslawsoltes/PanAndZoom) |
| Notification.Avalonia | 2.1.0 | NuGet | MIT | [GitHub](https://github.com/AvaloniaCommunity/Notification.Avalonia) |

I would like to express my gratitude to the [TombEditor](https://github.com/MontyTRC89/Tomb-Editor) team and the authors of [TRosettaStone](http://xproger.info/projects/OpenLara/trs.html). Their imppressive public contributions immensely helped me understanding the TR level file format.

## Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an [issue](https://github.com/JohnnyJF10/TgaBuilder/issues).
If you want to contribute code, feel free to fork the repository and create a pull request.

## Support
If you have any issues, please open a [GitHub Issue](https://github.com/JohnnyJF10/TgaBuilder/issues).