Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Mar 2012
Offline Last Active Nov 06 2015 08:51 AM

#5051103 Where do I start?

Posted by metsfan on 07 April 2013 - 11:40 PM

Where do you start?  Well that's a loaded question my friend.  What are your goals?  I think the first question you need to ask yourself is the following:  Do you want to make a game engine, or a game?  The two are very different.  You talk about wanting to create an application where you can load 3D models, "walk around" (which I assume means you want animation), and a "battle system where you can kill things".  The first two parts, fall in the domain of game engines, the latter part in the realm of games.  You don't necessarily HAVE to make your own engine, but if you do, you're in for a ride.  


If you want to build an engine:

The first thing you need to do though, is learn the graphics pipeline.  You aren't getting anywhere until you understand how 3D graphics applications work.  There are many places to learn this: books, this forum, internet tutorials, ect.  One of the biggest mistakes I made early on was just wanting to "see something on the screen", without understanding why or how it got there.  I did lots of copying and pasting from tutorials until I got something there, but once I did, I couldn't make the changes I wanted because I never really understand what I was working in.  Learn how the 3D graphics world works, then worry about getting models to show up, and animate.


If you just want to build a game:

Find yourself a nice, free open source engine.  There are a few choices out there, and a quick search of this forum or google should yield you some useful results   Once you get the hang for using this engine, you should be able to load your models, and then you can start programming your game logic.   However, before you just dive in and start making a mess, I strongly suggest you learn about application development, particularly how to separate your view logic from your application logic.  This will save you a ton of time in the long run.  


I don't know how much of this information will be useful to you, but I hope you take one thing away from what i've said:  Making games is hard, and making game engines is even harder.  The hardest part isn't even writing the code, it's planning it in such a way that you create flexible systems, and it's about understanding the systems you're working with so that you can create new systems through understanding, not trial and error.  Good luck.

#5049602 Am I the only one that finds OSG's code disgusting?

Posted by metsfan on 03 April 2013 - 10:28 AM

So I've decided that as an exercise to learn more about engine development that I would develop a platform-independent scene graph with the ability to have renderers for multiple rendering systems.  I have heard much praise from OpenSceneGraph, so I decided to have a look at their code for ideas and inspiration.  


What I found instead was a sea of bad code.  In particular my gripes were:


1) Tons of protected member state.  This opens a HUGE potential for problems later on, and would require massive refactoring if the underlying base classes ever changed.


2) Every object extends from a "base object" (similar to Java), and supports only manual reference counting.  I once considered a system like this, and came to realize (with the help of others) it causes nothing but problems in the long run.  Why OSG?


3) Exposing getters and setters for properties that have no business being exposed.  Literally every bit of internal state can be modified through a setter, and in some cases it's extremely inappropriate.  The idea of private state is practically nonexistent in OSG.


4) I was expecting an abstraction of OpenGL, and found only a thin wrapper.  The idea that OSG could ever support another rendering library is basically impossible at this point.


Now this isn't to say I didn't take away anything positive from my dive into their code.  In fact there were several things I liked.   But overall, wow what a disappointment that was.  Is this the feeling most people get when they look at OSG's code, or am I just being too critical?

#5048183 Where to begin on first game

Posted by metsfan on 29 March 2013 - 06:15 PM

Whoa, you're getting way ahead of yourselves.  You're talking about game subsystems and you haven't even decided on an engine yet.  First decide HOW you are going to build your game, then you can decide on the parts after that.  


Once you have decided on your language, and platform, you should decide if you are going to be building your own engine or leveraging a 3rd party engine.  If you don't use a 3rd party engine, you will have to build abstractions around many things yourselves, namely: audio, networking, rendering, user input, GUI, utilities, as well as a few other things I've surely forgotten.  Not to mention, there is a fairly large middle ground.  You can use certain software packages called "middleware", so that you can implement your own engine, which customizes the game engine in ways that suit your specific game, but implement generalized functionality for certain parts. As an example, I am building my own engine, but I use FMOD to manage the audio, as that is a particular area that I have no interest in interacting with.  However, when it comes to the networking, I have decided to manage this myself, as I don't feel like handing control over to a 3rd party library would make sense for my particular game.


Once you have decided whether you are going to use a prebuilt engine, build a frankenstein (some middleware and some of your own stuff patched together) , or totally from scratch, THEN you can decide how to build your game.  


Overall, I would say the first thing you need to decide is how you are going to drive your game's data.  Every game is data driven.  You have levels, enemies, objects, players, NPCs, ect.  You need to decide how you will load these different types of entites into your game.  How you will serve them up to the player.  And of course, how you will store them so they can be accessed the next time the game is loaded.  


Once you have a good architecture for the data driven section of your game, you must then decide how your players will enter the game.  Will there be a login screen?  Will they start a new game from a selection screen?  Will there be options?


Here's all I'm going to say from here: if you've gotten this far and you still want to make a game, come back here.  We will help you.  But until you have got this far, you aren't ready to make a game.

#5048026 What is functional programming and how can it help us in game developing?

Posted by metsfan on 29 March 2013 - 10:26 AM

For one thing, functional programming typically handles multithreaded situations much better because of the lack of mutable state.  As a result, things that you typically would do sequentially, you can spread out among multiple threads, and you can thread by task.  Also, the idea of functions being first class citizens can be a useful paradigm when trying to move away from an global event manager model (which I have grown to hate).  Just a couple of ideas, there are more.

#5044031 Anyone here a self-taught graphics programmer?

Posted by metsfan on 17 March 2013 - 02:41 PM

Self taught grahpics programmer here.  I learn mostly from books, whitepapers, and additional help from internet forums  (such as this website, and StackOverflow's gamedev section) when I have trouble finding the answers on my own.  There is more than enough material out there to learn.  I find the best way for me to learn is to pick small projects and try to accomplish them, then work your way up to bigger projects.  A good exercise to get started is to create a mini graphics engine (just the very basics, simple abstraction of shader programs, vertex buffers, textures, and the graphics context).  Then you can use this engine to power your testing and development.


Best of luck.

#5044030 Image class still needed ?

Posted by metsfan on 17 March 2013 - 02:37 PM

It really depends on what you need to do.  For instance, let's say that I want to apply an alpha mask to an image.  If the mask changes often, or if I want to maintain the original image without the extra memory overhead of creating a copy, then applying the mask on the GPU makes sense.  However, if the mask never changes, it only needs to be applied once, and it isn't necessary to maintain the original image, then it makes sense to do it on the CPU, and save my GPU clock cycles for things that actually do need to be computed every frame.  It's a matter of what your needs are.   Really this is the question you should be asking yourself:  "Does this NEED to be updated every frame, or is this something that can be computed once, cached, and reused?"  

#5043126 Gain experience by learning(studying) or by doing?

Posted by metsfan on 14 March 2013 - 01:08 PM

Why not both?  I read during my commute to and from work, and I code when I get home.  Best of both worlds.

#4991791 What version for a new project?

Posted by metsfan on 19 October 2012 - 08:54 AM

I'm starting a new project and I know that not all cards support DirectX 11, but the differences between DirectX 10 and 11 from a programming point of view are very different, so supporting both is likely not going to be possible for me. With that said, is it better to use DirectX 10 or 11 for this project? My target release date is about a year from now, so please take that into account as well. Thank you.

#4986975 How to measure the time it takes to evalueate an expression

Posted by metsfan on 04 October 2012 - 07:09 PM

Would the result be inaccurate because it is such a small difference?

There are high precision timers (on windows they are called "Multimedia Timers") that can give you i believe at the microsecond level (might even be nanosecond though at that level it probably would be inaccurate). Why do you need such a precise timing for only a single operation? If you are trying to figure out the clock speed of the user's processor there are better ways.

#4986886 A good discrete mathematics book/site?

Posted by metsfan on 04 October 2012 - 02:34 PM

How much information do you need? Just give me a recommendation on a discrete mathematics book, I'm not telling you my life story.

There are much more helpful ways to ask for help from complete strangers who have no good reason to help you other than out of the goodness of their heart. A bit of information on the types of problems you are trying to solve would have been helpful, and would have been beneficial to you as you would have got better answers.

#4984368 Math API performance: saving CPU cycles?

Posted by metsfan on 27 September 2012 - 08:41 AM

That's honestly pretty irrelevant. We always knew that a good low-level programmer can achieve better performance through hand-coded assembly, but few people have that kind of skill set (or the time and energy to apply it to their entire project). The fact that the general case is faster for the JIT than for the AOT compiler, says a lot about how far JITs have come.

I didn't mean that a programmer could achieve better results through hand coded assembly, I think the point that I and those commenters were making is that unless you post the output assembly for the benchmarks, there's no way of knowing if the computer is really doing the same thing in both cases. If I understood correctly what people were saying was because the benchmark test was just buffering a string and never actually doing anything with it, that the JIT compiler was likely optimizing out the entire benchmark test. However, without the raw assembly output, we'll never know. That's all I was saying.

#4980625 Game Engine Architecture, Separation of Application, Game Logic,& GameVie...

Posted by metsfan on 16 September 2012 - 08:03 AM

Events and messages suffer from these same problems. If you are not careful, you will end up with all these managers bouncing events and messages back and forth and you won’t be able to debug it, you won’t be able to keep track of all the types of events and messages you have added and avoid conflicts, you won’t remember the reasons behind choices you made years ago because they are all just numbers, etc.

I appreciate what you are saying here, but at the same time, you don't offer any alternatives. Games are a complex web of events no matter how you cut it. You can't ever make a game, especially a big one, with perfectly clean logic that will be obvious when you pick it up again in a year. In fact, I don't think you can write ANY program without sometimes forgetting why you did something you coded a year ago. You just have to write good comments, and document your event system so that if you or a new person are looking at it later, you know what's going on.

I will say though, if you have an alternative to an event-based game engine, I would love to hear it because it could only serve to make me a better programmer.

#4971838 Finding the object a user clicked on

Posted by metsfan on 21 August 2012 - 08:39 AM

Hello all,

I am trying to devise an algorithm to which object in my 3D world the user clicked. If two targets are close to eachother, the one closer to the near plane will be chosen. Here is my thought process for how to build this algorithm, and I just want to make sure I'm on the right track before I get too deep into this

My near distance on my view frustum is 1.0

1) Determine the direction vector between the origin and the spot clicked on the screen. This is done by calculating the following values:
[source lang="cpp"]float rayX = (position.x / halfWidth) - 1;float rayY = -(position.y / halfHeight) - 1;float rayZ = 1.0f;[/source]

This produces a ray with values -1 <= x <= 1 and -1 <= y <= 1. The z-coordinate is equal to the distance to the view frustum near plane.

2) Transform the near plane by the inverse transpose of the (modelview * projection) matrix

3) Calculate the intersection point between this ray and the transformed near plane.

4) From this intersection point create a ray with the intersection point as the start point of the ray, and the vector (0, 0, 1) as the direction vector.

5) For each object that is clickable, test if the ray intersects the bounding volume of the mesh

5a) if more than 1 match is found, the intersection point with the closest z coordinate to the near plane is chosen.

Am I totally off here? Am I close but need some tweaking? Am I greatly overcomplicating this problem? Any help would be great.

Thanks in advance.

#4969483 3D Game Math Books?

Posted by metsfan on 14 August 2012 - 08:58 AM

Is it very OpenGL oriented, or is it perfectly fine to use with DirectX 11 too?

It's remains fairly agnostic, but whenever he does choose to refer to a graphics library, it's usually OpenGL. For the most part though, the book is about math and concepts, which can be applied to any graphics project.

#4950583 Structure of classes in good Game Engine?

Posted by metsfan on 19 June 2012 - 08:28 AM

That's fine, each style to it's own, but this is still an arbitrary choice by the API designer to use a singleton as a restriction on the end-user developers usage. You could replace the UIApplication singleton by, inside main, making local variables for a window, an event queue, a URL fetcher, etc... and then having the choice weather to make them global variables (e.g. via a singleton) or not, ourselves (i.e. the end-user of the API).

I suppose your right that it's not a requirement that a singleton be used, but at the end of the day, it makes the API easier to use. I'm not saying singletons are the solution to every problem when it comes to needing dependencies throughout your application, but it does make sense from time to time. I am also of the belief that if you are trying so damn hard to not use a particular design pattern that you end up bending over backwards, you should probably take a step back and wonder if you aren't just being a bit evangelical and maybe just maybe that design pattern exists for a reason, and you should stop trying to fight its use in a legitimate use case. I doubt we will ever see eye to eye on this though, so I'm going to gracefully walk away and say, let's agree to disagree Posted Image