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

👼Script: OGRE bindings for editing scene, meshes and textures - with examples #3030

Merged
merged 37 commits into from
Mar 14, 2024

Commits on Mar 11, 2024

  1. Configuration menu
    Copy the full SHA
    9ead066 View commit details
    Browse the repository at this point in the history
  2. AngelScript: added OGRE Node+SceneNode bindings.

    AngelScript API changes:
    + `ImGuiCond` enum
    + `ImGui::SetNextItemOpen()` func
    + `Ogre::Node` object
    + `Ogre::SceneNode` object
    
    Code changes:
    * CReadonlyScriptDictView moved to ScriptUtils.h
    * created CReadonlyScriptArrayView in ScriptUtils.h
    
    ogre_demo.as changes:
    * codechange: added class OgreInspector, draw funcs made methods.
    * ability to traverse scene node graph (using scenemanager.getRootSceneNode() and scenenode.getChildren())
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    e138464 View commit details
    Browse the repository at this point in the history
  3. AngelScript: added Ogre::MovableObject bindings, updated 'ogre_demo…

    ….as'
    
    New script API:
    + `Ogre::MovableObject`
    + `Ogre::MovableObjectArray` - returned by `SceneNode::getAttachedObjects()`
    
    Codechanges:
    * CReadonlyScriptDictView - removed Get() funcs - useless here, this object stores only 1 predetermined object type.
    * CReadonlyScriptDictView + CReadonlyScriptArrayView: removed static const char* VALUE_DECL; using just a parameter to Register*()
    * OgreAngelscript.cpp: major tidy-up, new funcs use same style as old funcs, helpers moved among older helpers, base class regs extracted to `register*Base()` methods because the duplicity was growing and growing.
    * ogre_demo.as - added MovableObject listing under SceneNodes, added checkboxes to set Visibility and CastShadows of the movables.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    7ddc31f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8c829b8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    477844b View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e05fdd0 View commit details
    Browse the repository at this point in the history
  7. AngelScript: added Ogre::AnimationState/Ogre::AnimationStateSet

    Updated ogre_demo.as to use it - look for the 'Character#0' scene node.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    45f8bca View commit details
    Browse the repository at this point in the history
  8. AngelScript: added game.getSceneManager() and ton of OGRE funcs.

    'ogre_demo.as' now has "Pose Demo" panel which loads up a character and draws anim controls.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    3d57d9a View commit details
    Browse the repository at this point in the history
  9. Codechange: finishing touches in 'OgreAngelscript.cpp'

    * added `assert(r>=0)` where missing.
    * `TexturePtr` and `TextureManager` regs unified with the others
    * function `registerOgreTextureManager()` separated out from `registerOgreTexture()`
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    c615620 View commit details
    Browse the repository at this point in the history
  10. Doxygen docs: added all OGRE-AngelScript objects.

    Added dummy namespace `AngelOgre` to avoid mixing up OGRE-AngelScript exports with actual C++ objects.
    
    * Doxyfile.conf.in upgraded using `doxygen -u`
    * MainPage.h - fixed warnings about "unknown command \My \Rigs" etc... unescaped slashes :)
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    fbdeee7 View commit details
    Browse the repository at this point in the history
  11. 👼 Script: raw OGRE Overlay bindings (demo)

    New script API:
    * `class Ogre::OverlayManager`
    * `class Ogre::Overlay`
    * `class Ogre::OverlayElement`
    * `enum Ogre::GuiMetricsMode`
    * `enum Ogre::GuiHorizontalAlignment`
    
    New example script: example_ogre_overlays.as - a test script I used while developing, creates 1 "Panel" overlay with material "tracks/wheelface" and some GUI controls.
    
    # Conflicts:
    #	source/main/scripting/bindings/OgreAngelscript.cpp
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    021185a View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    bfab13d View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    4e6bfcc View commit details
    Browse the repository at this point in the history
  14. overlay_editor.as: added buttons to destroy overlay/element.

    multiple fixes: clashing name of new element, missing PushID in lists which broke buttons, typos in detail tooltips.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    2647411 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    ce1b8c8 View commit details
    Browse the repository at this point in the history
  16. Terrain: Grouped scene nodes together for nicer inspector view.

    This has no effect on rendering, it just helps users to diagnose the scene graph.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    05b1c91 View commit details
    Browse the repository at this point in the history
  17. Actors: grouped/renamed scene nodes for nicer inspector view.

    Prettier and more uniform object names - Helper func `ActorSpawner::ComposeName()` is now smarter, outputs nicer IDs and is used even more.
    
    This has no effect on rendering, it just helps users to diagnose the scene graph using the inspector script.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    befcbb8 View commit details
    Browse the repository at this point in the history
  18. 👼Script: Ogre::ManualObject API - create manual mesh

    2 new example scripts.
    
    New script API:
    * `enum Ogre::RenderOperation`
    * `class Ogre::ManualObject` REF | NOCOUNT object type. This is castable to MovableObject. Official tutorial for Ogre::ManualObject: https://ogrecave.github.io/ogre/api/latest/manual-mesh-creation.html
    * Functions in OGRE SceneManager: `createManualObject()`, `getManualObject()`, `destroyManualObject()`
    * Extra feature: function `TerrainClass::getHeightAt()` for the MeshedConcrete example to work.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    702355d View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    4bdee41 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    b925a16 View commit details
    Browse the repository at this point in the history
  21. 👼Script: Added texture blitting API 🎆

    NOTE: the example script only blits to topmost mipmap, so to see the effect, you must be close to the object! This will be improved.
    
    New Angelscript API:
    * `game.loadImageResource(filename, rg)` - see GameScript.cpp & GameScriptAngelscript.cpp
    * `ImDrawList::AddImage()` - see ImGuiAngelscript.cpp
    * Ogre objects: `box; PixelBox; HardwarePixelBufferSharedPtr`, Texture functions `getBuffer(); getNumMipmaps()`
    
    Example code:
    ```
        // src image
        Ogre::Image gSrcImg = game.loadImageResource("sign-roadnarrows.dds", "TexturesRG");
        // dst texture
        Ogre::TexturePtr gDstTex = Ogre::TextureManager::getSingleton().load("character.dds", "TexturesRG");
        // let the MAGIC happen
        Ogre::HardwarePixelBufferPtr pixbuf = gDstTex.getBuffer(/*cubemap face index:*/0, /*mipmap:*/0);
        Ogre::PixelBox srcPixbox = gSrcImg.getPixelBox(0,0); // getPixelBox(cubemapFaceIndex, mipmapIndex);
        box gDstBox; // where you want to put it.
        pixbuf.blitFromMemory(srcPixbox, gDstBox);
    ```
    
    New/updated scripts:
    * new 'example_ogre_textureBlitting.as' - draws UI using GridViewer and lets user mouse-draw destination pixelbox. Hardcoded to use character.dds as destination.
    * 'gridviewer_utils.as' - added 'zoomMin' config, new func `screenToLocalPos()` to enable mouse-interactions with the viewed data.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    4e61b82 View commit details
    Browse the repository at this point in the history
  22. OTC fileformat: fixed typo causing early crash when 'normalheight' is…

    … empty.
    
    The OGRE version we use (11.6) crashes anyway when normalheight parameter is blank, although for OGRE13+ it's supposed to be okay (regarding to Paroj @ GitterChat)
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    a6506a8 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    5cb624e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    b8925c9 View commit details
    Browse the repository at this point in the history
  25. 👼Script: 'gridviewer_utils.as' - renamed func. for consistency.

    There are now 2 funcs:
    * `localToScreenPos()` - originally `projectPos()`, renamed to align with the below.
    * `screenToLocalPos()` - added recently to make texture-blitting example work.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    6b1dcb1 View commit details
    Browse the repository at this point in the history
  26. 👼Script: added reading verts and texcoords from Mesh.

    Task 3/3 from RigsOfRods#3030.
    This means I can start writing a script to batch together terrain objects (meshes+textures) for performance - especially for Community Map
    
    New script API:
    * objects: `MeshPtr, SubMesh, MeshManager`
    * to get vert positions, use "array<vector3>@ __getVertexPositions()" on SubMesh
    * ditto for vert texcoords, note the extra index param because mesh can have more than 1 texcoord layer: "array<vector2>@ __getVertexTexcoords(uint index)"
    
    See example script "example_ogre_vertexData.as"
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    c762091 View commit details
    Browse the repository at this point in the history
  27. 👼Script: 'script_editor.as': fixed folded regions stuck at orig. len.

    If you loaded a document with regions, their recorded character count would be stuck on the original value, so if you added/removed characters the folding would break. This was fixed.
    
    There is still a bug - orphan regions don't resurface as expected.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    15ae6f4 View commit details
    Browse the repository at this point in the history
  28. 👼Script: 'script_editor.as': Fixed folded regions missing in execution.

    Problem: The `restoreRegionFoldStates()` didn't actually modify buffer, just restored the flag.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    97a9aa1 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    4be7d50 View commit details
    Browse the repository at this point in the history
  30. 👼Script: ✨ OGRE Mesh/Material bindings + example

    This introduces 'example_ogre_terrnBatcher.as' which shows how Mesh/Material API works and will evolve into a production tool. this will conclude RigsOfRods#3030.
    
    THE INTENDED USE of the future completed TERRN BATCHER:
    1. You start with a list of OGRE SceneNodes - see green box.
    2. you pick those you want to batch together - see orange box.
    3. [WIP] The tool generates one mesh which contains all those picked (keeping position, scale and rotation) and cover them in single material containing all the textures.
    4. [TBD] The tool remembers what batches were done as a 'schedule', and allows saving/loading the schedule as file. Modders can share and improve the schedules.
    5. [TBD] Modders can launch the tool directly from .terrn2 and auto-execute a schedule on map load.
    6. Profit
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    0dba980 View commit details
    Browse the repository at this point in the history
  31. 👼Script: 'script_editor.as' fixed text sliding in folded regions

    Problem: The character offsets weren't updated, so when you edited text above a folded region, it's content would come out corrupted after unfolding.
    
    This also factors out helper function `mergeCollectedFoldingRegionsWithExisting()` with extra commentary.
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    96d843e View commit details
    Browse the repository at this point in the history
  32. 👼Script: added Ogre::Timer, profiled & optimized 'script_editor.as'

    I really suspected the `array<dictionary> bufferLinesMeta` to be the culprit. When that was disproved, I thought collecting regions or merging region info could be it. Both were disproved too. To my surprise it was the `isChar()` helper.
    
    Profiling results [in microseconds] opening 'example_ogre_terrnBatcher.as':
     * Before:  PROFILING analyzeBuffer(): total 205834us (CPU 206000us) regions 324us (CPU 0us) dict 15805us (CPU 17000us) merging 151us (CPU 1000us)
     * After: PROFILING analyzeBuffer() : total 32313us (CPU 32000us) regions 280us (CPU 0us) dict 15653us (CPU 16000us) merging 146us (CPU 0us)
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    a2301a5 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    aee613f View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    0040cb2 View commit details
    Browse the repository at this point in the history
  35. 👼Script: Added OGRE shader parameter bindings + example ✨

    // New Script API:
    // -- `BeamClass.getManagedMaterialNames()` -> `array<string>@`
    // -- `BeamClass.getManagedMaterialInstance()` -> `Ogre::MaterialPtr`
    // -- `Ogre::Pass.__getNamedConstants()` -> `array<string>@`
    // -- `Ogre::Pass.getFragmentProgramParameters()` -> `Ogre::GpuProgramParametersPtr`
    
    New internal API, `class Actor`:
    - getManagedMaterialInstance(const std::string& orig_name); --> Ogre::MaterialPtr
    - getManagedMaterialNames(); --> std::vector<std::string>
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    b564add View commit details
    Browse the repository at this point in the history
  36. 👼Script: Added OGRE index buffer bindings.

    The 'example_ogre_terrnBatcher.as' script was updated
    - Use the new indexBuffer bindings
    - Perform merging of selected meshes (buggy at the moment)
    - Display an inline control for scene node visibility - useful to compare original vs. generated meshes
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    ec5fcf0 View commit details
    Browse the repository at this point in the history
  37. 👼Script: Added game.serializeMeshResource() - dumps .mesh files

    Script 'example_ogre_terrnBatcher.as' updates:
    - Added [dump] button to inspector scenegraph - tested to work also for ManualObjects
    - Fixed mesh generation (I forgot to offset indices for every new appended mesh)
    - Reduced debug outputs
    
    Code changes:
    - added RGN_LOGS, auto-created at startup (along with other resource groups)
    - the actor-dump code now uses RGN_LOGS
    - moved RGN_ defs from ResourceManager.h to Application.h
    ohlidalp committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    98f448a View commit details
    Browse the repository at this point in the history