Page 1 of 2 12 LastLast
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
    Multiplying by 1 actually does hard work. It positions all the blocks side by side. If i remove it all blocks are on top of each other.
    One idea i had is to use some list with all blocks already with correct X,Y,Z coords translated mathematically and just let opengl draw them. Just a rough idea. I still will need gltranslate i guess, dunno.


    And i found now that displaylist increased performance alot.
    33% CPU with area of 33x33, using vertex arrays and drawing only lids.

    With 23x23 its around 3-7% which is fine for me.

    Now i need some ideas, how to rebuild display list after map array modification so it will render the changes?
    Just gldeletelists and create new list after each mouse map manipulation?

    Edit:
    my idea, have some list (vector, tlist) with all the needed blocks and coordinates. If user modifies block it will get added / removed / modified. And make_displaylist function just loops through all these blocks and positions them.
    And in draw() i just call that list.

    If i modify map, again loop through block list and make new display list.
    Dunno if it will work.
    Last edited by hwnd; 25-08-2013 at 03:49 PM.

  2. #2
    Try TDisplayList on nxPascal maybe, it's designed for easy updates and stuff. You could have 1 displaylist for each chunk, to minimize performance impact on updating just certain part. (I mean map could be divided in like 8x8x8 block sections or something, not displaylist for each individual block)

    glTranslatef( 1.0 * jj, 0.0, 1.0 * ii );
    is same as
    glTranslatef( jj, 0.0, ii );

    Also if you are using nx models with Render(initialize: boolean) procedure, you could try doing the initialization manually if you repeatedly render same block. You just have to keep track on when model changes and initialize new one when needed. I'm right about to do that optimization on my pgd game entry right now. Related functions are model.SetPointers, EnableStates and DisableStates.

    edit: It came down to:
    Code:
              if _otype^.model<>lastModel then begin
                model[_otype^.model].SetPointers;
                lastModel:=_otype^.model;
              end;
              model[_otype^.model].Render(false);
    I enable model[0] states at beginning of loop, and disable states at end. States are same for all models here so they don't need to change inside the loop. However i didn't gain FPS boost so it's back to drawing board.

    edit2: My issue was in materials. I've updated nxPascal SVN because of change to material handling. Because my models have flat faces they were all in unique groups. Therefore it changed material for every face... not anymore.
    Last edited by User137; 25-08-2013 at 05:01 PM.

  3. #3
    Like i said a while ago, i was unable to make models for my editor so it was easier to create vertex data by hand and just use opengl calls to render them. I would use model structure but only if i can port my vertex data for all 63 slopes to your model struct.
    So atm, no nxmodels are used. I should try make model from 0 in code again, it was long time ago, when i tried. I even have your private messages where you tried to help, i will have to look. I remember also that i got blank screen, i didnt fill all needed things up i guess.
    EDIT: ahh, it needed some indices or something, this is were i got stuck. I was too lazy to create these, i have 63 slopes, it will be pain i think. Dunno. Will try.

    I will look at the TDisplayList.
    Last edited by hwnd; 25-08-2013 at 04:33 PM.

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

    If video mem is too low for gfx app this means Windows or something makes the app to use CPU also?


    And another question.
    Atm, i have lots of repeated vertex coords for all the slopes (blocks). The unit file size is 322KB. I was able to reduce it to this size with help of User137. Gave me great suggestions. Before that it was something like 1.6MB or something.

    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.


    Will this speed up my rendering also a bit?

    Here is example, how some vertex data is linked / pointed to other array element.
    http://pastebin.com/jpGTg9b3

    Copy/paste from TRSI lighting example.
    Last edited by hwnd; 10-09-2013 at 08:17 PM.

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

  6. #6
    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:
    https://code.google.com/p/nxpascal/s...Model.pas#1733

    I don't understand how the TRSI demo works, OpenGL shouldn't be able to handle that kind of vertex record
    Code:
      TVertex = record
        { Position }
        Pos: Integer;
        { Normal }
        Nrm: Integer;
        { Texture coords }
        u, v: Single;
      end;
    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.

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

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

  9. #9
    Its been a while when i worked on this thingy.

    I once wrote here how original editor uses low resources.
    http://www.pascalgamedevelopment.com...l=1#post100842

    How to render more with 0 or very low cpu usage?
    Original editor has always 0 cpu usage, only when you change block or move mouse or rotate the scene it gets a bit higher and after that its 0 again.
    I quickly put together simplest opengl app without nxPascal that uses FormPaint event instead of any (game) loop or timer.
    In FormPaint i do
    Code:
    glDraw();                         // Draw the scene
      SwapBuffers(DC);                  // Display the scene
    In FormResize i do
    Code:
      
    ...
    glDraw;
      FormPaint(sender);
    and CPU usage is small, practically zero. Of course i havent tried to render big map yet, just simple rectangle.
    While i resize the form, then the CPU usage goes a bit up and as soon as i stop resizing it goes back to 0.

    I think original editor uses same approach with the DirectX.

    Because when you modify any block in map, for example change the slope type, then you wont see updates immediately, but later when you do something else.
    So it seems its not re-rendering whole scene every frame but only when you click somewhere or change something else.


    It may be calls "Paint" event when needed only.


    So question is, is this do-able with nxPascal? And at the same time still keep same framerate on all PCs and so the picking also works as needed?


    I ask this to reduce the CPU usage which is high, even if you dont do anything. Rendering just makes it go high.

  10. #10
    Whoah.
    Last post from 2014. Time passes quickly.

    Was lurking around here, searching for OpenAL Delphi stuff.
    Im still working on it.

    I have bunch of versions on my hdd's and dvd's.
    There are few things added to editor. I dont work on this thing full time.
    Sometimes i get tired of all the programming stuff and i need to do something else.
    Now i picked it up again.

    Dunno when it happened but i figured out the camera rotation problems with mouse and kbd movement.
    All this now works ok.
    There are animated tiles also. Although the editing of animations is not working atm.
    My primary point was to make tile animations work and they do work at the same framerate as GTA2 ones.
    There are some more animated things needed, like power pickups, weapons etc... First i must draw them and then animate.

    Also some lighting work is done, my primary purpose of the editor is to make it compatible with WIN95 so no shaders for lighting.
    Why?? Because i love old op. systems, WIN95 is cool. Love sitting in there.


    I managed to figure out how to get like 60 built in OpenGL lights on screen at once and enable and disable them/change their properties.
    But usually maximum i need on screen at once is something like 10-15, usually less.
    So i can say that the lighting is okay.

    I have a code where i added a ped to the city and i can walk around the city.
    Collision detection only works on right side of the buildings, have been lazy to implement more.
    This is my way of doing things. It motivates me to see "half" working thing and then i can always finish it later.
    For me half working thing is more motivating..

    Now i mess with OpenAL delphi wrapper and trying to add some sounds to map.
    They are "scripted into game", i will not parse scripts atm but i add some sounds by hardcoding (taking data from script).
    Like birds on the trees or tower clock ticking.

    I want to test 3D sound. So if i walk away from clock then the ticking fades away..

    There are no new videos currently.
    Im just working on different things and trying them out.


    I have idea to actually rewrite it from scratch, using modern Delphi ((10.3 atm), generics etc..), also latest OpenGL with shaders and VBO.
    So i can render whole city with 60FPS etc etc.

    Will see..
    Last edited by hwnd; 16-02-2019 at 04:15 PM.

Page 1 of 2 12 LastLast

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
  •