Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 May 2006
Offline Last Active Today, 02:58 PM

#5250615 C# 3D graphics engine needed - with polygon picking? Where to start?

Posted by GuyWithBeard on 04 September 2015 - 03:34 PM

Again i am surprised that picking is not a more commonly available feature, if not the graphics library then something els.


It's not that it isn't "available". It's just that it's such a small and specific thing that it's not advertised as a "major feature" of any given game engine or toolkit. It's the same as car manufacturers not making a deal out of their cars featuring blinkers.


I would think that any half decent game engine allows you to select polygons by picking, so just select the one that you fine nice otherwise and then find out how to do the picking. It helps if the engine has a user community as then you can usually find tutorials or code snippets on the internet but, as I said the picking could be done completely separately, bypassing the graphics engine completely.


I have worked with a couple of in-house game engines that actually provide ray casting (which can be used for picking among other things) only against the physics objects, rather than the graphical objects. The physics objects are usually a lot simpler than their graphical counterparts, in terms of number of polygons and vertices, so they don't line up perfectly with what you see on the screen. This is another reason that I tend to think of picking as not being part of the graphics engine.


That said, if you really want to select visual polygons you can do it with the technique I described above. If you are unsure about the math just ask, or do a google search using the steps I provided as search terms. Also, depending on how complex your scene is, you might be able to skip the AABB test completely as it is just an optimization and go straight from the ray construction to ray-triangle intersection, iterating over all triangles in the scene.

#5250450 C# 3D graphics engine needed - with polygon picking? Where to start?

Posted by GuyWithBeard on 03 September 2015 - 12:08 PM

To be honest I don't know why you make such a big deal out of the polygon picking. I don't even consider that part of the graphics engine. You can do that with a little bit of math, for example a simple way would be:

  • Construct a picking ray with an origin and direction. For this you need the camera view and projection matrices and a way to select a 2D screen coordinate on the window (which should be easy enough in Winforms)
  • Iterate over the objects in the scene and do a ray-AABB intersection test against their bounding boxes
  • Select the object with the closest hit
  • Do a ray-triangle intersection against the triangles of the object
  • Select the triangle with the closest hit

The above technique can be optimized in a number of ways, but that is generally what you need, and it is the same regardless of the graphics engine or API used.


As for rendering into Winforms, that can be done with almost anything. For example, my engine is a standard Win32 application but I can attach it to a Winforms app and run it as an editor, basically rendering into a Panel Control in winforms, the window handle of which is passed to the engine process. In the past I have used Ogre through the Mogre wrapper to render into a winforms application.


If you like one of the toolkits that you listed but you were missing the picking code I suggest writing that yourself. It is only a couple hundred lines of code. And you should be able to find tutorials for doing that on the internet. Eg. Frank Luna's DX11 book has a chapter on picking and the code can be downloaded from this site:



#5237332 Implementing multiplayer in MOBA-like game

Posted by GuyWithBeard on 28 June 2015 - 03:21 PM

There is nothing preventing you from writing the whole thing in Java if you want. There are OpenGL wrappers for Java that you can use for that.


However, if I understand correctly, you would like to have some sort of networking layer on the client, written in java, which would mediate between the server and the client front-end (written in C++ or something else)? Sure, that is possible but then you have three parties involved instead of two and that might not make it that much easier.


In fact, in my engine, the level editor front-end is written in C# and the main engine is C++, and I actually use the network to have the different parts talk to each other even though they both run on the same machine. I find this more elegant than marshalling memory back and forth, and while it makes everything asynchronous it has not been a problem for me.


If you just wrote your whole client in C++ and have it talk to the Java server you would be in the same situation where you just send bytes over the network and have the receiver do something with them, regardless of what language it happens to be written in. I don't really know what you mean by "C++ networking" since it is all about sending and receiving bytes, but there are a number of good networking libraries for C++ that can help you if you don't want to be writing pure socket code.

#5237323 Trying to emulate "typical" internet conditions

Posted by GuyWithBeard on 28 June 2015 - 03:06 PM



I am looking over the netcode in my game and trying to make it more internet friendly. The game has been mostly tested in a LAN environment, where it works fine, but I would like to see how it performs when played over long distances, eg. over the atlantic.


I found the SoftPerfect Connection Emulator which seems very nice when it comes to emulating problems that might arise when sending data on the internet. Using it, it is very easy to completely break my simulation, so it seems I have some work to do still. However, before I start I would like to know what is a reasonable target. I would like to create a preset for the emulator that I can run every time I have made improvements to my netcode to see how well the game performs.


For example, I have a preset that have the following parameters:


- Speed limit: 768 Kbps (DSL)

- Latency: 50-100ms

- Packet loss: 1%

- Duplication: 0,1%

- Reordering: 0,1%


Now, I know it is very difficult to say "how well the internet works", but would you consider that a fair target to aim for? Ie. if I got the game working with those parameters would that be okay for general internet play, or should I aim for even worse conditions? My target audience (if there is such a thing) would be mainly european and american players, so I would have to prepare for transatlantic communication.


Thank you!

#5211187 DirectX 11 UI Library

Posted by GuyWithBeard on 17 February 2015 - 09:00 AM

Some years ago I was in the same situation and I ended up writing my own system. That said, there are a few libs you can use. I have had all of the following integrated into my engine at one point or other:


https://github.com/garrynewman/GWEN - GWEN is a very simple UI layer with nothing extra. I don't think there is a DX11 renderer, but it should be farily simple to implement.


http://cegui.org.uk/ - CEGUI has been around for a long time, it is mature and diverse, but perhaps a little old-fashioned. Also it tends to bloat your project quite a bit.


http://www.awesomium.com/ - Awesomium is really an offscreen HTML5 renderer rather than a UI library, but it can very well be used to do UI. In fact, that is exactly what I did and I enjoyed it quite a bit. However, I cannot use it anymore since they don't provide any 64-bit windows binaries. Also it is not open source.

#5201724 Writing a game in Erlang, tips wanted!

Posted by GuyWithBeard on 04 January 2015 - 07:08 AM

Hey folks! The title says is all: I am thinking about writing a game (or a tech demo, or something) in Erlang and I'd like some tips. Before you dismiss me as crazy, let's start with some background:


I am a fairly experienced game programmer, having worked on and shipped games on various platforms, as well as written a number of game engines in my spare time. The games/software have almost always been real-time and they have been developed using well established tools, such as C++/C# and a bunch of well known middleware.


Lately, I have been getting more and more into the area of parallel programming (like most of us these days) and I have written a few systems for making parallel programming easier, such as job/task systems etc. However, I have been hearing about Erlang for a long time, especially when it comes to concurrency and I have always been a bit sceptical, perhaps because it still has not really been picked up by the game developers, a bunch who are REALLY into concurrent programming these days. And I would like to find out how good Erlang really is, while at the same time educating myself in functional programming.


So, I decided to look at Erlang myself, to see just how well it works as the main programming language of a small real-time game or tech demo. The thing I am thinking about writing is a small app with a height field fluid simulation that the user can interact with (ie. throw objects into the water and see nice looking waves and ripples appear). It should be farily easy to make the simulation code for the fluid simulation run concurrently on top of Erlang's concurrency model. (And before you say anything, I am quite aware that it can be done efficiently on the GPU, in fact I have done that. I want to see how well Erlang does it).


So, what I'd like you to do is throw any good internet articles, tips, stack overflow answers or book recommendations, covering Erlang and game programming, my way. I am talking about things like; how to set up the main loop in a way that is Erlang friendly, how to hook into OpenGL, how to handle input etc etc. I have a bunch of good books covering Erlang/OTP, but none of them (unsurprisingly) cover game programming.


I am hoping this might help other people interested in Erlang, functional programming and/or other niche technologies not really used within the games industry (except perhaps on the server side).



#5193077 Best Way to Learn 3D Computer Graphics? Help!

Posted by GuyWithBeard on 16 November 2014 - 04:03 AM


this book: http://d3dcoder.net/d3d11.htm and working your way through the examples


Luna's book is an excellent resource. Note, however, that his projects are based on the (deprecated) DX SDK (June 2010). It's certainly a private choice, but, IMHO, a D3D11 beginner may as well just use the Windows SDK, perhaps using the book as a reference. Luna's projects were created with VS2010, and they don't necessary upgrade well to later versions of VS.



Using the Effect Framework: http://blogs.msdn.com/b/chuckw/archive/2012/10/24/effects-for-direct3d-11-update.aspx, almost all chapters in the book can be compiled and run on the newest SDKs. Luna also has samples for creating windows store apps and using shaders without the effect framework on his web site, here: http://www.d3dcoder.net/resources.htm


I suggested the book because it covers a lot of the essential math topics needed for graphics programming, regardless of APIs and SDK versions.

#5192958 Best Way to Learn 3D Computer Graphics? Help!

Posted by GuyWithBeard on 15 November 2014 - 03:30 AM

May I suggest getting this book: http://d3dcoder.net/d3d11.htm and working your way through the examples as you read it? Be sure to understand everything before moving to the next chapter. It will teach you the necessary math while focusing on the "fun stuff" ie. programming.

#5171460 Where should I start? (2D Game Programming)

Posted by GuyWithBeard on 04 August 2014 - 12:53 PM

That's also another broad statement. I have been able to code anything I've ever wanted in Java without ever touching a doc, thanks to the great community support and millions of working examples on websites such as YouTube that will teach you how to do things correctly. However with C++ there seems to be much less resources like those I found for Java, and it's much more complicated. That's why I'm trying to get help.  


It's not a broad statement at all. The fact is, if you think that reading the docs takes too much time, then you need to adjust your attitude. And just because you have supposedly "been able to code anything you have ever wanted" without reading any docs, it does not mean that you can keep doing that. You have been lucky (not that I consider it unlucky to have to read the docs).


Now, if you would have read the docs for the connector you would have found the line that says "As of MySQL Connector/C++ 1.1.0, the Boost C++ libraries 1.34.0 or newer must be installed.". In other words, the errors you are getting are because you are missing the boost library (or the IDE cannot find it because of incorrect include paths or something).


You can find the whole thing here: http://downloads.mysql.com/docs/connector-cpp-en.pdf


Seriously, next time check the docs (or at least do a google search). Also, remember that we all really want to help you. GD.net is an awesome community, so try not to get offended when someone more experienced gives you a gentle nudge. Good luck with your project!

#5171234 Where should I start? (2D Game Programming)

Posted by GuyWithBeard on 03 August 2014 - 02:26 AM


The easiest way to use MySQL from C++ is probably through the connector


I've tried the connector countless times in the past, all I get is errors. Then when I ask for help, people just point to the documentation, and tell me to read it. I don't have time to read the documentation. I read it anyways, and it was still a waste of time because I never got my problem solved.



Okay, well I have used the connector successfully in multiple projects, so I can tell you it works. I did ask you what problems you are having, but you did not answer me.


Also, you don't have time to read the docs? Seriously, with that attitude you won't get far with game programming. It takes time, lots of it.


Now, what was the exact problem?

#5171087 Where should I start? (2D Game Programming)

Posted by GuyWithBeard on 02 August 2014 - 07:27 AM

Especially since in order to use MySQL in C++ you have to use a windows form application. You cannot use MySQL in a normal "empty project". :/ any help on that would be appreciated.


That's not true. You can use MySQL from any sort of C++ program you wish, from Win32 console applications to graphical applications. What sort of problem are you having?


The easiest way to use MySQL from C++ is probably through the connector: http://dev.mysql.com/downloads/connector/cpp/

#5160832 getting a job with sdl?

Posted by GuyWithBeard on 16 June 2014 - 07:00 AM

Your game will not be "made in SDL". It might use SDL for a certain task, such as capturing input or managing threads. Now, both of those things are easy to do with SDL and they both require quite a bit of work without SDL, but they are still only a very small part of all the code that goes into making a game.


As for getting a job with the knowledge of SDL, not really sure what you mean. Knowing JUST SDL will not get your far. Does knowing SDL help? Sure. A lot of companies use it. Eg. Valve uses it for their cross platform stuff. Actually, IIRC, the original author of SDL works for Valve.

#5159295 Starting game making help

Posted by GuyWithBeard on 09 June 2014 - 11:15 AM

Okay i'm gonna learn java now, start small and just grow.
Is this a better idea?


Yes, good luck!

#5156666 How do I change the rotation mode in Maya (LT) to world space?

Posted by GuyWithBeard on 29 May 2014 - 03:38 AM

The docs for Maya says that the rotation tool can operate in different spaces:




Currently I can rotate my model in local space, but I would like to rotate it in world space, and I cannot figure out how and where to change the rotation mode.


I tried googling but with little success. Can you help a poor guy out? Thanks!


EDIT: Nevermind, found that double clicking on the tool icon opens up the tool options menu.

#5131572 Keeping my water simulation in sync over the network.

Posted by GuyWithBeard on 15 February 2014 - 11:05 AM



I am implementing height field water simulation in my multiplayer game engine. The system I am using is roughly the one described in this paper:




In a nutshell, you have a height field where each element in the field represents a vertex on the water surface mesh. The water surface interacts with the rigid bodies of the physics engine, and they in turn affect the water. The server runs the physics at 10 FPS with the clients at 60 FPS. To cope with small differences in the physics engine on every machine, the server sends the updated transforms to the clients every so often and the clients correct themselves accordingly (with some smoothing and prediction added so all looks nice and smooth).


My question is, how should I propagate the water surface height values from the server to the clients? We are talking about something along the lines of 128x128 floats, so sending them all every tick is not an option. I was thinking I might put every element in a randomly selected "update bucket". Every tick (the server is normally ticking at 10 FPS) a bucket would be sent across the network to the clients. Since the vertices would be randomly selected you would never see an "area" of the water suddenly get updated.


The water tends to affect other objects slowly so the update does not have to be immediate, but somehow I have to prevent the whole sea from going out of sync with the server over time. What do you think of my proposed solution? Any other ideas?