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
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    I did find in some apps that calling mousemove in mousedown is acceptable solution. But it has to be last line of the MouseDown event, and you would change it to
    Code:
    pnlRenderMouseMove(Sender, Shift, X, Y);
    But you got it working without it so i would not suggest re-adding

  5. #5
    Ok, but still i have problems with selectorblocks.
    I have some ideas why it goes through the main tiles, probably because of that selectorblocks "spheres" and map blocks "spheres" that i use for picking are in same place.

    I can detect if selectorblock is under mouse and when its not, but its not enough. I guess i have to check if selectorblocks are the first ones under mouse or are they "lower".
    Some kind of Z sorting is needed or something.

    Im not sure.

  6. #6
    How about splitting picking code into two stages:
    1. You do checking to see if your mouse is over selectorblock (only checking those sphere that are used for detecting selecboxes. If your mouse is over selectorblock you end here else you go to second stage. In order to achieve better optimizatio you may add aditional logic check to see if secetor block colision is even needed (depending on your editor implementation you probably won't need this at all times) if not you simply skip to second stage.
    2. Here you do checking to see above which map cell is your mouse.

  7. #7
    Well if you look at this that way then its already is 2 stage. Well kinda...

    One piece of code is picking map blocks and second below it is picking selector blocks.
    Its just copy/ paste of picking code with slight modifications for selector blocks.

    I dont know if you meant that but if not then i should try it. Have to think a bit.
    Its almost perfectly working atm but just 1 (ok in worst case 2) problem(s) still exist.

    I will devote more time to this today, maybe whole night and will try different things.

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
  •