Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrain editor now edits *.tobj files in place #3199

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Nov 17, 2024

The 'logs/editor_out.log' file is history. The game now edits *.tobj files directly, but only if the terrain is unzipped in a directory (= a project). Exiting terrain editor at a zipped terrain will show a console/chatbox warning "cannot export - not a project".

Known issues:

  • preloaded actors rotations are off
  • [FIXED] procedural road bridge types are not preserved.
  • The "Terrain editor mode" doesn't inform about projects. TBD: add a button to import zipped terrain as project (internals already exist, only UI needs to be updated).

Notes to code reviewers:

  • I did a roundup of file format handlers -> a lot of find&replace hapenned, see individual commit descriptions.
  • For convenience this branch builds on top of Script updates and fixes #3197 - when that is merged, it will become much leaner.

changes made:
* added `*_utils`  namespaces (new convention for includes)
* unified style of scripts: using global variables and functions instead of classes.
* scripts auto-formatted by script_editor.as
This reverts a line from caf88e5 - I wanted to be purist and force users to do `engity.getSubEntities(0).setMaterial()` but since OGRE has this convenience method and the skeletal posing example already uses it, let's just roll with it.
Returns `array<Ogre::MovableObjects@>` in no particular order; works using bounding boxes so large/generated meshes like roads get matched all the time.

comes with example script.
drawSelectableFileList() now Creates a child window with dynamic height (but clamped to hardcoded max value).
		const int MAX_CHILD_HEIGHT = 300;
		const int CHILD_WIDTH = 600;
Also fixed typos in `get/setCameraOrientation()` function bindings - parameter was declared as `vector3`, should have been `quaternion`.
Also fixed weird binding of global `game` object, preventing use of AngelScript delegates. Fixed to bind as non-counting reference because that's the sensible choice.
Consistency++; Until now some document objects were named `^Document` (RigDef, GenericDocument), some `^File` (Odef, TObj) and some `^Def` (skin).

Principal changes are in file 'ForwardDeclarations.h' - all document types and smart pointer typedefs are now here. The rest is pretty much all find&replace.
The 'logs/editor_out.log' file is history. The game now edits *.tobj files directly, but only if the terrain is unzipped in a directory (= a project). Exiting terrain editor at a zipped terrain will show a console warning "cannot export - not a project".

Known issues:
* preloaded actors rotations are off
* procedural road bridge types are not preserved.
* The "Terrain editor mode" doesn't inform about projects. TBD: add a button to import zipped terrain as project (internals already exist, only UI needs to be updated).
In this mode, the road will automatically switch between solid base and bridge depending on current height above ground.
Internally, this mode already existed, but was only activated when importing legacy blocky-road into procedural road.

This fixes the new TOBJ export from terrain editor.
When loaded with a terrain containing races, it detects them and generates race-def files for each of them, also modifying the .terrn2 file.
These files can't be processed yet, but they contain all info normally present in the race definition scripts.
Example from Auriga:
```
; ~~ New 'race-def' format (file extension: .race). ~~
; Each race file specifies a single race
; In .terrn2 file, list the race files under new section [Races]
; Filenames must include extension and end with = (like scripts do)
; Race system supports alternating paths!
; Checkpoint format: checkpointNum(1+), altpathNum(1+), x, y, z, rotX, rotY, rotZ, objName(override, optional)
; By convention, the checkpoint meshes are oriented sideways (facing X axis)

race_name 1 kilometer drag
race_laps 0.000000
race_checkpoint_object 31-checkpoint
race_start_object 31-checkpoint
race_finish_object 31-checkpoint

begin_checkpoints
1.000000,1.000000,1010.000000,9.000000,505.000000,0.000000,90.000000,0.000000
2.000000,1.000000,10.000000,9.000000,505.000000,0.000000,90.000000,0.000000
end_checkpoints
```
Since adding INT/FLOAT and removing NUMBER token types from GenericDocument, all copypasted viewers/editors in scripts are broken.
This is 1st step to creating an unified viewer/editor as include, but not yet there.
Implements `GenericDocEditor` which doesn't edit yet but has highlight+selection and can be shared by scripts.
Currently only 'example_terrn2_raceConverter.as' was updated to use it.
* 'terrain_project_importer.as' - Launched automatically with terrain-editor mode with a read-only (ZIPped) terrain, provides info and import controls.
* 'terrain_editor.as' - Launched automatically with terrain-editor mode with a terrain project, provides mouse+gizmo editing controls and hints.

KNOWN ISSUE: main menu doesn't appear after unloading terrain from script...
How I could trigger it:
1. enter simple test Terrain (zipped)
2. load 'script_editor.as' script.
3. enter terrain-editor mode --> game launches 'terrain_project_importer.as' --> boom.

May be related: There are 2 messages "cannot run function with ID -1" that seem to appear when the terrain import script starts, I dont know where they come from.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant