ToEEZWB - pet project

Discussion in 'Tech Guides and Help Threads' started by anatoliy, Nov 8, 2017.

Remove all ads!
  1. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Hi

    I've been developing modest new tool ToEEZ World Builder for few weeks now. The tool is inspired by famous ToEE Worldbuilder .NET.

    Currently stumbled upon problem of mapping Ground and Isometric Sectors. Is there anyone who understands and can help me with that?

    [​IMG]
    [​IMG]
     
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    2,714
    Likes Received:
    84
    Hey,
    You can look at the render code and transformations in the Temple+ git repository.
     
    anatoliy likes this.
  3. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Yes, Sitra Achara, the Temple+ project. Personally, I cannot express enough how great your project is, especially from programmer’s view. Unraveling this black box (decompile \ reflection) into workable structured code is just huge!

    Now, back to the problem.

    I’ve found interesting code:
    Code:
    \GitHub\TemplePlus\TemplePlus\graphics\mapterrain.cpp:
    
    auto viewportWidth = config.renderWidth;
    auto viewportHeight = config.renderHeight;
    
    // The terrain is centered on the center tile of the map
    // This is 480,480 for all vanilla maps, but theoretically it
    // depends on the map size specified in the map's map.prp file
    auto mapCenter = maps.GetMapCenterTile();
    
    // The center of the map in pixels relative to the current screen viewport
    int terrainOriginX, terrainOriginY;
    locSys.ToTranslation(mapCenter.locx, mapCenter.locy, terrainOriginX, terrainOriginY);
    
    // Since the origin is still pointing at the map center, shift it left/up by half
    // the terrains overall size. The Map is slightly off-center for *some* unknown
    // reason. This may be a relic from Arkanum
    terrainOriginX -= MapWidthPixels / 2 - 40;
    terrainOriginY -= MapHeightPixels / 2 - 14;
    
    Perhaps this 40 and 14 it’s just what I have been looking for.

    Thanks!
     
  4. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Basic rendering of Game Map
    The Game Composite Map contains two base Layers:
    1. Grounds
    2. Sectors

    Grounds
    Grounds is a square tile Cartesian 2D-map with inverted Y axis. Origin of this coordinates starts at Top Left, X-Axis goes from Left to Right and Y-Axis goes from Top to Bottom.

    Ground Tile is image of 256x256 pixels that is usually stored as jpeg.

    [​IMG]

    The Grounds Map is placed onto Composite Map centered at X: 32, Y: 35 Map Tile adjusted 107 pixels to the right, and 30 pixels to the up. Those numbers have been figured out experimentally.
    This placement location is hard-coded regardless of actual tiles availability.

    Grounds Map Folder
    Grounds Map is stored in this pattern folder:
    ".\modules\<module>\art\ground\<MapName>[-day|-night|]"

    For example:
    "D:\Games\Temple of Elemental Evil\modules\ToEE\art\ground\HOMMLET_01_Exterior-day"
    "D:\Games\Temple of Elemental Evil\modules\ToEE\art\ground\HOMMLET_01_Exterior-night"
    "D:\Games\Temple of Elemental Evil\modules\ToEE\art\ground\HOMMLET_02_Inn_Lower"

    Ground Tile File
    Ground Tile is stored in file of such name pattern:
    <int_number>.jpg

    For example:
    00110001.jpg

    Parse int_number to X, Y:
    1. Convert int_number to hex_string of length 8 characters.
    2. Split y_hex = substring(hex_string, 0, 2); x_hex = substring(hex_string, 6, 2);
    3. Y = ToInt32(value: y_hex, fromBase: 16) / 4;
    4. X = ToInt32(value: x_hex, 1 fromBase: 16);

    Sectors
    Sectors is a square tile Isometric 2D-map with inverted X axis. Origin of this coordinates starts at Top Right, X-Axis goes from Right to Left and Y-Axis goes from Top to Bottom. Isometry parameters are -45 grad (anticlockwise) and Y-scale of 0.7055.

    [​IMG]

    The Sectors Map is placed onto Composite Map centered at X: 7, Y: 7 Sector’s center.
    This placement location is hard-coded regardless of actual sectors availability.

    Every Sector consists of 64x64 squares. Every square is actual game coordinate. Therefore:
    1. Sector. TOP Right Square = Sector.X * 64, Sector.Y*64
    2. Sector. TOP Left Square = Sector.X * 64 + 63, Sector.Y*64
    3. Sector. BOTTOM Left Square = Sector.X * 64 + 63, Sector.Y*64 + 63
    4. Sector. Bottom RIGHT Square = Sector.X * 64, Sector.Y*64 + 63

    Sector Map Folder
    Sectors Map is stored in this pattern folder:
    ".\modules\<module>\maps\<map_name>"

    For example:
    "D:\Games\Temple of Elemental Evil\modules\ToEE\maps\TEMPLE_09_Level_1"

    Sector File
    sector Tile is stored in file of such name pattern:
    <int_number>.jpg

    Parsing same as Ground Tile File.

    Cartesian Rendering
    [​IMG]

    Isometric Rendering
    [​IMG]

    Isometric Parameters
    Rotation Angle: 45
    Scale Y: 0.7055
    Zoom: 28.2

    Composite Map Render
    Both Layers with all Labels
    [​IMG]

    Both Layers, Sector Grid, Axis
    [​IMG]
     
  5. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Published first bug free (hopefully) version ToEEZWB.v.0.1.64.4.zip:
    https://drive.google.com/file/d/1MRWj9cgTLcg1dmPOj5vHtcUcGJPqvYOO/view

    The file contains tiny Microsoft built-in installator. I assume it will check .NET version.

    Install.

    Usage:
    1. Open ToEEZ.WB from Start Menu.
    2. First time it will ask for ToEE root location. Choose it.
    3. Main Menu \ Project \ Maps...
    4. Locate desired map in the list, double click to open in new Designer Window.
    5. Poke it with Menu \ View options.

    This version contains only render ability and view options:
    *. Drag map using mouse.
    *. Ctrl+Mouse Wheel to zoom;
    * . Other options in View menu;

    Note: Background thread render can take time. And currently there are no indications that it is actually working. One could see black Designer Window for tens of seconds on start.

    Feel free to leave feedback here.

    BR,
    A
     
  6. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,002
    Likes Received:
    24
    Looks nice. :)

    So what I'm seeing here is basically a visual representation of the sectoring aspects of WorldBuilder, is that correct? With the idea being (at some point), to add the same functionality to it? (This aside from a hefty investment to the overall knowledge base.)
     
  7. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Thanks! :)

    Personally I have two strategic goals: learn and practice c# sufficiently to pass MS Exams, and second, - simplify a way to make ToEE content modifications.

    I'm really glad that old ToEEWB was published with sources. Although I see that coding was somewhat rushed, the work is invaluable to me right now. Big thanks to author(s)! :)

    I'm too, will publish sources on the GIT somewhere, when it's ready, or when I'll take a lengthy break.
    ----------

    Answering to your question - yes, the ToEEZWB is planned to be at least as ToEEWB companion or at most as modern replacement.

    Some use cases I wrote in todo:

    Extract Map portion to new Map
    1. Open some Map;
    2. Select desired area;
    3. Create new Map in Working folder from this area with such parameters.
    4. Save new Map;
    5. Publish to Game folder as new Map;

    Edit Sector Squares
    1. Open Map;
    2. Select desired sector square.
    3. Change properties (blocked, flyover etc);
    4. Save Map;

    Edit Background
    1. Open Map;
    2. Import new solid background image;
    3. Rescale, move background;
    4. Split, to see result;
    4. Save Map;

    Resector
    1. Open Map;
    2. Set Resector mode;
    3. Move new Sector grid as desired;
    4. Select new sector grid exportable sectors;
    5. Apply or copy to new map;

    Square Painter
    1. Open map;
    2. Choose Square Painter Brush preset (or customize it).
    3. Click or move mouse down on sectors to apply Brush effect on desired squares;
    4. Save Map;
    ----
    Also I've made some new features and changes to previous release. Didn't released yet.
    [*] Changed Clipping Regions for hot, selected and focused areas;
    [+] Added Hot, Selected and Focused modes;
    [*] Remade menus:
    View\Active Layer
    View\Active Layer\Sqares
    View\Active Layer\Sections
    View\Active Layer\Grounds
    View\Tool
    View\Tool\Focus
    View\Tool\Hand
    View\Tool\Select
    other cosmetics;
    ---

    Currently (right now actually) I'm working on redesigning Model classes, adding abstract ReadWriters and so. Afterwards I'm going to add Property Editor control and have ability to select modify squares in Designer window, directly seeing the result.
    Then publish.

    Then save ability for sectors. Then creating new maps, without MOBs at first....
     
  8. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,667
    Likes Received:
    136
    This is an interesting project, anything that makes creating the Icewind Dale (and any other new) module easier to do would be awesome and greatly appreciated.

    Worldbuilder can be a bit finicky and experiences the occasional crash to desktop wich can be annoying if it happens after a lot of work has been done since the last save.
     
    Last edited: Nov 20, 2017
  9. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Hi Allyx :)

    Could you write a use case for Map creation or modification, without mobs at first? What is the biggest pain in such routine? What tool do you use for image modification?
    BR,
    A
     
  10. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,667
    Likes Received:
    136
    The process I currently use is as follows:

    1) Extract IWD maps with Near Infinity, maps that include doors and containers are extracted with itens both opened and closed, Outdoor maps are also extracted in both night and day versions where possible (not all outdoor maps have a night version) as a .png file. I use MS Paint and/or Gimp for graphical edits (mostly Paint and Gimp is still pretty new to me.
    2) Maps with containers and/or doors are edited to show containers closed and openable doors removed completely.
    3) The edited image is copy/pasted onto a recombined ToEE map (to make splitting again easier) using ToEEWB.
    4) Add the map to the art folder to replace an existing map.
    5) Clear the old map's sector data in ToEEWB.
    6) Open the new map in WorldEd, paint the border around the map impassable.
    7) Paint the terrain material types for the floor (for the various footstep sounds).
    8) define other impassable areas, walls, buildings etc. in WorldEd.
    9) Add and rotate doors and containers in WorldEd (some of which subsequently need to be extracted in ToEEWB, resized to fit and embedded back into the map's sector files which requires some guesswork).
    10) Add clipping data for tables, beds, chairs, bars, crossbeams that block characters behind them from vision in WorldEd. A lot of this also requires some guesswork as the height and depth of the clipping models is 3d and the map is 2d.
    11) Add particle effects and lighting in WorldEd (I never figured this bit out completely as @Shiningted did that bit for me.

    A fair bit of the frustration using WorldEd stems from the fact it was adapted from Arcanum's WorldEd, a number of the selectable options are invalid in ToEE's version and causes crashes when selected, some of the SVB blocking/extending options are confusing or poorly explained. The orientation of doors is not entirely apparrent sometimes, but at least rotating 180° is easy enough.

    I did have to set my pc up as a dual boot system (Windows 10/Windows Vista) as when Win 10 was new, WorldEd would not run on it, it does run just fine on Win 10 now though).
     
    Last edited: Nov 20, 2017
  11. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    So, let's split this use case into smaller ones.

    Input:
    A) SolidImage of arbitrary size.
    B) Picture in your head.

    Questions:
    1) How do you know, how many sectors you'd require?
    1.1) Do you have a picture size template for some combinations of sectors?
    1.2) Do you do some math calculating rectangle of sectors?

    2) How do you move (adjust) to right\left\up\bottom of this SolidImage? Is it done in your image tool or you use WB Recombination constantly?
    3) How do you rescale, and if it's really needed?
     
  12. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,002
    Likes Received:
    24
    Al, I think you mean WorldEd? Which, @anatoliy, if you're not aware is the official toolset made available (in a manner of speaking) by the former Troika powers that be and can be found here. Their code isn't available but you may find it interesting to look over nonetheless if you haven't already.

    Thanks for the breakdown, looks like a useful effort!
     
  13. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,667
    Likes Received:
    136
    Ah yes, thanks @Gaear for correcting me, I did mean WorldEd, I'll edit my previous post for charities sake.
     
  14. anatoliy

    anatoliy Member

    Joined:
    Feb 18, 2017
    Messages:
    99
    Likes Received:
    6
    Thanks @Gaear !
    I didn't know about the WorldEd. Just installed. Is there any manual or at least info how to open existing map?
     
  15. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    4,667
    Likes Received:
    136
    Last edited: Nov 20, 2017
Our Host!