Building a 3D Game Engine using LWJGL - in 3 months?

Hi guys,

I am just looking for opinions and experiences on this - my final year University project. Ideally, my project is to create a basic 3D game engine (i.e. FPS) in around 2.5 - 3 months. I say basic as it doesn’t have to be amazing, it can be something simple, with basic collision detection and what not.

However - is this possible in the time given, which is around 2.5 - 3 months (spending around 25-30 hours a week on this)?

It was a throw up between a 3D and 2D engine and in the end I decided the 3D engine would get me the most marks due to being more technical and complicated compared to a 2D engine… however it is no good if it is honestly far too much work to complete in the time available, and this is what I am most worried about. I am fine for learning the required maths, but I just think that doing the graphics and building a small 3D world would take up several weeks and not leaving enough time for other game engine features such as lighting, shadows, collision detection, sounds, input etc.

I have numerous books, including one that has a walkthrough of building a basic 3D world in JOGL - I would probably try to convert that to using LWJGL and I have ordered a textbook on OpenGL (OpenGL Superbible) to be delivered tomorrow.

So yeah, a 3D engine is definitely a project that will get me the best grades from my tutor (and although I have had little graphics programming experience, I have four years Java experience) but I am just SO worried it will not be achievable!

All opinions and advice absolutely welcome!

Thanks everyone! :slight_smile:

Just set boundaries. Work out a very simple game, something you feel you can implement in a rainy afternoon. It’ll probably take a week or two. Work from there, incrementally: ‘release’ something that works every week, after two months you’ll know where your project will end up. Keep it simple though, very simply. Don’t even try to add terrain, trees or grass to your world, making any of those three look good and fast can easily take 3 months.

That was actually very useful, I’m about to properly plan my project week by week so I’m going to make sure I keep everything really simple (despite wanting to show off, I suppose just the code required for something simple is still impressive).

Could you recommend any good resources/the best library to use? Obviously I’m looking at LWJGL, but I’ve also looked at Java3D (which I know is different), JOGL… they all seem relatively the same, are there any major differences/disadvantages to choosing one over the other to use?

IMO, avoid Java3D

the two others are both good choice, and your project success will be in both case more relative to how you build your game/project architecure than the API you use (ideally if you well prepare/built it you should be able to switch from one to another at low cost/time)

Yeh agreed, Java3D is pretty much dead and best avoided, but if you are looking for a java library or engine, the following snippet from the old JGO wiki has some useful links.

[quote] 2D Engines and Libraries
Slick2D (Hardware Accelerated 2D Games Library)
PulpCore (2D Games Engine, especially good for Applets)
LibGDX (2D and 3D OpenGL library, both desktop and Android support, and more)

3D Engines and Libraries
Ardor3D (Java based 3D engine)
JMonkeyEngine (Java based 3D engine)
jPCT (Java based 3D engine)
LibGDX (2D and 3D OpenGL library, both desktop and Android support, and more)
Clyde (For creating action-oriented networked 3D games in Java.)
Xith3D (Java based 3D engine)
Ogre4J (Java binding to the popular C++ engine Ogre3D)
3DzzD (Java based 3D engine for webpages)
[/quote]

You could use libgdx. It provides access to OpenGL through an abstraction layer over LWJGL, JOGL, Android, and others. There is no problem developing a desktop only game with it though. It provides more than either LWJGL or JOGL, which mostly just provide access to OpenGL, input, etc. libgdx has texture loading, sprite batching, VA/VBO helpers, font rendering, texture atlases, particles, etc.

Could a 3D engine be developed using libgdx?

My idea of a game engine is really something that is a very very simple generic game… and that has an API to supply methods to a developer to use this generic game and extend it through the features available (i.e. load in their own textures, content, choose whether or not there should be a timer, leaderboard, which features a game should have etc).

Is my idea roughly right? (It’s less focused on graphics and more on the coding of creating a basic game, the ability to create a basic game and add whatever features the developers choose and to provide a very simple way to do that)

With graphics, I didn’t really want to “reinvent the wheel” (I am not a graphics student nor have that experience, my tutor didn’t actually recommend me learning all of the mathematics required as he thought there would be something available to do that - not that I have a problem learning if required) but focus more on building a “generic” game that can continuously be extended and be simple for a developer to take and develop their own game.

I’d advise you to use a pure OpenGL binding like LWJGL… the major advantage is that you can read endless amounts of tutorials on OpenGL (like NeHe) and basically copy and paste code, messing around, until it works.

When you work with some existing engine (I thought your goal was to create a game engine…? for a tech demo, not a game?) is that you’ll never learn the basics. Any time you run into trouble you have to ask the (community of the) maker, bad thing. Stick with pure OpenGL and you’ll have vast amounts of resources to dig through. (and irc.freenode.net #lwjgl for instant help on OpenGL and LWJGL)

If you want to make a 3D world engine thing, think about the basics of how Minecraft is implemented.

Cas :slight_smile:

Riven: Well that is where I could be a bit confused… or possibly worded my idea a bit wrongly. If I was to create some simple 3d game engine with collision detection (and again basic, to stop say the camera/something walking into an object in the 3d world), to demonstrate it I would have to create a simple game to use it/go along with it, no? (Unless this is what you meant by tech demo).

To give the origins of how this project started about… I was going to do a game however my tutor thought this would not flex my skills enough and for that good grade I should go more “general”… instead of having character X with ability Y in world Z… to be non specific and allow character X to be any character… ability Y to be any ability and to provide that in the form of some sort of engine that a developer could use to implement characters, abilities, worlds of their choosing. And that’s how the 3D engine idea came about! (2D was discussed but we decided it would too simple - or so my tutor thinks it would be rather too simple for me - but I think the extra capabilities that I could add with the extra time available would negate that but eh).

Will definitely take a look at Minecraft…!! :smiley:

The whole idea of 2D being easy is ridiculous. Mona Lisa is 2D too, not to mention TV and the web.

You can make 2D as easy or complex as you make it. You’d expect a teacher to grasp that. Same goes for 3D by the way, it can be absolutely less impressive than a nicely designed, polished and thought through 2D engine.

The only difference is that you are dealing with another spatial dimension, which often means you have to use more geometry, which affects performance, hence you lose yourself in mundane world of frustum culling and level-of-detail. All these things have absolutely nothing to do with the design of a playable, fun game. If you want to have a bit of depth (story wise) in your game, allowing for non-linear gameplay, your game-code will be hard enough, and those 3 months will feel pretty tight.

f you however solely want to impress your teacher (which makes sense, if you’re doing it for the grade), make it 3D, add lots of particle-engines and fancy physics that have no purpose, and put a beat under it. It will surely make up for the lack of complexity in the game-code…

Tough choice. :-X

Yeah I definitely see your point.

I think my project right now is definitely not to create a game (I’m not designing a game, not designing any story, or characters, or anything like that) but something to demonstrate my programming skills and that could possibly be extended in the future I guess (so definitely a 3D engine… with as you say particle engines, physics and a “tech demo” to go along with it merely to show off what I have achieved from my engine). Again, whether or not that is possible in 3 months I’m not sure!

I think I’ve been getting slightly confused with exactly what a game engine is… and my project is in no way supposed to create any playable game I don’t think. (I think even creating some sort of basic 3d environment with camera etc would look impressive and still require quite a bit of work on my side, i.e. mathematics, opengl wise).

Are NeHe’s tutorials quite good and relevant today?

A game engine is basically the code that handles the rendering, the networking (if any – please dont…) and the physics (if any). It’s like a technical foundation, on which you build the game code.

In a game engine you’d find code that loads textures, does frustum culling, pushes data to the GPU, plays sound effects and streams background music, possible a finite state machine for the AI. It’s basically everything in your game that nothing to do with the game.

Ah ok. That definitely makes more sense and was basically along the lines of what I was thinking.

As for something such as collision detection - again I’m assuming this would be implemented by the game engine - just how difficult is it to implement this would you say?

(Sorry if some of my questions sound as if I’m trying to find the easiest way to do things - I’m not, I’m just trying to prioritise what things to do when based on how difficult they could be etc!).

Thanks so much for your help Riven, I really appreciate it!

Collision detection is reasonably easy. Collision response is not.

It often helps to start off with a 2D version of your physics API.

Make Circle<->Rectangle work first, then write the Sphere<->Cube version. In the end you probably want Sphere<->Plane, Sphere<->Triangle and Triangle<->Triangle.

Don’t try to focus on realistic collision response: it’s really, really hard to get right, and you won’t get it done in three months along with the rest of your game. Instead, once you noticed you collided with something, either destroy the object, or move back to the last known valid position.

Oh ok.

I definitely think one problem I am having is thinking too big for the time available and need to just go a bit more simpler.

I’ll no doubt have more questions as well! :stuck_out_tongue: Again, thanks for all your answers so far, they are really helpful.

Yes, of course.

There is some truth in what Riven is saying, that using a “pure OpenGL binding” will expose you to the low level details so that you are sure to understand how it works. When you choose a higher level technology, you should have a reasonable understanding of how it works, else you will be unable to help yourself when you get into trouble. The reason not to choose a lower level technology is to save time by not writing boilerplate/common code and to allow you to focus on what you are trying to accomplish.

libgdx provides access to OpenGL, so many of the tutorials and sample code can be made to work with little effort. It also has some higher level features you may choose to use that allow you to develop your game more rapidly, such as text rendering, easier management for VA/VBOs, etc.

FWIW, I prefer writing 2D games.

based on how much basic questions you have, I would in your place try to get an easier task from the teacher. If you start learning now how to handle objects in 3D and how to load them in, do rendering, handle the transformations, set up all kinds of parameters for rendering, maybe how to use shaders, how to do collision detection in 3D and on top of that have the code be extendable. Then in this amount of time you will at most write a basic spaghetti code that can achieve some of these things but it will be very far from the goal which is a game engine and if you then show the spaghetti to the teacher then what is he supposed to do.

For what it’s worth, my guess as to the sort of thing you could get done in three months would be:

A world made up of rectangular (in 3D, so cuboid) rooms connected by doorways (portals). If you keep the room geometry simple then you save yourself a lot of problems, not least of which would be how to create the room data. You don’t have time to build your own world editor, and writing the code to import data from an existing editor would be a hassle.

To simplify things even further, the player/camera always stays at the same height (no stairs, no sloping floors, no jumping, no falling). That way the engine’s logic is all 2D. For collision detection, you just treat the player/camera as a circle in a 2D world. (Tip: Implement a ‘map mode’ that displays the game world, including the player, from above using an orthographic projection. Very useful for debugging.)

You could probably get the above done in a month or less. Then you can spend the rest of your time adding cool stuff. If the walls (and floors and ceilings) of the rooms start as just plain colours, then the next step would be to texture map them, and then to add other interesting effects as time allows (e.g., bump maps).

And then you can start populating the world with objects, and creatures, and weapons upgrades, and so on, and so on.

Just a suggestion.
Simon

dishmoth: That sounds an interesting/fantastic idea! And one I am definitely considering when planning my project this weekend.

I think it is clear that in the time given with my abilities in 3D graphics (and my tutor is aware that I have no experience really of 3D graphics as they don’t do it on the course anymore!) that I am going to have to go with something slightly basic as a target, and merely extend - and I doubt I would get anywhere near a full game engine, however the 3D graphics stuff should show off my skills and ability to research/learn etc.

indexunknown: Understand your point totally… I have literally no experience with Java gaming but the whole point of this project is to learn new things and use whatever skills I have learn’t so far in Java and apply them to new things now. I am a first degree student, hence the big project suggestion, and this does mean more research is required in my project (and certainly would be done if I was learning 3D graphics).

However as I said I think I will take what I have learn’t from everyone’s suggestions here - I know what a game engine should do… I know what is basically possible in the 3 months available when using 3D graphics and starting from scratch and I know that a full game engine in 3D will not be completed in 3 months… but more a “sub-section”. (Infact though, my tutor said aiming for a “subsection” of a “prototype” would be fine really!).

I’ll make my plans on what I think is possible, and I’ll give them to my tutor on Wednesday and basically say… “OK, if you want me to demonstrate a really basic partial 3D engine… I can do this and this and it will require a lot of research…” or “If you want a full engine with just as much research, but in other areas i.e. fluid movement, collision detection… then I should drop the 3D and move to 2D”. Either way the work is complicated and still lots to learn… but I think within the time possible one project would achieve more (visually and in a game engine way) more than the other.

Am I now thinking along the right lines?