Skip to content

Commit 30a035d

Browse files
added copilot instructions
1 parent 1544b17 commit 30a035d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/copilot-instructions.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# X-PlaneSceneryLibrary — Agent Instructions
2+
3+
Goal: Get productive fast in this C++20 library that parses X‑Plane scenery (library.txt, obj8) via a virtual file system and region/season selection.
4+
5+
## Big picture
6+
- Single library target XPSceneryLib (no app). Code in `xplib/`, wired by `cmake/xplib.cmake`.
7+
- Namespaces: `XPLibrary` (VFS, regions, seasons, parsing) and `XPAsset` (asset models like obj8).
8+
- Flow: `VirtualFileSystem::LoadFileSystem(xpRoot, currentPackage, customPacks)` → crawl real assets and parse all `library.txt` (custom packs in priority + default scenery). Commands build `Definition`s keyed by virtual paths, with `RegionalDefinitions` and weighted `DefinitionOptions`.
9+
10+
## Where to look/edit
11+
- VFS and parser: `xplib/include/XPLibrarySystem.h`, `xplib/src/XPLibrarySystem.cpp` (commands: EXPORT, EXPORT_BACKUP, EXPORT_RATIO, EXPORT_EXCLUDE, REGION_*, EXPORT_*_SEASON).
12+
- Path/selection model: `xplib/include/XPLibraryPath.h` (DefinitionPath, DefinitionOptions, Region, RegionalDefinitions, Definition; seasons like `'s','w','f','p','d'`).
13+
- Asset parsing: `xplib/include/XPObj.h`, `xplib/src/XPObj.cpp` (vertices/indices/draw calls; texture directives; uses `XPLayerGroups`).
14+
- Layer groups: `xplib/include/XPLayerGroups.h|.cpp` (Resolve group+offset ↔ vertical order).
15+
- Tokenization utils: `xplib/include/TextUtils.h`, `xplib/src/TextUtils.cpp`.
16+
17+
## Conventions and behaviors
18+
- C++20; MSVC-friendly flags (`/utf-8`, UNICODE, `_CRT_SECURE_NO_WARNINGS`). No in‑source builds (CMake errors out).
19+
- Includes use repo-root prefix: `<xplib/include/...>`.
20+
- Region selection uses bbox check + optional conditions; region map lives inside `VirtualFileSystem`.
21+
- Seasons: single-char tags; selection falls back: seasonal → default → backup.
22+
- Weighted choice: `DefinitionOptions::AddOption(path, ratio)` and `GetRandomOption()`.
23+
- Real asset ingestion: scanned extensions (from `XPLibrarySystem.cpp`) → `.lin, .pol, .str, .ter, .net, .obj, .agb, .ags, .agp, .bch, .fac, .for`. To add more, update the `vctXPExtensions` list.
24+
- Textures: `.dds`/`.png` are commonly referenced by assets (e.g., OBJ, POL) but are not ingested as primary assets.
25+
26+
## Build and dev
27+
- Windows one-shot: run `SetupProject.bat` (creates `build/`, logs to `CMake_Gen.log`, generates VS solution).
28+
- Manual: out-of-source CMake; VS generator or Ninja (see `CMakeSettings.json``out/build/x64-{Config}`).
29+
- Pre-build (Windows/MSVC): `scripts/increment_xplib_build.py` bumps `xplib/config/resource.h` (needs Python 3 on PATH).
30+
- Outputs (top level): `bin/{Config}`; tests are present but disabled in `CMakeLists.txt`.
31+
32+
## Minimal usage example
33+
```cpp
34+
XPLibrary::VirtualFileSystem vfs;
35+
vfs.LoadFileSystem(xpRoot, currentPkg, customPacks);
36+
// auto def = vfs.GetDefinition("lib/objects/house.obj");
37+
// auto real = def.GetPath(/* vfs regions */, 39.85, -104.67, XPLibrary::SEASON_SUMMER);
38+
```
39+
40+
## Extending safely
41+
- New library.txt command: add a case in `XPLibrarySystem.cpp`; tokenize with `TextUtils`; use `DefinitionPath::SetPath`, `GetRegionalDefinitionIdx`, `DefinitionOptions`.
42+
- New asset type: derive from `XPAsset::Asset`, add a parser next to `XPObj.cpp`.
43+
- Maintain layer ordering via `XPLayerGroups::Resolve(group, offset)`.
44+
45+
## Integration
46+
- vcpkg toolchain auto-detected at `dependency/vcpkg/...` if present; optional.
47+
- `XP_SCENERY_LIB_INSTALL` enables install/export (`XPSceneryLib::XPSceneryLib`).
48+
49+
## Formats and references
50+
- Official X‑Plane format specs relevant to supported extensions:
51+
- NET (.net): https://developer.x-plane.com/article/vector-network-net-file-format-specification/
52+
- LIBRARY.TXT: https://developer.x-plane.com/article/library-library-txt-file-format-specification/
53+
- LIN (.lin): https://developer.x-plane.com/article/painted-line-lin-file-format-specification/
54+
- TER (.ter): https://developer.x-plane.com/article/terrain-type-ter-file-format-specification/
55+
- FAC (.fac): https://developer.x-plane.com/article/x-plane-10-facade-fac-file-format-specification/
56+
- POL (.pol): https://developer.x-plane.com/article/draped-polygon-polfac-file-format-specification/
57+
- STR (.str): https://developer.x-plane.com/article/object-string-str-file-format-specification/
58+
- AGS (.ags): https://developer.x-plane.com/article/autogen-string-ags-file-format-specification/
59+
- AGB (.agb): https://developer.x-plane.com/article/autogen-block-agb-file-format-specification/
60+
- AGP (.agp): https://developer.x-plane.com/article/x-plane-10-autogen-scenery-file-format/
61+
- FOR (.for): https://developer.x-plane.com/article/forest-for-file-format-specification/
62+
63+
---

0 commit comments

Comments
 (0)