Page 10 of 12 FirstFirst ... 89101112 LastLast
Results 91 to 100 of 115

Thread: G.T.A.2 Map Editor

  1. #91
    Quote Originally Posted by hwnd View Post
    Strange thing is that on my current PC (not laptop) i have no CPU usage on map editor, all faces are drawn.
    But in my laptop which only has 16MB of video memory, it uses CPU, not alot but around 20-30 depends...
    It is posible that your graphic card on your laptop doesn't natievly support all the graphic functions your application is using and therefore graphical engine fals back to use software rendering which is being done by CPU itself.

  2. #92
    Quote Originally Posted by hwnd View Post
    I would like to make it even more smaller.
    And was thinking about only use unique vertex coords. Many blocks that need same vertex, is pointed to one vertex, so one vertex is not duplicated for each block that needs it.

    And also use glDrawElements, and maybe even interleaved arrays.
    Drawelements is in core from v1.1, so shouldnt be a problem on old hardware.
    That is the standard way to render all models, to reuse same vertex indices if possible. I'm not sure if this is helpful at all, but here is code generation for cube, plane, sphere and torus models with face indices, each with segment parameters:

    I don't understand how the TRSI demo works, OpenGL shouldn't be able to handle that kind of vertex record
      TVertex = record
        { Position }
        Pos: Integer;
        { Normal }
        Nrm: Integer;
        { Texture coords }
        u, v: Single;
    Index for position, normal and textures is always the same, you can't customize it. This seems more like a "guideline" structure to build real array later that OpenGL will then use. I'm trying to keep away from having 2 instances of model arrays in memory, and only have that which OpenGL uses.

    A cube for example cannot share all the 8 vertices it has. Because in the corner points there are 3 different variations of normals and texture coordinates. So the amount of vertex/normal/uv-indices that cube has, is 6 faces * 4 vertex_per_quad = 24. That would be drawn with either 6 quads, or 12 triangles. And no, vertex indices will not speed up rendering, it will be as fast as vertexarrays using the coordinates directly. But you can save some memory with indices, especially with models that have smooth triangle-connections such as sphere. That's 1 of the sweet cases where all the vertices can be linked together.

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

    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.

  4. #94
    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. Editor
    Last edited by hwnd; 17-09-2013 at 08:30 PM.

  5. #95
    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:
    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.

  6. #96
    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.

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

  8. #98
    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.

  9. #99
    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.

  10. #100
    Ok, i did stupid mistake. And i got better and faster average color calculation using scanlines:

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

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

Page 10 of 12 FirstFirst ... 89101112 LastLast

Tags for this Thread


Posting Permissions

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