

Let's Code... an MMO - JeanPierre
http://www.sea-of-memes.com/LetsCode1/LetsCode1.html

======
jerf
Shamus Young has been doing a vaguely similar series lately, which you can
find at: <http://www.shamusyoung.com/twentysidedtale/?cat=66> Note that that
page, unlike most blogs, is sorted earliest first, so I'm actually referring
to "Project Hex" at the bottom. Though you may find the others interesting
too. Interesting to compare and contrast the two fundamentally different
approaches, which nevertheless have produced reasonably similar screenshots
initially.

------
swah
I was thinking of (one day) creating a "Let's build a" series in the following
order:

1) Students learn about assembly, opcodes, etc. They write programs for an
imaginary machine and only run them on paper for now.

2) Students write their own CPU emulator (in C) that can run and test the
simple programs from 1.

3) Students write a compiler to a simple HLL which allows them to write more
complex programs, and test against the emulator.

4) Students build the processor which was being emulated in HDL, and download
it to FPGAs, testing outputs of the programs generated by their compiler
against the emulator.

I think most schools already do something like this, but mine missed the
compiler part.

~~~
corey
Check out The Elements of Computing Systems. It walks you through the
construction of a computer starting with just NAND gates. You start by
building other logic gates, and then an ALU, CPU, assembler, virtual machine,
a compiler for a simple high level language, and finally an operating system.
Each chapter gives the necessary background information, and a specification
for you to implement.

------
daeken
This is a pretty damn cool article, but it's an odd choice of bounding spheres
for frustum culling of octree nodes. Yes, it's cheaper in terms of CPU time
than using the actual octree nodes (which are either cubes or boxes -- cubes
in this case), but it's far less precise, meaning you're going to be 1)
checking more nodes, due to recursing further when you have a false positive,
and 2) most likely sending more data to the GPU than required, especially
considering the density of his world.

Can anyone think up a reason why spherical bounding boxes would be beneficial
here?

~~~
davidsiems
A sphere-frustum check is a lot cheaper than a box-frustum check. The
spherical test only has to check the distance of a single point to the
frustum, a box intersection test is much more complex.

There are some false positives, but as with many things in game development
'close enough' usually works pretty well.

If you're really concerned with efficiency you should look into other data
structures than an octree. Octrees are a nightmare for cache performance (like
most other tree based structures) and cache utilization is usually the
bottleneck on modern CPUs.

If you're interested in the subject this book
(<http://realtimecollisiondetection.net/books/rtcd/>) covers everything
extremely well.

~~~
daeken
Yea, I know sphere-frustum checks in and of themselves are cheap, but when you
consider the cost of false-positives for octree traversal and the cost of
sending unnecessary data to the GPU, it doesn't seem like it makes a lot of
sense to me.

~~~
davidsiems
Then it sounds like it's time for an experiment.

Take the code he posted with the article, and modify it to use a box-frustum
check instead. Don't forget to test the program's performance before you make
any modifications so you'll have something to compare to. Even better, keep
the code intact and #ifdef'd out so you can toggle between the two.

Then, compare the differences. Check to see how many false positives there are
on average, and how much extra data this means gets sent to the GPU. Keep in
mind, however, that extra data being sent to the GPU doesn't matter unless the
GPU is actually the bottleneck.

My hypothesis is that the way the octree abuses the cache will overshadow the
performance gains (if any) you'll make by using something other than spheres
for your test. In the end you'll find that if performance in this part of the
code is a problem, you'll need to switch data structures.

~~~
daeken
I'm more curious about this as a general trend. I always see people advising
sphere-frustum tests for these situations, but I've never really understood
how it works out better than box-frustum. I should really run some tests not
just against his code, but to figure out where the tipping point between the
two techniques is.

~~~
barrettcolin
Broadly speaking, simpler is better on modern CPUs and GPUs. Testing an array
of spheres against a view frustum is cache friendly, can be sped up
considerably using SIMD instructions and is easily parallelizable. Submitting
superfluous data to a GPU is not generally impactful; GPUs are clever at not
drawing stuff that doesn't actually contribute (with clipping and depth buffer
rejection) and extremely fast in their own right.

------
AlexC04
This is really cool! I can't wait to come back and give it a proper read
through. Hurry on weekend :)

------
riprock
I've been looking into game programming in my spare time and I was wondering
how to best implement the UI as a hobby project. I know there's Scaleform,
<http://www.scaleform.com/> , that's used for major games like Starcraft 2 but
the price tag is way out of my league. Anyone have any suggestions?

~~~
nihilocrat
A ton of UIs are built from the ground up. When you compare the logic and math
involved to the logic and math used in 3D rendering or even 3D game logic,
it's an absolute pushover, though you might feel like it's a huge hassle since
in web development you get the UI logic, more or less, for free. You'll notice
very quickly in game development that, until very recently and with the
exception of graphics / sound libraries, you have to code everything from
scratch.

It really depends on the library/engine you are using (if you're using one!)
OGRE3D integrates well with several packages, Unity has a builtin GUI system
that is stupendously inefficient, and the list goes on...

~~~
chipsy
It's definitely a pain point for games that there isn't much choice around for
general-purpose UIs. It's a big factor in why many indie games end up with
really shitty, underdeveloped UI.

Fortunately, you don't really need to reinvent Qt or CSS to get the job done.
A font system and a few hand-coded controls usually suffice.

I think the bigger problem is in sound synthesis and processing. This arena
still remains mostly confined to reverb algorithms, crossfaded tracks, and
pre-recorded samples, yet the depth of the subject goes about as far as
graphics does. So we're really missing out in terms of applying technology to
creativity here.

------
pixelcort
As for an Octree-based implementation, <http://sauerbraten.org/> comes to
mind. Sauerbraten (aka Cube 2) also has a real time collaborative world
editor.

------
donaq
Uh... I'm getting a 404 for this.

~~~
phoenix24
me too

------
feral
The article is called "Let's Code... an MMO" - but it is just a simple Octree
tutorial.

I don't mean to be negative, like the guys friends that laughed at the project
- but coding an MMO is several orders of magnitude more complex than putting
together an Octree renderer.

Best of luck with it, but, so far, nothing to see here.

~~~
nihilocrat
Writing an octree is definitely part of coding an MMO. It's a piece of
software, of which an octree or something similar is a fundamental part, thus
it totally fits. If this is too slow-paced or ground-level for your tastes ...
avoid game development, it just gets worse; more complicated, more pedantic,
more detailed, more time spent not actually creating game logic.

However, I'm also cheesed at the misuse of the term MMO, Minecraft is pretty
close but the lack of a centralized game world in any way makes it unlike most
MMOs, and by extension doesn't really fit the term. It is merely a persistent
multiplayer construction set. N8 (Neverdaunt) or Wurm Online (which notch had
formerly worked on), for example, are similar construction-oriented games that
definitely fit the MMO moniker because there /is/ a centralized persistent
game world. Dealing with the side effects of such a architecture does make
things an order of magnitude more complicated.

~~~
feral
I disagree where you say 'an octree is definitely part of coding an MMO.'

An Octree is just one technique to reduce the size of the Potentially Visible
Set of geometry that is sent to the rendering pipeline. While its a quite a
natural fit for a voxel-style world, such as minecraft, there are many
techniques to achieve this; an octree just being one.

If the Octree was the core technical challenge and data structure used to
create every MMO, then I'd have no issue with the article. But its really not
- its a simple technique, graphics 101, used to speed up rendering (or
collision detection).

Further, just having an octree is not nearly sufficient for handling MMO scale
issues - a lot more needs to go into structuring the world - when those larger
challenges are solved, I'd like to read his article on it.

------
Roritharr
Honestly i don't believe that he will get to the point of having something
playable. I watched too many projects like this fail and some succeed.

Those who succeeded all did NOT focus on their technology when talking about
their project and seemed to focus more on getting it to a point where you
could actually play something.

Of course you'd think that for a mmo a good technology base is key, but it
isn't because if you're honest: Your mmo won't attract a that large crowd in
such a speed that you won't have time to merge to something better and spend
the money you've earned from your customers of the first hour on improving
scalabililty.

Find something fun, get it done and then make it work would be my advice to
any aspring independent gamedeveloper.

------
omouse
Where's the maths?

------
binaryfinery
Oh piffle to all you nay-sayers. Look at what he's done! What fun! How great
it is to zoom around a world entirely of your own creation! Who cares about
the rest? Not me. Sure, I would have just used a 2D structure instead of a 3D
one, and maybe experimented with hex maps instead of squares, but this guy now
knows more about 3D oct-tree terrain rendering than I do, and anyone who has
commented so far, I'll wager.

Creation is never to be sniffed at.

------
alkavan
been checking some simple game development solutions in my spare time ... been
looking into SlimDX, and then discovered pygame - <http://www.pygame.org>,
works on linux and windows, it's a Python based lib, now i dunno python but it
was really easy to start crating nice stuff in no time.

~~~
daeken
Pygame is a great way to get started quickly. Once you move into the 3d world,
though, I seriously recommend pyogre (and its bindings for Bullet and all
that). You won't get the knowledge of how to write your own engine, but if you
want to do some awesome gamedev with minimal time sunk, you really can't beat
pyogre, IMO.

~~~
Jach
Do you have any thoughts on Panda3D? Like pyogre it's a C++ framework with
Pythonic bindings on top.

I think the most fantastic thing about Pygame is the huge library of open
games on its website. I wish these 3D framework sites had that.

~~~
daeken
I have looked at Panda3D, but I haven't built anything with it, so I really
can't compare the two very well. That said, Panda3D's goal is to be a game
engine, rather than just a graphics engine, as with Ogre. I imagine between
that and the poor documentation for pyogre, it may very well be easier to get
a game going with Panda3D. But personally, I love ogre and the bindings that
pyogre provides to other libraries, e.g. Bullet, make my life damn easy. Also,
the documentation issue _is_ an issue, but most things are wrapped so closely
to the C++ counterpart that you can just use the Ogre docs and be fine.

I spent a couple days writing wrappers around pyogre to do things like game
state management, nice GUI APIs, etc, and after that it was clear sailing. I
wish I had more time to work on the game all that stuff was for, really, but
such is life.

