The source for Project Frontier is now available on BitBucket. I’m really hoping you find it to be useful. I’m very sorry to see I left the codebase in such shabby shape.
The program defaults to re-loading the last save you played. If you’re running it for the first time, then it doesn’t do anything. Bring down the console with ~ and type:
game new 1
You can replace the 1 with any number you like. That’s the seed number used to create the world. Different numbers will lead to different worlds. (The screenshot above is from right near the spawn point in world #1.)
Looks like it also defaults to wireframe on, textures off, shaders off. That’s dumb. Sorry. In the console:
render.shaders=1
render.wireframe=0
render.textured=1
That should put you in a good place. Also use:
mouse.invert=1
If you’re a mouse-inverter. Use
flying=1
Or:
flying=0
To turn flying on and off. The WASD keys move you around. Right-click enters and exits mouselook.
Missing textures are represented with a checkerboard pattern.
Please let me know if you have any other problems.
Was it a Hack?
A big chunk of the internet went down in October of 2016. What happened? Was it a hack?
Why Batman Can't Kill
His problem isn't that he's dumb, the problem is that he bends the world he inhabits.
The Death of Half-Life
Valve still hasn't admitted it, but the Half-Life franchise is dead. So what made these games so popular anyway?
This is Why We Can’t Have Short Criticism
Here's how this site grew from short essays to novel-length quasi-analytical retrospectives.
Raytracing
Raytracing is coming. Slowly. Eventually. What is it and what will it mean for game development?
So why try to put the thing on GitHub if you used a Mercurial repository all along?
Also, thanks! I’ve been looking forward to this =)
He actually forgot he had used Mercuirial.
Ah, thanks. Reading edits FTW
I think he forgot about having used Mercurial.
So why did he try and use GitHub?
Because he didn’t remember that he had the code on BitBucket :P
Simple: Because he didn’t remember that he had used Mercurial.
Cause we all were like GITHUB GITHUB GITHUB in the comments. He tried to accommodate us.
Hooray!
I think it is a very good thing; i won’t have time to delve in the code but i think it will definitely benefit the community (i’m thinking in particular about your river code, which i find very interesting)
Don’t hesitate to keep us posted about what spawns from your code.
Thank you, Shamus!
I’ve usually done most of my (scientific) program on a unix account, but am now starting to re-teach myself C/C++ at home on my Windows box. Anyone have any suggestions on a free IDE to use? If I can get Frontier to compile that will be a major achieve for me :P
There is a free version of Visual Studio available here. Alternatives are CodeBlocks or the QtCreator, which are both also cross-platform.
I would love to recommend QtCreator (cross-platform development without splitting your codebase), but it just stopped compiling my project by trying to link to things that don’t exist that I didn’t intentionally ask it to. My OpenGL demo code doesn’t depend on an installation of some SQL library that I’ve never heard of or had installed. Grr…
Edit: Managed to get rid of it by manually removing it from my Makefiles. It would be nice to have found some documentation on how to change that inside QtCreator, but I can compile again…
I’ve used Dev C++ and found it to be quite nice.
http://www.bloodshed.net/devcpp.html
Don’t use Dev-C++. The compiler it ships with is a beyond ancient version of MinGW that can’t handle modern C++ or libraries. You can install a newer version of MinGW for it, but it’s not worth the trouble.
Using Dev-C++, you’ll run into lots of code that doesn’t compile, but when you ask for help everyone will say there is no problem on their end…it’s simply Dev-C++ being unable to handle C++.
Instead, use the freely available VC++ Express or Qt Creator or anything else that integrates properly with the debugger and autocomplete (which so far only VC++ and Qt Creator do on Windows).
You know there is a new fork of Dev-C++?
http://orwellengine.blogspot.com.au/
You can use MinGW or TDM-GCC. I have no idea how good each of these are, but they appear to be the latest versions.
We need a post – this one would do fine, really – for people to post their favorite world seeds.
Haven’t played with it yet myself (yeah well; I really should do _some_ work today) so I don’t have any favorites… yet.
If nobody does it before this weekend, I might hack up some makefiles to get this thing building on Linux. Of course, I’d probably have to remember all the C++ I’ve forgotten and then learn the rest. Maybe not though!
I’m afraid porting this will require much more effort than just a makefile. Assuming all the libraries used have a matching Linux alternative there are still the WinAPI calls I spotted during my quick look.
I haven’t scanned the source yet, so maybe you’re right, but it’ll get done one way or another.
It would hardly surprise me. I looked at the libraries used and all of them are indeed available for Linux. So in the end it really is just about stripping out windows.h.
I don’t think there are that many ties to windows. SDL takes care of opengl and input, and along with cg, it’s cross platform. The biggest worry, though, is the .ini settings parsing system. Maybe we could get Shamus to switch to xml and use, say, tinyXML.
In the mean time, I’m sure WINE will run a visual studio or mingw binary.
IIRC it took me about a week and some change (hacking on it nights and weekends, when not working) to port over pixel city. This should be mostly similar in terms of the windows api calls, except probably many many fewer of them. (And no four days’ worth of trying to figure out freetype or fontconfig or whatever it was, to get the bitmaps for the fonts used on buildings. Probably.)
Not sure if I’ll get time in the next day or two to install mercurial and fork the repo, and get started, but maybe.
The INI parsing code really wasn’t hard to port over; there was an entire separate Ini.{h,cpp} file pair that made it really self-contained.
Got maybe a third of the way through (when counting by files), or possibly up to half, making the .cpp files compile into .o before needing sleep. We’ll see how much farther I get tomorrow.
My forked repo, FWIW:
https://bitbucket.org/bryankadzban/frontier
Seeing as this is a public repository, I feel the need to ask whether you prefer we fork before doing any playing with the code or if direct changes are acceptable?
I would think it’s best to leave the original codebase alone and fork it if you want to do anything with it.
Quit forkin’ around.
Mercurial is distributed. Fork, make changes. Then create a pull request… Wait, does Mercurial have pull requests?
I would say fork, hack, then figure out how to contribute back upstream later. You won’t be able to write directly to his bitbucket anyway unless he gives you write access.
Yes, bitbucket has pull requests and Mercurial is functionally very similar to git.
I read that bitbucket also added git support. (http://blog.bitbucket.org/2011/10/03/bitbucket-now-rocks-git/) Is that a per-repository thing, or do all repositories now somehow support both – leading to the novelty situation where we can clone frontier through git?
It’s set per repository, unfortunately:
http://confluence.atlassian.com/display/BITBUCKET/Create+an+Account+and+a+Git+Repo
Step 2, sub-step 6. “Check Git for the Repository type. You can’t change this value later.”
So what do we need to install in order to get this code and run it?
So far, I went to the Bitbucket page, used “Download Source”, downloaded the .zip. Then I got extracted the .zip onto my hard drive and then downloaded Visual Studio C++ 2010 Express. I opened “Frontier.sln” and pressed “build”. Then the compiler choked because I seem to be missing something called “glConsole.”
glConsole would be here:
http://www.robots.ox.ac.uk/~gsibley/GLConsole/
Well, I got GLConsole, then I got GLUT, then I got SDL, then I got lots of new errors, and I decided to wait for someone else to upload the binaries. This is just too many new things for me to figure out all at once.
I’ve mostly got that figured out – I’m cleaning it up a bit so it’s easier to build, then I’ll put it up (and put a pull request, in case that’s a thing Shamus wants to do). I’m swapping out the NVidia specific Cg shaders for regular GLSL so everyone can run it, after that.
I’d be really grateful if someone would be willing to post some sort of tutorial for non-coders on how to turn the github file into an executable game. I just want to walk around in the world, not play around with the source files, but to be honest I’m a little stumped. (I should probably try this again when I’m not half-delirious from exhaustion.)
Indeed. As a follower of Shamus’ work, I’d love to be able to traipse about the procedural worlds his code can generate and check out the scenery. As a non-coder, I have no idea how to go about this. :/
Maaan, when I saw this title for a second I thought you meant you’d ported Project Frontier to Valve’s Source engine.
Which, in theory, may be conceivable since it also uses C++ – however, probably still a ridiculous amount of work.
EDIT: Shamus, what exactly was in your “H:/sdk/cg/” folder? From the compile errors, I assumed it was just SDL, but apparently I was wrong – I’m still missing a couple files, “cg.h” and “cggl.h”.
I’m assuming they’re the libraries that you yourself wrote?Nevermind, looking into it more, it’s probably a third party library. However, just doing google searches, I can’t find it. Any way I could get some help with this?Whoop, nevermind, I got it. CG is from here:
http://developer.nvidia.com/cg-toolkit
And you’ve got to change all of Shamus’ H-Drive references to wherever you’re keeping your libraries. I did this by opening up the .vcxproj file, finding “H:” and changing all the references to wherever my stuff was. Also, there’s a “pragma comment” you have to change within “main.cpp.”
If anyone wants, I can post a couple of compiled binaries so you can look at PF without having to compile it yourself.
One last thing though: it looks like the trees are using the entire leaf texture without clipping it. You can see what I mean here: http://inarticulateloquence.com/wp-content/uploads/2012/05/trees.png
I’d love a compiled version, doing it myself is a bit outside my capabilities.
Yeah, looks like that purple should be transparent. But looking at it, not all trees are affected.
Compiled binaries would be nice. I assume there’s a good amount of people who just want to play around and look at things without needing anymore access than what the console provides. And they probably don’t want to look into setting up visual studio or whatever program they choose to build and run the code.
Yeah, I just kinda want to run around and see the sights. I dont know a thing about coding, or how I could actually get this to work… XD;
thats really helpful, thank you!
Seems like it might need some serious re-factoring.
http://inarticulateloquence.com/wp-content/uploads/2012/05/Frontier1.zip
Ok, here’s a binary I compiled in Visual Studio 2010 with Windows 7. This one includes purple trees and, now for some reason, no animations. It works fine when I run it within the directories I set up, but does not when I copy it out of that directory. Very odd.
Anyway, I figured I’d post it since my edit time is running out (The last one, I posted and forgot to include any of the textures/anims).
I see landscape and a black avatar, but there’s a constant green noise flickering over everything (bad grass?) and the trees are purple.
That’s odd. The purple trees are to be expected – after I got it compiled, I’ve been trying to figure out why that’s happening.
Unfortunately, I can’t really troubleshoot this stuff effectively because I only have a vague outline of what the code’s doing. Hopefully someone else posts a binary as well, so we can compare notes.
Here’s what I see:
http://www.sea-of-memes.com/graphics/frontier1.jpg
I do have the purple trees, but the grass is ok. No flickering noise. And animations are working, too.
But I have encountered some strange floating polygons…might be a desired effect, though (fog?). (World Seed: 2)
Yeah, that’s “fog”. Or would be, if the texture was available. I went through the source and added everything *.bmp and *.png that I found to the repository. Looks like some things are still missing, though.
Texture files used in the code (as in: files referred to in TextureFromName or TextureIdFromName calls), sorted by filename and then unique-ified:
avatar.png
bark1.bmp
clouds3.bmp
clouds.png
foliage.png
font.png
grass3.png
stars2.bmp
sun.bmp
sunrise.bmp
terrain.png
terrain_rock.png
terrain_shading.png
vines.png
water1.bmp
water4.bmp
water.bmp
Diffing this with the Textures directory’s contents, I can see the files referred to in code that don’t exist in the repo:
-clouds3.bmp (but there’s a clouds.pspimage; possibly relevant?)
-water4.bmp
-water.bmp
There are a bunch of other files that exist in the repo that aren’t used in code (AFAICT), but that’s less relevant.
However, there’s one call, in CEmitter::Render, that calls TextureIdFromName(_settings.texture.c_str()). It *looks* like all of those “texture” entries come from .prt files in the Particles directory, and it *looks* like the list of files is thus:
fog.png
particle_dot.png
particle_flower.png
sand.png
Of those, there’s one more that doesn’t exist:
-fog.png
Yeah, I figured out what was wrong with the animations – a “frontier.ini” was included that had a bunch of necessary info, but was also created when the program ran, so I kind of skipped over it.
Going to continue to unravel this mystery. I noticed the fog, too – going to try to come up with a suitable replacement texture. Will update the wiki as things progress. I made a place for people to post their compiled binaries.
I made a reasonable fog texture.
http://dl.dropbox.com/u/21158334/fog.png
One question: What license is this code under?
Good question. I would like to know this too.
zlib/PNG/BSD is what I’d recommend, alternatively pick an appropriate http://creativecommons.org/ license.
Note that the license would apply only to Shamus’s code,
any 3rd party code used is subject to their own license. (GPL and LGPL can be a real pain in the ass, which is why I recommended zlib/PNG/BSD style license or CC)
Awesome! Thanks for doing this.
I hate to give you more work, but if you find a free minute could you perhaps put a small README with the code that outlines:
– What are the basic system requirements: (ie which Visual Studio version you used, what additional tools might be needed).
– Few sentences on how to compile (if there are any steps other than hitting compile button)
– All the stuff you just explained above (or link to this post)
This way if someone stumbles upon your source code six months from now, they can build and play with the game without actually having to dig out this post to learn how.
Once again, thanks for open sourcing it. :)
I wish he would also free (as in freedom) the code, by giving it a free license (copyleft or not).
Right now, though the code is open, we’re not actually allowed to do anything with it beyond reading, when you’re pedantic about copyright law.
Actually, that’s not true. We’re allowed to do all sorts of things to it, just not distribute the result. In fact, we’re not allowed to distribute it at all. Not even to put up on bitbucket.
Fortunately, that only applies if Shamus is a litigious jerk, which he is not.
Incidentally, the libraries may be under different licenses that need to be included.
Very good point.
Shamus, if you don’t care I would recommend the WTFPL license: http://sam.zoy.org/wtfpl/ :P
If you don’t want people making for-profit copies then just go with GPL.
Copyleft licenses like the GPL still allow people to monetize your work, they just require them to also free any changes they made.
BSD is good and short, if you don’t care what people do with it. If you want PF to only form the core of money-making games when you approve, the GPL (with an option to commercially license) will get you there. Of course, if you go that route you’ll have to get approval from anyone who contributes to it. The GNU approach of requiring anyone who contributes to assign copyright to you can work, but it’s not very practical if you want to encourage people to work on it.
Short version:
Do you care if other people internalize this into commercial products?
Yes -> GPL
No -> BSD
The other thing to consider is the license for the various libraries you’re using. SDL is LGPL’d, so as long as you don’t make changes to SDL itself you’re clear. I don’t know about all the other things you’re using, but if you link with something that’s GPL’d, and distribute the resulting binary, you have to GPL it.
http://www.opensource.org/licenses/category
That can help.
And you thought open sourcing stuff would be easy!
I’ve placed the BSD license on the Wiki.
And now I’ve changed it to the WTFPL.
I’ve seen some developers multi-license stuff.
Thus far, Apache and MIT were the two most “free” license types that I’d seen – this is the first I’ve heard of WTFPL, so I’ll be interested to check that out.
I’m just thrilled that you decided to open up the code, I think this is of great benefit to the development community at large.
Thank you!
My personal favourite license to use (if I feel like I’ve been remotely creative in some way) is http://en.wikipedia.org/wiki/Zlib_License
In a binary release, at minimum a copyright line crediting the original author is only needed (but apparently optional).
So no TEXT BLOCK OF DOOM to annoy people with.
And in the cases where I don’t feel like I did anything remotely creative I just “license” it public domain. (Just a line of textg stating I place it in the public domain).
Though Creative Commons is kinda neat as they have a more standardized way of creating your licensed. (both zlib’ish and PD’ing your work) so I might use that in the future, we’ll see.
EDIT: Actually after looking quickly at the longform CC, and the BSD and MIT licenses. I find that the zlib license is probably the most straight forward and and simple license I’ve seen.
Guys, can we start a list of dependencies for this? Maybe Shamus can add it to a REAMDE later.
So far from the comments I gather you need:
GL Console: http://www.robots.ox.ac.uk/~gsibley/GLConsole/
CG Tookit: http://developer.nvidia.com/cg-toolkit
SDL: http://www.libsdl.org/
GLUT: http://www.opengl.org/resources/libraries/glut/
Anything else?
Shamus, can you enable the Wiki on the Bitbucket page? Maybe we can pull resources and write some documentation for you. Crowdsourcing man! :)
devIL
http://openil.sourceforge.net/
The one seeming to give me problems is GL Console, the others I’ve just hooked up to their include-folders, but this one I have no idea what to do with.
Boom! Wiki is public.
Actual GLUT is super crappy, grab FreeGLUT (it comes with binaries for lazy people like me, even)
Note that FreeGLUT will barf an error and die the first time a glut* function is called in the current state of the code, since nothing ever calls glutInit() at startup. (Or, at least, my version of freeglut does this.)
https://bitbucket.org/bryankadzban/frontier/changeset/8aa20249b009
fixed this for me, although I have no idea how to get an argc / argv out of WinMain for the #ifdef WINDOWS branch. Shrug. :-)
Be aware that if you try to build GLConsole from source, it does *not* use the standard autoconf procedure (./configure / make / make install). It uses cmake instead. So if, like me, you don’t have cmake installed because you’ve never needed to build anything that requires it before, it’ll be a bit of an experience.
(Not that it matters all that much, but still…)
Uh… is File.cpp supposed to have Activeworlds Inc. copyright info at the top? (Related: is Cg.cpp supposed to have a header claiming to be CTerrain.cpp?)
That and I kinda disapprove of File.cpp in general. Yuck, Microsoft-specific stuff… curse you, File.cpp, you’ve probably just wasted fifteen minutes of porting time. It also stores timestamps in 32-bit integers.
Ini.cpp also makes me sad.
Shhh…. this is why programmers don’t like to release their code to the net.
Also, why I’m trying to learn as much as I can about this kind of stuff (portability, open source software, third-party libraries, etc) as I can before I get out of college. This is all stuff they don’t teach you about, folks.
Wow. That means I’d originally copied something from Activeworlds source.
YIKES!
Looking at it… it’s clear it’s not this file. It’s obvious I copy that block header around. Still, that’s sort of alarming.
And like Goodfellow said, this is exactly the sort of thing I worry about when releasing code.
EDIT: Okay, I’ve looked over the source. I no longer have Activeworlds code to compare to, but I think we’re in the clear.
Somewhat related, I could try to start flamewars about how I hate his use of spaces instead of tabs for indenting and his {-placement… :P
But yes, File.cpp and Ini.cpp are not really tutorials on portability.
When Shamus settles on a license, I’d probably be willing to relicense my INI reading class as a replacement, if that’s helpful to people.
It might be too complex for this use-case, though, and has certain other dependencies that need to be replaced, that I can’t relicense (for example, the Stream classes come from ScummVM and are GPLv2+).
I’ll go ahead and say File.cpp and Ini.cpp are pretty horrible. Yes, I knew all along they would need to be replaced at some point. You know how it is when you’re prototyping.
I’ve got a File.cpp working on POSIX, but I suspect it wouldn’t run on Windows. (Also, I didn’t actually check that some of the directory code actually worked… it looked kinda gnarly.) Now to fix my pesky texture bugs… It loads the sun, the stars, dust puffs, and absolutely nothing else. (Not even the console font!) Any suggestions would be appreciated…
You know, looking at the dependencies and portability issues, I have to say there are some advantages to being anal and writing all your own code like I’ve been doing. Too bad it’s only taken me a year to do what Shamus does with his libraries.
Meh, aside from the INI stuff (which I ended up hackily patching out) I haven’t had too much trouble porting to POSIX, aside from this texture thing… and as best as I can tell, that’s not a library issue. (Shamus’ chosen image library seems to be loading images fine, it’s just OpenGL doesn’t render ’em for whatever reason. Still trying to figure out why that is…)
Of course, I’m of the “write your own code” sort myself, though that’s mostly as regards algorithms… I’m gonna have to implement Fortune’s Algorithm soon, which will naturally be a blast.
Good luck. A friend and I spent the better part of two weeks trying to get Fortune’s Algorithm for some robotics work. That is one of the most complex algorithms I’ve ever tried to get my head around and implement.
Instead of patching out the INI stuff, you could try pulling these from pixelcity:
https://github.com/BryanKadzban/pixelcity/blob/master/Ini.h
https://github.com/BryanKadzban/pixelcity/blob/master/Ini.cpp
Not sure if they’ll continue to work with frontier (going to find out once I get all the $*(@#)”%&)(#$ nonsense introduced by case-insensitive filesystems cleaned up), but maybe.
There wasn’t really that much that depended on the INI code, though. If I were going to replace it with anything, I would probably just rewrite the code using it to depend on CVars instead.
Well, it’s one of the age-old tradeoffs — between reusing something that has worked previously, even if written for a different source, and just changing around the rest of the program to not require it.
Depends on how much you want to do. I have the pixelcity sources sitting on this machine, so I’ll most likely just copy those two files in and — assuming they work — call it an hg commit. :-)
Hmm, nope. Looks like a few things changed in Shamus’s Ini files. Wheee.
They got overloads for specifying a section explicitly, and adding that support will be … interesting. I can probably make it work with a multi-way map: “map<string, map >” where the first is the section and the second is the entry. Hopefully this is reasonably easy to save and parse back. Whee.
You know, I’ve got a huge 2k post tomorrow about how much Qt bothers me, but seeing these porting headaches is making it all look reeeeally attractive.
Here’s an in-progress screenshot showing [a] that it’s mostly running natively under Mac OS X (POSIX) and [b] that only the stars have any texture.
OK, I’m fairly sure that the issue is in the shader system. Shamus, do you remember any issues that you had with the shaders which might be helpful here? Alternately, do you have any suggestions on how to eliminate them entirely? The way it’s set up right now, when I tried to sloppily eliminate shaders, I ended up with a permanently overcast sky and non-colored grass and flowers.
The thing is, I HATE a lot of the coding styles I use.
For years I worked on Activeworlds. That began in ANSI C in 1994. It used the old-school styles favored by its originator. All lowercase. Underscores. Spaces, not tabs. Indents are 2 spaces. Braces open on same line.
Everyone else followed these standards. Even after the original guy left, it was generally agreed that consistency was king, and nobody wanted to convert all those 100k lines of code from
void do_a_thing ()
to
void DoAThing ()
When I moved on, I was free to use styles that I favored, but after all those years it was hard to get out of those old habits – even the ones I disliked. I’m looking at frontier, and at my current project, and I’m seeing a lot of worrisome inconsistencies of style. I really do need to pick a set of conventions and stick with them.
However, I really am a fan of
I dislike throwing away a lot of vertical space on curly braces. I can understand why people like the symmetry of matching braces, but I’d rather have the screen space.
Tell me about it! I learned all that Microsoft cruft — m_lpzString and then gradually let most of it fade away.
I was reading someone else’s coding standards the other day, and it was “yes, yes, that too! I do all of that! Finally, someone with the same style as me!” But after the first five points, it went insane and I had to stop reading…. sigh.
Ugh, m_lpz prefixes. :-(
There is, of course, a much better way to do them:
http://www.joelonsoftware.com/articles/Wrong.html
Went right the other way round for me.
I used to put the { on their own line. Instead I was more stingy with the horizontal space “for(i=0;i<10;i++)".
Then I joined the ScummVM team in 2006, and adjusted to their coding style. And I kept with it. Hugging braces, "for (i = 0; i < 10; i++)" and all.
The only thing I always did was tabs for indent, spaces for alignment. Spaces for indenting just never made sense to me.
You don’t replace tabs with spaces? MADNESS
I prefer to open curly braces on a new line. Not as much for symmetry, but for with being able to easily tell where the blocks start and end.
For my work, we settled on an unconventional braces style – a mix of K&R style vertically aligned braces for class and method blocks, but with BSD KNF style opening braces on the same line for ifs and loops and anything else. It was weird at first, but I’ve since adopted it as my own – it kind of makes sense that you don’t need to waste whitespace on a 3-line if statement, but you want to keep your functions and methods nicely spaced out.
Let’s see if I can’t screw up a ‘code’ tag to illustrate my own odd style:-
TES3::Record *
TES3::Reader::read_header(
QDataStream &data_stream)
{
static const QByteArray tes3 = QByteArray("TES3");
// Check TES3.
QByteArray magic = data_stream.device()->peek(4);
if (magic != tes3) {
qDebug() << "This does not look like a TES3 format file - header magic is wrong.";
TES3::NotTES3FormatException ex = { magic };
throw ex;
}
return read_record(data_stream);
}
Okay, how can I edit comments? I just keep managing to screw up the formatting. I don’t see an obvious ‘edit’ link.
Given the nature of the blog and audience, I really don’t get why Shamus doesn’t have proper support for code samples in comments. Surely it can’t be that hard? Of course, I’m coming from the direction of having written my own website code from scratch to do exactly what I want it to, so I have no idea how to do things in WordPress-land. Still, it seems like it should come up enough that someone should have worked out a solution by now.
Thank you for posting this, I appreciate it a lot!
I guess now’s as good a time as any to learn C++.
Thanks for releasing the source, Shamus. My final project in my graphics class last semester was a terrain generator that was inspired by Project Frontier. Your series also helped me implemented a mostly working quadtree simplification algorithm. The code is here, though it’s not nearly as impressive as yours.
Can’t wait to see what you come up with in Project Octant.
Your trees look like cubes. Is that a reference to minecraft, or a result of more traditional tree designs being difficult to program?
When textured properly, they should look more like a World of Warcraft-ish kind of thing. I don’t know about “difficult to program”. One tree is about as easy as another until you start getting close to photorealism.
Speaking as a programming noob; How me make this go?
Easiest and cheapest way is to get Visual Studio Express. Then, download all the libraries noted here. Download Shamus’ source. Open up the .sln file with Visual Studio. There should be two “frontier”s on the left pane; right click the second one (the one tabbed over on the hierarchy) and hit properties. Look through all the categories; every time you see something like “H:\SDK\…” replace it with the location you downloaded and unzipped the libraries to. Now, you should be good to compile.
It’s a bit more nuanced than that. Maybe someday I’ll do a long writeup on how to compile other people’s source, but for now, it’s late.
Nnnnnnnnope, too computer-geeky for me. I’ll wait for a compiled version where the trees work.
If anyone wants to run the program in first person view, my .exe is available here.
Download Ed Lu’s archive and replace the exe with mine, and change the CameraDistance in Frontier.ini to 0.
If you don’t trust my .exe, I simply reduced CAM_MIN to 0 and commented out the code that renders the player model and the code that handles the mouse-wheel. It works well enough, I think.
Could someone please post the executable version of Project Frontier for the n00bs that have no idea how to compile code (i.e: me)?
Okay, here’s what happened today:
– I started reading your code
– Two hours pass
– I forgot to eat dinner and now have 20+ tabs open in notepad++
Congratulations Shamus! You created your very own TV Tropes!
Seriously though, I am learning a LOT from this stuff. I study computer science and although it’s all fine and dandy to hear how this stuff works in theory it can be so much more educational to see how it’s actually applied in practice.
Thank you for this.
Well, I think there’s a bug. :-)
In World.cpp, both in WorldWaterLevel and WorldBiasLevel, the code calculates an origin.x and origin.y value from the passed-in world_x and world_y values. Then it clamps them to the range [0, WORLD_SIZE-1] (inclusive).
Then, it tries to get the region at four different points: (origin.x, origin.y), (origin.x, origin.y+1), (origin.x+1, origin.y), and (origin.x+1, origin.y+1).
However, that last one (just to focus on one of them), up in WorldRegionGet, tries to dereference world.map[WORLD_SIZE][WORLD_SIZE] when the code calls WorldWaterLevel(max_x, max_y) (whatever the maximum world coordinates are). Since the valid indices into C and C++ arrays start at 0 and go to [array size]-1, and since map was declared as “Region map[WORLD_SIZE][WORLD_SIZE]”, you can’t dereference that entry.
The program segfaults for me partway through building a world (the first time it tries to walk off the end of the — pretty large — block of memory reserved for map). It works fine (or, well, gets past this crash anyway :-) ) if I replace the “clamp” calls in both those functions with clamp calls that limit the range to [0, WORLD_SIZE-2] instead.
See https://bitbucket.org/bryankadzban/frontier/changeset/f63e6721682e — though I don’t know if there’s any easy way in mercurial to pull this individual patch.
…Except that last commit doesn’t fix all the cases where the code tries to overrun the size of world.map[][] — there’s one more (known so far) in WorldColorGet().
See https://bitbucket.org/bryankadzban/frontier/changeset/413c5c8430a6 for that fix.
I don’t see any more in World.cpp at least…
Another bug. None of the GridData-derived classes are actually calling the GridData constructor. They’re all simply creating a temporary (of type GridData), then throwing it away. :-)
For instance, in CTerrain.cpp:
Well, er … no, actually, that’s not what that does. :-) That’s what this does:
(Note that you can use the initializer list after the colon to set the initial values of class fields, as well, though I think there are some restrictions on the usable values, and I know you have to initialize fields in the order they were declared in the header file. Elements in this list are separated by commas. But that’s a bigger change.)
Last bug. I think. :-) This change actually makes it *show* the ground when shaders are enabled:
https://bitbucket.org/bryankadzban/frontier/changeset/efa4181223a2
(It’s possible that one of my other changes made this particular enum value stop working, but I think it’s unlikely.)
Now I can finally see stuff. And reverting all the local changes to the .cg programs (that I added to try to figure out why I couldn’t see anything before), makes all the other effects show back up again, as well. :-)
No purple trees — the surrounding night makes it a little hard to tell, but I do see green. No green noise all over for the fog, either (although again, it’s night, so maybe the fog isn’t present or something; have to wait about ten minutes to see).
Crap, never mind, the fog isn’t working. (Large checkerboard patterns along the ground instead of actual fog.) Most likely because of the missing fog.png texture I mentioned earlier. Well, everything but that is pretty good, I think. :-)
Wait, what? Bounds errors and segfaults? How did this ever run?
I got problems with the binaries Ed Lu offered. Problem: Window keeps black (even after 5mins of waiting), both with on board Intel and normal Nvidia graphics card. Any solutions?
Hit the tilde key ~ to bring up the console. Type “game new 1”. That will begin a new game. Replace the #1 with some other number to use as a seed, if you like.
Thanks :)
I should read the posts more carefully in the future.. Now its working :)
Interesting fact: with on board intel gpu: no purple trees, but weird grass effect, like MichaelG mentioned. With nvidia gpu: purple trees, but everything else works fine :)
Interesting fact #2: with on board intel gpu: clouds, stars (at night) and trees are beeing displayed correctly, with nvidia gpu i don’t see any clouds or stars. Maybe that helps fixing the problem :)
I AM AN INVINCIBLE GOD OF PROGRAMMING
It compiles! It runs!
I mean, sure, my desktop is covered in assorted source files and binaries which I’ll never be able to reassemble if something goes wrong, and GLConsole doesn’t recognise any commands I put into it, and the trees are all purple, and I have absolutely no knowledge of C++ which I could put to use debugging this stuff, but IT COMPILES! AHAHAHAHAHAHAHAHA BOW BEFORE ME MORTALS.
EDIT: Oh. It keeps crashing randomly.
Thanks for releasing the source. I have actually created a similar program, or at least started to, but it’s not nearly as good as what you have done. I have some terrain rendered from a heightmap, some simple trees, a huge water texture like yours (only animated so it is moving and transparent). I added in ambient sound (wind, birds, water when swimming). I done mine like Battlefield 1942 mostly, I copied the terrain so that it basically goes on forever. You keep walking/flying and when you reach the edge it wraps around, but because I copied the terrain and it is designed to the edges all match up (wraps around) it just seems to go on forever. I wanted to try something like you have done, with different terrain in sections and eventually have the world wrap around, opposite sides would match up and you could walk around the world literally.
I love the idea of procedurally generated worlds, I got the idea from the old game Elite which generated the entire universe at runtime, which led me to your page here when searching. We have the same interests, you just have far more skill! ;)
As for your coding STYLE, we’re alike I think. K&R seems to suit me, and it looks like your style as well. I also use underscores for my variables, I don’t like the look of MyVariable, I prefer my_variable, it’s more readable in my opinion and I hate Microsoft’s style. Like you I see no need in wasting vertical space on brackets. Some people say it helps them know where the block is, well, you can tell easily by the indented lines…
if(a == b) {
do_some_stuff();
c = d + 5;
}
As anyone can see, the indented lines make it obvious, but no wasted space. I also can’t stand things like:
if(a == b)
{
d = 1;
}
when it could be written:
if(a == b) d = 1;
But everyone’s different. If you want to get truly portable, a good compiler to pick is Code::Blocks, it has many of the same look and feel of Dev-C++ for those that liked it, but it is maintained still. It can now (with the latest nightly build) import VC2010 solutions as well as Dev-C++ projects, but most importantly, it is also available on other platforms like Linux, so you can completely port your projects, code and all to Linux, using the same compiler and compile away. Code::Blocks uses the MinGW (Windows version of the GNU GCC) compiler.
A library I use that is similar in portability as SDL is Allegro (specifically, Allegro 5, which is more up to date). It supports JPG, PNG, OGG, OpenGL etc and is very flexible with nice sound, TTF etc… support as well.
Hi! I have been a long time lurker, just reading an article now and then.
Recently, after a normal bing of your LOTR comic, I started reading the other posts, and just stumbled on this series.
It’s been a very interesting read, and gave me an itch to look how you coded the project, since I have been always interested on 3D programming. However, the Bitbucket repository seems missing? Was it deleted/removed and I haven’t seen that post or is there is some other reason?
I was wondering the same thing. I remember a long time ago I had downloaded it, but I’m not sure if I ended up keeping the files, if its on anything, they are on an old PC I can’t check right now. I did, however, find someone who evidently was going to port Frontier to C#, although didn’t seem to do too much with it: https://github.com/EwgB/frontier-net
It doesn’t look like it will be plug and play to get running as dependencies probably need to be compiled (well, GLConsole/FTLK/SDL and whatnot) and everything else, but could be a possible starter point or at least some sort of reference. I’m not quite sure when the original repository went down, though.