Page 1 of 1

Hexagon Grids

Posted: Sun May 24, 2009 10:05 am
by monkeycracks
Here you can find my Hexagon Grid project. It doesn't currently have any plans to be used by me, but it was a fun learning process. I based the code from an article that I found at http://www.codeproject.com/KB/graphics/ ... part1.aspx.

It's fairly easy to use, with the code being:

Code: Select all

#include "Main.h"
#include "Hexagon.h"
#include "Grid.h"

#pragma comment(lib, "irrlicht.lib")

int main()
{
	IrrlichtDevice* dvc = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 32, false, true, true, 0);
	IVideoDriver* drv = dvc->getVideoDriver();

	dvc->setWindowCaption(L"Hexagon Grid");

	Grid grid;
	grid.create(7, 7, 35); // 7x7 grid - side of hexagon is 35 units. 7 is max, see grid.h for why. I'd like suggestions here

	while(dvc->run())
	{
		drv->beginScene(true, true, SColor(255, 0, 0, 0));
		grid.draw(drv);
		drv->endScene();
	}

	dvc->drop();
	return 0;
}
Looks easy enough, right?

http://www.deliciousjesus.com/wp-conten ... 20Grid.rar (be sure to get the whole thing, the forums broke the link) to download the source and executable. Keep in mind that I don't comment my code very well, but if you have any questions feel free to ask!

Screenshot:

Image

I might have a 3d implementation up soon.

Posted: Sun May 24, 2009 1:31 pm
by Dorth

Posted: Sun May 24, 2009 6:27 pm
by Cloudef
I used this kind of hexagonial grid in one of my Nintendo DS Projects. Its really useful for Touchscreen keyboards :)

Posted: Sun May 24, 2009 9:37 pm
by monkeycracks
Dorth wrote:http://www.codeproject.com/KB/graphics/ ... part1.aspx
and
http://www.deliciousjesus.com/wp-conten ... 20Grid.rar

Thanks for sharing, but mind the links, it's not that hard ^^
I'd been up for far too long and couldn't remember how to do that. Thanks!
I used this kind of hexagonial grid in one of my Nintendo DS Projects. Its really useful for Touchscreen keyboards
Sounds interesting. All that DS stuff is beyond me, but hopefully it'll help anyone looking to get into it.

Posted: Mon May 25, 2009 9:24 am
by devsh
well if it was 3d or faked 3d it would remind me of this

Image

Posted: Mon May 25, 2009 8:35 pm
by monkeycracks
I remember that game. Used to be one of my favorites, but I forgot it used hexagon grids for that sort of thing. Maybe this'll get more application than I'm expecting.