Results 1 to 10 of 121

Thread: G.T.A.2 Map Editor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ok, i will use vertex arrays. I already did this on the copy of editor in my laptop but i dont have it near me atm.
    Lighting demo just uses that custom record to make things "easier"
    http://www.pascalgamedevelopment.com...f-lightsources

    I have plan to use this later on my editor for lights.
    Only version i have found that doesnt use 3D textures or some special function that only new hardware supports.

    The demo is not made by Micronix, unless he is the same person. Original author specifically states in included readme.txt that unless you have really new hardware with 3D textures available then you can make this easier, but for the ones who dont have this this is the way. But if Micronix wouldnt post it, i would never have found this one.

    I really like this lighting demo. Best i have found.
    Last edited by hwnd; 11-09-2013 at 08:24 PM.

  2. #2
    Yesterday worked a bit on the thing again and finally took decision not to mess with minimap anymore and use the "ground_type" flag from map to actually build some usable minimap.
    Works and looks pretty well:


    Blue is water obviously. Green is field, gray are pavements, and darkgray roads.
    I tried to find better method, but they are too slow.
    This current one is fastest.
    Tried to get average color for tiles, but its too slow, because of ~500 tiles loaded for map.
    If not more.. But colors were much better but algorithm needs rewriting.

    Maybe should make sheet of tiles and get average colors of that?
    I have seen something like this done in one open source Delphi game. I even downloaded src from svn. But still i dont understand everything in it.
    Editor src.
    https://code.google.com/p/castlesand...k%2FKaM Editor
    Last edited by hwnd; 17-09-2013 at 08:30 PM.

  3. #3
    Is the map like 3D with different layers, or flat plane of tiles? If there are layers, it might at least look best by finding the "roof-block" and plotting its color. You can get roof-block by starting searching from sky/height-max level downwards, until you meet a block that is non-empty. (And you could cache this information for later use in a byte-array)

    As for color averages, OpenGL can do that for you. If you for example wanted to draw a roughly blurred map of 32x32 world, using only every second tile of it:
    - Initialize a 16x16 texture with GL_LINEAR.
    - Plot every second tile to it.
    - Render the texture with any size quad.
    (Obviously this is just a bad example. It'd be better to use 32x32 texture for full details.)

    But also some simple algorithm if you have to do it manually:
    Code:
    For-loop through tiles from 0 to MapWidth-2, 0 to MapHeight-2:
      color.R:=(col[x,y].R + col[x+1,y].R + col[x,y+1].R + col[x+1,y+1].R)*0.25; // Average Red
      // Same for Green and Blue channels
    Last edited by User137; 18-09-2013 at 01:46 AM.

  4. #4
    Quote Originally Posted by hwnd View Post
    Maybe should make sheet of tiles and get average colors of that?
    That is exactly what you should do.

  5. #5
    Quote Originally Posted by hwnd View Post
    I have seen something like this done in one open source Delphi game. I even downloaded src from svn. But still i dont understand everything in it.
    Editor src.
    https://code.google.com/p/castlesand...k%2FKaM Editor
    Wait that is the souce of Knights and Merchants remake.
    I have been in contact with lead developer (atleast I think) some time ago (exchanging some ideas and expirience) and I got impression that he was verry open in making discusions about the game, how certain things works etc. I even got a few tips and suggestions from him about something compleetly different.
    So I suggest that you just go and contact him or other developers if you don't understand some ascpects of their code. I'm quite sure all of them will be able to offer their help to you.

  6. #6
    The world is 256 * 256 * 8 (X,Y,Z) always, just the blocks and their faces matter. Some faces are textured some not.
    I only check for AIR blocks that contain no faces, this speeds things up a bit.

    Map has 8 "layers" (0..7) in Z coord, from top to down. Its a top down view game.

    Looping through ~500 tiles and getting TBITMAP for them and then doing pixel stuff on them is pretty slow.
    Maybe i should reuse the actual texture data i already created from tiles. Instead of doing another read for same tiles second time.

    I once talked about here how one GTA1 editor shows so nice minimaps. It only works on Win9x. Fails on NT with "Failed to create empty document". MFC app. I will try to get the BMP of minimap and analyze that. Maybe i will figure out how he is able to create minimap so fast or at least whats the tehnique, will try to analyze some area of minimap and actual tiles that are used in map at the same place.
    Last edited by hwnd; 18-09-2013 at 08:16 PM.

  7. #7
    You can calculate once at beginning of program what color each tile type means. Then it becomes very fast to just use that color table for each map tile. What still remains is refilling the texture when map updates.

  8. #8
    Ok, i did stupid mistake. And i got better and faster average color calculation using scanlines: http://www.delphimaster.net/view/2-1...72/all#PageTop

    I was calculating this for every pixel 64x64 and in a third loop. Thats why it was terribly slow. I really should not code at nights and after the work when im very tired.

    Now i just get avg color for each of the 992 tiles and store it in a 1D array of TColors:
    Code:
    tileColorIndexes: array[0..991] of TColor;
    Later i just loop through map and set minimap pixel color according to: tileColorIndexes[tile_id];

    But i still have to optimize a bit. Just do reading tiles once, not twice. But anyways, here are the results using average colors. Amazing how good the minimaps look right now.
    I still have to think about the logic for the transparent faces (tiles), so here is one with transparent disabled and second one enabled. The first one with lots of black pixels is the disabled transparency version.



    Second
    Last edited by hwnd; 21-09-2013 at 12:29 AM.

  9. #9
    EDIT: Nvm, got it working it seems. Was looking over my code, thinked a bit and removed one line: pnlRenderMouseMove(Sender, [ssLeft], X, Y);
    from MouseDown.. event. Because it messed up some things and i just now discovered that i actually implemented better thing in MouseDown.

    Basically calling "pnlRenderMouseMove" even in MouseDown was needed for selectionboxes to clean up, so after single click anywhere on map there will be only one selectorbox.




    Strike that all.
    Working on this thing again after very long break.
    I have some problems with selectorboxes. It basically works, but it picks the objects behind the selectorboxes.
    It probably has to do with objects Z ordering or something.

    It goes through the selectorobjects and picks the tiles behind it.
    I can detect the coordinates of the picked selectorbox cube and face of it but for some reason it goes through the selectorboxes. I tried to "pick" them first (by moving code for picking on the top of the code for picking map cubes) and then actual map cubes but it didnt change anything.

    I tried to set glDepthMask(FALSE); and true, nothing changed. Just worse.

    Im doing the picking like in nxPascal picking demo. Spheres at specific position, if ray touches spheres i loop through selector vertex coords.

    Any ideas what should i try? So if ray hits the selectorboxes it will not go behind them.
    Here is pic with arrow, behind the arrow it picks the map cubes (the blue / yellow ones). But it shouldn't.


    Last edited by hwnd; 08-03-2014 at 09:20 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •