Page 6 of 13 FirstFirst ... 45678 ... LastLast
Results 51 to 60 of 121

Thread: G.T.A.2 Map Editor

  1. #51
    Quote Originally Posted by hwnd View Post
    Here is the way im doing atm:
    Code:
     
    var texTop, texbottom, texleft, texright:single;
    w,h:Single;
    
    
      texTop:=0; // This shouldnt be 0 i think, must be calculated?
      texleft:=0; // This shouldnt be 0 i think, must be calculated?
      texbottom:=th /getnextpot(th);
      texright:=tw / getnextpot(tw);
    
    
      w:=tw/64;
      h:=th/64;
    
    
    
    
    
    glBegin( GL_QUADS );
             // Top-left vertex (corner)
             glTexCoord2f( texLeft,    texTop ); glVertex3f( -w/2, -h/2, 0 );
    
             // Bottom-left vertex (corner)
             glTexCoord2f( texRight,    texTop); glVertex3f( w/2, -h/2, 0 );
    
             // Bottom-right vertex (corner)
             glTexCoord2f(  texRight, texBottom); glVertex3f( w/2, h/2, 0 );
    
             // Top-right vertex (corner)
             glTexCoord2f(texLeft, texBottom); glVertex3f( -w/2, h/2, 0 );
    
       glEnd();
    If i modify either texTop and / or texLeft then i can move texture to center.
    But then it looks pretty bad, like squeezed together a bit or something.
    The problem of this code you had is that you have only been moving texTop and/or texLeft but not texBottom and/or texRight. So instead of moving texture you have actually been scaling it.
    You should have changed your code like this:
    Code:
     
      texTop:=0; // This shouldnt be 0 i think, must be calculated?
      texleft:=0; // This shouldnt be 0 i think, must be calculated?
      texbottom:=textTop + (th /getnextpot(th)); //Bottom edge is always position of top edge + height
      texright:=texLeft + (tw / getnextpot(tw)); //Right edge is always position of left edge + width

  2. #52
    Quote Originally Posted by phibermon View Post
    I'm working in OpenGL 4.x currently and I don't support anything less than 3. I did that specifically because I didn't have to jump through all the hoops. I'm guaranteed to have NPOT support, guaranteed to have uniform buffers, tessellation stages on 4.x hardware blah blah blah

    it's so much less of a headache than GL1.x GL2.x, GLES etc...
    I have plans for that, it's just lots of work... I already rewrote the shader classes 2 weeks ago so the "concrete basing" is already set tight Building the renderer and all the shaders won't be easy though. Basically the 2D drawing code from programmers part will hardly change at all. Instead of nx.DrawRotate(), you'll just propably get nx.renderer.DrawRotate() with same parameters. The plan is to have polygon queue which adds and adds stuff, and then draw all of them at once. On change of texture, polygon mode (triangle/quad), or shader program change it will render the queue and start over again. That stuff should be invisible for the programmer. I would also be able to support uniform light arrays for example, in theory at least. Almost can't wait to get writing the shaders, just that true game programmer is also a gamer himself that is the major issue

  3. #53
    Quote Originally Posted by SilverWarior View Post
    Code:
     
      texTop:=0; // This shouldnt be 0 i think, must be calculated?
      texleft:=0; // This shouldnt be 0 i think, must be calculated?
      texbottom:=textTop + (th /getnextpot(th)); //Bottom edge is always position of top edge + height
      texright:=texLeft + (tw / getnextpot(tw)); //Right edge is always position of left edge + width
    Thanks, but does it matter? I changed like you told me but it looks same.
    But anyway, its good if somebody else with more knowledge takes a look at this.

    User137

    I know that nxPascal supports the stuff, but i wanted to work out "my own" so i understand what must be done to support and draw such textures normally.


    Edit: wow, i just now noticed the example you made.
    Thank you very much for this!!
    Every bit of such thing helps and motivates me.

    Thank you again!

    So now if i apply the animated texture to 3D quad, it will still work?
    Last edited by hwnd; 31-03-2013 at 07:51 PM.

  4. #54
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Quote Originally Posted by hwnd View Post
    Thanks, but does it matter?
    Not for a single image, but in a texture atlas for example you will need to do as SilverWarior stated, obviously in such a scenario your textop + texleft would be non-zero
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  5. #55
    Quote Originally Posted by phibermon View Post
    in a texture atlas
    Ok, if i will ever create my own game, i will try to use texture atlas.
    The most difficult thing with texture atlas is calculating correct texture coords to get specific sprite.
    But i will investigate this later.

  6. #56
    Quote Originally Posted by hwnd View Post
    So now if i apply the animated texture to 3D quad, it will still work?
    You have 2 ways. If drawing the quad yourself, get pattern texture coordinates with this function:
    Code:
    tex.GetPatternCoords(var x,y,w,h: single; pattern: integer)
    Notice that w, h are width and height, not x2, y2. You can get those with x+w, y+h. It will get the coordinates from texture which was previously set.

    Or if you want to use the nx.DrawRotate() or others in 3D that is possible. But you have to deal with problem of 2-sidedness and camera, possibly lighting aswell (2D-drawing functions don't use normals). nx.rs.CullBack:=false should be set if you want it 2-sided. When setting the camera right you might find that useful... especially if you try to place it on ground and it's actually facing down, you can't see it and wonder why it's not working. The nx 2D drawing functions consider 0,0 coordinate be top left corner, whereas in 3D world positive Y goes vertically up. So first of all your image is upside down, and camera should be rotated around X axis before rendering. Then the scale of things, where normally 1.0 match about 1 meter, is only 1 pixel in those drawing commands. So they would appear gigantic and should be rendered smaller using the functions that include scale in parameters.

  7. #57
    Didn't notice your reply here. Thanks for the info. I will test these things when i get back the motivation.
    I am pretty tired lately and slightly sick because of the cold weather etc, i don't want to see the computer for a while now.

  8. #58
    User137 or anybody.

    I have a third party OpenGL app, actually GTA1 map editor from 1998, maybe uses OpenGL 1.1 or something, dunno. What's interesting in it is that it creates very nice minimap from map. I see that minimap uses same colors as actual map and any changes made in actual map are immediately visible on minimap.
    Its a C++ MFC app, there is no source available.

    Also it has option to also draw or not to draw transparent tiles on minimap.
    This makes me think that it actually draws scaled down tiles, but how he does it so fast.
    Thats the key question.

    Any ideas how it creates that minimap? It seems that it draws actual map in small size somehow, like scaled down someway. But all minimap colors are same as in actual map and i would like to do the same in my editor.

    In opengl, what could be used to create such minimaps? I dont think that it draws whole city twice, one in actual size and one like scaled down version. Or does it?
    And its fast, changes in big map are immediately modified on minimap also.

    I once tried drawing all tiles in 1x1 pixel for minimap but something was very slow. But it gave me same colors like in actual map.

    EDIT: ok i remember, drawing 1x1 pixel tiles for 256x256 minimap was slow.

    But one idea i have atm is to have big global list where all the current (LID) tiles are, actually their ID numbers and only these that are currently used will be scaled down to 1x1 and drawn with StretchDraw and not all.

    I just need something fast.
    Last edited by hwnd; 15-04-2013 at 09:47 PM.

  9. #59
    I can think of two posible solutions for this:
    1. Draw the whole map into some chached texture (render texture), then render visible portion of the map inside your windows and finally draw that whole texture scaled down to fit the minimap size. But this might not be nest solution especially if you have large map as you would require huge texture and scaling down such texture could lead to large inacuracies.
    2. Calculate and store average color for each posible ingame tile. Then use that store information to determine the color value for each of the pixels for minimap texture (each tile is represented as single pixel). Since you are changing one tile at a time you would only need to update one pixel at a time.

  10. #60
    SilverWarior has good tips. I would do 2) to hold 256x256 colored vertex array for the pixels. Render it into texture as a 256x256 grid, that's what framebuffer demo in nx is about. It might be a little complicated demo though. You can optimize it by having a boolean variable "minimapChanged". Every time you draw to tilemap it is set True. Then every half second check if it's True. If it is, then set it False and generate the minimap texture again. For actual map drawing you're only drawing 1 quad per frame. Change texture coordinates based on where the camera is.

    edit: You can draw the whole map as is into framebuffer, if you want to make it simple and memory efficient. It will just take longer time to render. But then you can zoom the minimap with texture detail, depending on the texture resolution used on minimap. 512x512 would still only show you 2x2 area of 1 tile, but it's much more detail than 1 pixel.

    And, what it means to draw into texture... Think if it as drawing the whole map onto your screen in ortho mode. Scaled exactly in area of texture resolution 512x512 if that's what it is. You should definitely test by rendering it on screen first to see that the boundaries are right, and then switch to render it to texture.
    Last edited by User137; 16-04-2013 at 04:16 PM.

Page 6 of 13 FirstFirst ... 45678 ... 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
  •