Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by PanicRave

  1. that will keep me busy for a little while! thanks!
  2. Hey all, i've been messin with a little isometric engine. It's been over a decade since I wrote one although i'm very familiar with standard tilemaps. I was following a tutorial which has gone well but i've hit a little bit of a hump - the writers solution to an isometric environment is to do everything as you would for a standard (Cartesian ?) tile map, literally everything, and then at the very end when rendering you convert the Cartesian positions to isometric co-ordinates.   eg, calculate your standard tile positions for the tile about to draw: tile_x = tx * tilewidth; tile_y = ty * tileheight;  then do your usual camera offsets for smooth scrolling etc tile_x += camera.x % tilewidth; etc etc and when you're all done convert to iso: iso_x = tile_x - tile_y; iso_y = (tile_x + tile_y) / 2;   This works fine when your camera is following an object IN the isometric world. IE if your camera follows a character and you press right arrow to move player right then your character will walk diagonally down and right and the world would scroll as you expect.   But I want a free camera controlled by the mouse - its a strategy game and there is "no player" in the game world. I want if you click and drag you scroll the map. BUT because everything is done Cartesian and then converted iso if you click and drag to the left intending to scroll the world right it instead scrolls diagonally down and right which is NOT where you are dragging and it feels awful.   Any ideas how can i take the position of the camera and calculate a) the tile offsets so the correct part of the map draws and b) the pixel offset for smooth scrolling in a way that feels natural? I'm beginning to think this converting everything at the end for render isnt the best idea ever :/
  3. if you are working with pixel art (especially with a limited pallet) then you can be a bit more intelligent about how you build your models to save on triangles. Obviously any transparent pixels simply do not add to the mesh at all. Then you could use some sort of algo (perhaps a modified flood fill?) to find groups of pixels the same colour next to each other that can be represented by a rectangle without containing any other colour pixels. Then if you have say 4 black pixels left to right in a line you can do the whole lot with two black triangles instead of 8.   There could be other fun things to mess with too.. like if you used a colour to represent transparent pixels (traditionally magenta 255,0,255) instead of alpha then you could let the artist use the alpha channel to describe depth and extrude each pixel a different amount based on alpha :o
  4. So some of you know i've been working on procedural island generation. I'm really happy with my results right now and have just one last thing I want to perform and i'm not entirely sure how.   My continent is generated inside a 2D array, just like a tile map. I then generate a 3d mesh that matches width/height of grid where each cell is two triangles/quad with a width and depth of 1.0 units.  Where the shore line meets the coast is obviously very blocky whereas the rest of the island actually looks quite smooth despite the rigid quad layout.   What I want to do is find all vertices that share a cell flagged "ocean" and a cell flagged "coast" and sort of.. normalize them a bit? or somehow work out ordered points for a line they form and create some sort of bezier from that and pull the verts closer to that final line maybe? I'm not sure how to even begin doing any of that.   Any advice? :)
  5. Thank you all for your input! I have solved this using a variant of Krypt0n's suggestion, i'll share it here incase its helpful to anyone in the future.   First i'll try to better describe the problem for DaveSF and any others I confused:   We have a world map. It is always an island surrounded by ocean. For this example assume that the world map is a 2D array that simply stores a value saying whether this cell of the map is an Ocean tile or if it is a Land tile. I then create a 3D mesh (which is a 1D array of vertex positions) from this WorldMap array to represent the the world as a 3D object.   This is all fine, but due to the grid like nature of the 2D array and the fact each cell in that array represents a spacing of 1.0 world units it means wherever the boundary between land and ocean occurs it is made up only of square, straight lines and does not look very natural. I have done a silly sketch:     Any cell with O is ocean and any cell with L is land. The pencil line represents the natural border between the two, the X's represent the vertices that connect the two cells (not completely accurate in my case but you get the point) and then the curved pen line is a more natural looking, more desirable border between the two that would help the island look nice and should be completely achievable as after the 3d mesh has been generated the real world co-ordinates of the vertices can be moved as we please, they are not really restricted to a grid.   In order to solve this simply I've written a method that travels over the map and finds ocean cells. It then looks in four compass directions around that ocean cell to find land and stores the position of the land it finds in a list. After it has finished the search it generates a new position for the ocean vertex as an adverage of all connected land positions.   Here is the code i've written to do this: public void SmoothShoreline(WorldMapCell[,] WorldMap) { //for each cell of the world for (int cx = 0; cx < WorldWidth; cx++) { for (int cy = 0; cy < WorldHeight; cy++) { //if this cell is "ocean".. if (WorldMap[cx, cy].TileType == WorldTileID.Ocean) { int u = 0, v = 0; List<Vector3> CoastalVertices = new List<Vector3>(); //for each direction around the starting cell for (int d = 0; d < 4; d++) { //get direction coordinates.. if (d == (int)Directions.West) { u = cx - 1; v = cy; } if (d == (int)Directions.North) { u = cx; v = cy - 1; } if (d == (int)Directions.East) { u = cx + 1; v = cy; } if (d == (int)Directions.South) { u = cx; v = cy + 1; } //check valid map cell (simple bounds checking).. if (IsMapLocationSafe(u, v)) { //if valid and this cell is coastal (or land, whatever).. if (WorldMap[u, v].TileType == WorldTileID.Coast) { //store the coordinates of the vertex belonging to this cell CoastalVertices.Add(Vertices[u + v * WorldWidth].Position); } } } //final (new) position of our ocean vertice will be adverage of all the land cells around it, so.. Vector3 FinalPos = new Vector3(); //combine all the stored coastal/land cell positions.. for (int Vert = 0; Vert < CoastalVertices.Count; Vert++) { FinalPos += CoastalVertices[Vert]; } //divide by the total number of positions to get an adverage.. FinalPos /= CoastalVertices.Count; //set the final vertex position. Vertices[cx + cy * WorldWidth].Position = FinalPos; } } } } It is not completely perfect, i'm sure there is a much more fancy way that would get a 100% result - but it looks pretty good and I am quite happy with it for now :)
  6. for the record: I have thought about cheating this by just blurring the edge render (which happens on a separate render target which is all combined at the end) - the problem is not every edge gets lit up all the time and the camera is free moving AND you can zoom in to very close which would cause the squareness to show anyway
  7. So, at the moment any cell that is "ocean" i've just alpha'd out so it's not visible at all. Here is a screenshot although the final look is far from finished!   http://heavenlysoftware.co.uk/storage/EdgeDetect2.jpg   You can see the edge detection looks like it's in bad need of anti-aliasing - but the fact is thats just what the edges of the island is like.  I figure I can fix this as i said in the first post by normalizing/smoothing the vertices that belong to both a ocean and coastal tile.. but although I have enough knowledge to know that it's a "thing" I really do not know how to do it!   If I ever render ocean on this I want it to be very simplistic and minimal - maybe in the form of faint lines representing waves slowly animating around the coastal regions. I don't think it would be sufficient to mask the quad like structure when it comes to the edge of the island :(
  8. something like that CAN work but... I'm not entirely sure I'm going to render any ocean. If I do choose to, it will be very simplistic. The final effect of this terrain is a sort of world map looking like a hologram/computer projection on a screen rather than a "you are actually looking at a continent from the sky". It has more in common with a map drawn on paper I guess
  9. Hi all,   I would like to create a HLSL shader that renders a 3d model with the appearance of scanlines. I figure to achieve this I will darken out "lines" in the model by drawing pxiels darkened based on how high the pixel is. I thought I might also periodically have one bright line start at the bottom of the model and travel up to the top - it would be much the same method as darkening alternating lines but I guess i'd pass time or some other value into shader to offset it by.   My issue is I don't really know how to calculate that Y offset to pass to the pixel shader - im pretty sure it can be worked out in the vertex shader somehow? :)   Sorry if its a silly question, I'm still fairly new to graphics programming!
  10. I think i'm misunderstanding something or just being inept: in the struct for my vertex shader output i've added:   float3 PixelWorldPos : TEXCOORD5;   (i'm using other texcoords for multi texturing/blending)   in my vertex shader in the first line i;ve written:   output.PixelWorldPos = mul(input.Position, World);   to try and get the world position. I've read somewhere that when passed to a pixel shader it should interpolate to give the pixel position and not just the vertex position.   in my pixel shader I have: if (input.PixelWorldPos.y % 64 == 0) { output.Colour.rgba = 1.0f; } else { and in the else it draws the pixel normally.   But all this ever does is render the entire object normally EXCEPT the very bottom line (for want of better term) which is all white. but only the very bottom. I have tried replacing 64 with 32, 8 and 2 - all have exactly the same result :/
  11.   Thanks for the reply! I did not know about that semantic and its very useful to know! in this situation however I feel it wont work for the effect i want - I would like these scanlines to go from the bottom of the model to its top so that if say I had a triangle and I viewed it from the side like /\ I would see lines going from base to tip - but if i viewed it from the top down I dont want the lines to now go from the left side to the right side for example but still be orientated in model space. I don't know if im explaining clearly though!       Have you tried the same technique in the pixel shader by passing the model's world position along with the transformed position? I.e., test model_position.y? Note: the test will have to be in world units, not screen units.     I have just got home from work and will play with this now :)
  12. thanks for the reply! in this case i want the scanlines to appear on the model and change with orientation - the overall effect when i've done everything i wanted should be a sort of hologram projection of the model.   I wanted to start with drawing it with this scan line effect. i've been programming a very long time but mostly in 2D. if I wanted to do this effect in 2D I would get the Y of the pixel im looking at and say if i wanted every other line to darken out i'd if (p.Y % 2 == 1) { draw darker } else {draw normally}   I figured I could apply this same sort of technique in 3D if i could figure out how high up the model this pixel was? but bumbling through HLSL as i am i have no idea how to get that information :/
  13. I wasn't sure if this would count as game/general programming or graphics so apologies if this is the wrong place.   I have been working on procedurally generated islands for a few weeks and am really happy with the results. The next phase is the only bit left that has me scratching my head: creating/rendering rivers.   "Generating" the rivers and deciding where they go is not the problem here. I used an idea from Amit Patel who has a blog which covers this sort of stuff and the middle of my island is always the highest part, to generate rivers I just pick random spots above a certain height then follow the "steepest" path down to the coast. But how to phsyically create these things I have no idea about and my google searching is finding any amount of theory on generation but not phsyical creation :/   I figure I need to carve a river bed in the terrain and then create a new mesh which i can render as water?   The terrain is 3d and made of quads (or 2x tri's i guess). My algo's generate a height map of sorts and then I run over it and generate the mesh. It would be sort of simple before generating the mesh to lower the height in every cell flagged as river and THEN generate the terrain - but this would restrict river bed widths to being multiples of the cell sizes which I want to avoid. Amit's suggestion is that you store a water volume property and every time water flows through a cell you increase it by 1, then the river width is the square root of the volume for that cell.   So i'm thinking subdivision - i've never done it before (this really is one of my first dives into hand made 3d, usually I use 2d tile maps!) and cant figure out how you decide what to subdivide and where the new verts go and then generating the river mesh..   I'm sure i'm over thinking this. How should I be tackling this?   Thanks!
  14. Thanks for the response!   Unless im thinking wrongly (head still = tile maps) then even if i upped the resolution of my height map each river tile would still be a "square" which would have negative consequences. IE: a river trying to move diagonally would not be great. If a river increased in width then its choices would be 1 cell, 2 cell, 3 cell etc and if a river moved from being 1 cell thick to 2 cells thick (say another river joined it increasing the water flow) then the river would quite suddenly become twice the size and not be centered (because restricted by grid pattern, requires at least 3 cells to keep river center with 1 cell flow)   So I guess subdividing is the answer... i'll have to go on a google search for how to perform it. I have my array of vertices[] and indices[] and am pretty confident I understand how I built them but head goes a little funny when i think about adding one extra vertex to what was actually an array of just triangles and then deciding what index belongs to what etc.. gonna have to be a lot of reading!
  15. Quickie: Has anyone been working on a c/c++ port of lidgren OR is there any established method of communicating with a lidgren based server using c? I know lidgren uses a custom protocal. I started writing some network services using lidgren because a) I love it and b) its quite portable but I had completely failed to look into scenarios like wanting to connect to those services from a game I wrote in c :/ Now I'm weighing up the complexity of writing a c client library or rewriting my services using basic sockets! :/
  16. PanicRave

    c++ port of lidgren?

    If a wrapper is suitable then it would be ideal as id only have one library to keep up to date! But I was concerned about the portability of wrapping managed code - for example if me or someone else is writing a native android app in c++ would they be able to use my api? I've done unmanaged to managed wrappers before but it seems weird the other way around! Lol
  17. Hi all, I have seen some simular threads here but not one that specifically gives me the info i'm after.   I would like to create a fairly simple barebones (to start with) lobby server. I have an existing, finished game that was originally on Xbox360 and used the live services. I've since ported it to pc and rewrote the network using Lidgren - it's finished and working. One player can host and another can connect to the IP and play the game. Now I want to create and host a proper lobby server, I have a pretty good idea what i'm doing but wanted to get some opinions before I charge in blindly!   What i'd like to create is a service I can use for ALL games I create - think of it as a mini (reallllly mini) battle net. So the server will be running, through admin controls i'll setup "games" it knows about with unique id's and once a client has connected and registered what game it belongs to the client will be able to send request packets for game listings (i figure a list of gameid + some string to identify it in a human way, be that host name or some name the hoster has set for his game room) and then later request full game details (ip, etc) by passing one of the ID's.  At it's most basic level /thats it/.   No multiplayer game logic, no real communication with the players once they've started their private game session (except perhaps something to say a game is in progress or has finished and remove it from list). It should be quite light.  Later on I will add leaderboard services (which my mobile apps can also use simply for online scores) and probably lobby chat - i'd like players to be able to chat in the lobby before whatever game they are playing actually starts.   Sorry for the waffle tl;dr etc but I wanted good clear explination of my intent. Here's where I want to get advice before I storm in: given I want this to be an expandable system for use in my current and FUTURE games and that any dev's hope is that their games are successful what do I need to watch out for and how should I handle the storing and sending of data in a way that scales and doesnt die if I have say 5 games using the server that are all moderately successful with thousands of players wanting to host and search for games each? Even simple game listing and basic chat can start to become an issue when 10k clients are attempting it.  I sort of figured I might store games in progress and games availible to join in a sql database? or would that be a bad idea? Just in ram would be faster to access but that could get large, fast.  Should I be looking at some sort of compression for chat strings to minimise packet size?   Any advice at all would be greatly appreciated! I could run in and "just make it" but i'm sure i'll get got by something later on.   Incidently i'm most likely to write this in c# - though c++ is also an option.
  18. PanicRave

    creating basic lobby services

    thats really helpful! I'm thinking then that a "hosted game" could go in a database because it could last a rather long time depending on the game.  However players may come and go from games quite frequently so perhaps each server should have in ram a list of online users (I have that atm) and what game they are in with the info for that game being in the database?  Its tempting to put the users that are in the game in the db though because I could store it as a hostmask, userid@server so any lobby service looking at the users list could instantly see a) what users are in a game and b) what servers those users belong to so they could easilly send chat the right way without having to traverse a peer to peer tree (eg IRC).  But that may be just too much hit on the DB when the userbase gets large.   So instead perhaps the db should store the game and who hosted it in the db, lobby servers can read that and know which server to inform when one of their clients requests to "join" and in response the server with the user who hosted can pass on a list of other users already joined and their host masks, that way user discover is one direct message and no server tree required!   So finally I guess - data that goes stale in an hour.. just to be clear do you mean data that wouldnt change or data that would cease to be useful?  for example, a User name is rarely going to change.  I could make my "online users list" just an array of database id's for looking up that stuff.  However although the username wont change it will be frequently used / useful for lobby chatter lists, announcing joins and disconnects and all sorts of other stuff... so is that a candidate for ram or db lookups?   I guess I need to know if a db read is an expensive as a db write!
  19. PanicRave

    creating basic lobby services

    sorry to drag this thread up again but working on same project so didnt want to clutter board with more posts even though slightly different question now!   I have never used a database for such high volume data before, the biggest use i've ever put a db too is a forum. So atm i've been weighing up what data to store in ram and what data to store in DB, especially if I end up spreading the load over a few servers.  I guess im "choosing my bottleneck", wether ram or db, and im really uncertain to what extent I can push a db!   tl;dr - should I store games players are hosting (and unhosting) in the database? or just user data (llogin/pw/email/stats/etc)? anything I should be aware of?   Thanks :)
  20. PanicRave

    creating basic lobby services

    hmm, the reason I went with that method (vs ssl etc) was after reading your chapter on networking and seeing Challenge Hash Authentication sold as a "major benefit" and indeed with no passwords being sent to sniff etc the ONLY downside I could see was the server storing plain text.  I was not okay with the idea of plain text so my idea was that all passwords would be hashed server side by a secret key inside the server software itself so if someone DID get access to the db they would have hashed passwords and would need to then steal the actual software off my server and then reverse engineer it until they found the key.. or is there something much simpler they could do? I figured a large enough "secret" would prevent brute forcing, at least on any level anyone would bother here.  Would you say this is not sufficient and you'd still go for TSL/HTTPS?   I really like your optimisation suggestions, obvious when read but probably wouldnt of got them any time soon by myself!   At the end of the day this is a multiplayer lobby. It does NOT handle any game logic at all - if a hacker got in the worst thing they could do is steal a users account, change their password and maybe delete their friends list or intentionally behave bad on lobby chat to try and get a user banned and invalidate their acheivements etc.  I'm not sure how far I should take security - those things are certainly bad but not quite on the scale of "now I have your credit card information"!   edit: as I intend to run this from the azure cloud I believe I can trust microsoft with my data, even if I cancel my service later on :) there is also a default amount of redundancy using the cloud. but if I go the VM IaaS route as I intend then I guess the ultimate security of my server is down to my own configuration!
  21. PanicRave

    creating basic lobby services

    Okay, well fair enough. It's just a "take every edge you can get" mentality in a world where malicious attempts on anything internet are inevitable :)   But for the benefit of the forums then, these are the steps i'm intending to take to authenticate and join a lobby. I really appreciate your feedback on it as although I have nearly two decades of programming behind me I do not have much experience with networking so this is a bit of a new avenue for me!   This is assuming a user account has already been created (probably through a web page) and there is an SQL db with the login name and a password hashed with a "server secret" to avoid ever storing plain text passwords.   client connects to login server login server sends random challenge number to client client computes hash of challenge combined with a user supplied password and also sends a login name login server looks up client by login name, de-hashes stored password using "server secret" and rehashes the sent challenge + stored (now unhashed) password and compares to hash client sent. if password okay, login server generates an authentication ID, stores it on the sql server and sends client a ticket with their auth id, their user id and IP of server to connect to (could do load balancing here by smartly choosing different server ips?) client disconnects from login server and connects to new ip given for lobby server lobby server asks for user id and authentication token client sends requested information lobby looks up user id, read authentication token stored by login server and confirms that users auth token matches and has not expired, sends an "all okay" to client. Client may now perform lobby functions like send chat, receive chat, list games, etc. Periodically lobby server should request auth token from client to ensure no "man in the middle" injection and everything is as should be - correct supply of token extends expirary on that token. Any token that expires should auto boot the user attempting to use it out.   My main concern is whether just accepting commands from the client after an auth token has been confirmed as valid and then occasionally checking that whatever is talking still has the valid auth token is sufficient runtime security - the alternative seems to be prefixing every packet with the same auth token but it just seems like alot of extra data to be sending all the time?
  22. PanicRave

    creating basic lobby services

    hplus0603 - would you mind if I sent you a short private message? I believe I have worked out how I wish to do my authentication and logins etc and would like an expert opinion incase I missed something - but as silly as it sounds i'd rather there wasnt a thread bullet pointing exactly how my security works incase I go live and it's later found and gives someone with malicious intent a little edge :P
  23. PanicRave

    creating basic lobby services

    hmm, containers sound very interesting!   I learned a long time ago to not just ignore the advice of experienced dev's just because it doesn't match my original idea and a prevailing theme from everyones replies has been to have a seperate instance of the lobby server for each game using it. I'm really taking that on board but I have a few questions specifically about it :)   My original concept for the one instance was having a sort of start-it-and-leave-it-alone server that through a control panel (be it local or through a web interface) I could add "game" instances to it which it would give a UID to identify and I could configure some basic information such as if I add achievements later on a list of such achievements for that game, etc etc. Later on I might add a very basic friends system so people could see when their friends were online and what game they were playing using this lobby. I can still do all of that with seperate instances as long as they share one common database of course.   But what if I said that in the back of my mind is the vague idea that if this works and prooves stable with my games that I may in the long term offer the service to other small indie devs who need a bare bones framework for game discovery in their multiplayer games but are not using steam or LIVE and can't afford the starting cost for services like smartfox (and do not need the excess of features!) or the VM/Cloud subscription fees? Would you still suggest a seperate instance for each game? That could become.. quite alot of instances if it took off!   If I keep as one instance of the server, reading and storing data to a SQL db and then sending it to connected clients (but never doing game logic and having nothing really to do with games that have been "started" except an occasional poll to see if they still exist if game requires "game in progress" to be visible for additional players to join) then what sort of problems should I expect to encounter? Programmatically its a very simple thing to add multiple games to the server, it's just one more level of structure (ie instead of "foreach gameroom" it becomes "foreach game { foreach gameroom } }") so I am assuming that people suggest a seperate instance for each game for phsyical reasons such as processing and memory constraints? What else do I need to know?   So many thanks from me to everyone involved in this discussion, it's been a treasure trove of information :)
  24. PanicRave

    creating basic lobby services

    really, really good read! I feel pretty confident about tackling user authentication now, thanks! Infact overall I feel pretty good about prototyping this server now and giving it a spin.  I do have one last question for you though:   Given that this servers job is ONLY to register and list hosted games and later perhaps provide lobby chat and some other basic lobby functions - what sort of CPU power and ram am I going to be aiming for?  Azure lets you be very specific in what you need when it comes to number of cores and amount of ram.  With most of the data stored in a DB instead of active memory im thinking lots of ram isnt a requirement, but i've never really considered how CPU intensive network traffic is *scratches chin* what do you think?
  25. PanicRave

    creating basic lobby services

    Firstly: thanks for your reply, some good information there! :)   I'm intending to host this service on the cloud (microsoft azure). I am part of the bizspark program so for a couple of years I get $150 of azure credits every month so it provides the perfect platform for testing the viability of this software I think! I was intending to have a single server to handle a multitude of games as it seemed to fit well with what I understand of cloud computing where an application can scale and be granted (or removed) extra resources as and when required.   NAT Punch through is definitely something I should look into and had not considered.   The truth is I know that right now I can sit down and write this software straight away and i'd have no concerns if it was just for a single game because if I do something inefficiently it would be unlikely to ever show with todays computing power and high speed internet etc. But with this goal of being able to, for sake of argument, "infinitely scale up" adding more games each with their own player base I find myself questioning myself and what I know and what is the best way to store data (despite the fact I know SQL is used for HUGE performance critical programs, silly me!) and wonder what sort of pitfalls there are that I have never considered!   I'm going to go google for this TLS/HTTPS session key method you suggest for authentication - do you possibly have any links to useful articles on it or any subjects related to this task that you think I should read?   Thanks )
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!