Create a Hexagon in jME3

Hey @all,

i want to create a game like minecraft or the hex engine to learn a little bit more about 3D programming.

I want to create a agame like that:

WIP Hex Engine - Walkthrough One - YouTube

So, i need some hexagons… i don’t know howto do it so far, but i’ve already found this: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes

But theres only a little quad, so i don’t know howto change to hexagons…

[java]

Vector3f [] vertices = new Vector3f[4];

vertices[0] = new Vector3f(0,0,0);

vertices[1] = new Vector3f(3,0,0);

vertices[2] = new Vector3f(0,3,0);

vertices[3] = new Vector3f(3,3,0);

[/java]

so i want 6 points but i can’t write it like this:

[java]

Vector3f [] vertices = new Vector3f[4];

vertices[0] = new Vector3f(0,0,0);

vertices[1] = new Vector3f(3,0,0);

vertices[2] = new Vector3f(0,3,0);

vertices[3] = new Vector3f(3,3,0);

vertices[4] = new Vector3f(3,3,0); //??

vertices[5] = new Vector3f(3,3,0); //??

[/java]

because i don’t know what i’m suppost to write in the vector3f …

can anyone teach me howto do that?

thanks,

tom

First learn about 3d programming, then do a minecraft game.

“Games like Minecraft” are the hardest places to start, not the easiest. Just because the graphics look simpler doesn’t mean that it is simpler.

It’s basic math. You have the formula of a circle, you want 6 equally spaced points around that circle…how do you do it?

(There’s actually several ways using the JME3 libraries and several more just using the basic java math ones)

First start 2d. Then take a piece of grid paper and mark the hexagon points on it and use those as a reference when building your arrays. The tutorial you linked describes fully what a vertex array and an index array are. A quad has 4 vertices, a hexagon has 6. You will have to enter in the correct indices.

http://rbwhitaker.wikidot.com/index-and-vertex-buffers

okay, i know that it’s hard to program something like this, but it’s even better to learn like this because i can learn better on this way… (and i’ve already some little 3d games but without a story and now i want to make an endless-game…) so i’ll look for a solution… thanks

I’d advise you to draw a 3X3 square on a square paper. That is what the following gives:

[java]Vector3f [] vertices = new Vector3f[4];

vertices[0] = new Vector3f(0,0,0);

vertices[1] = new Vector3f(3,0,0);

vertices[2] = new Vector3f(0,3,0);

vertices[3] = new Vector3f(3,3,0);[/java]

The first value is the x value on the square paper, the second is the y value on the square paper. The third is the z-value. If you increase it, imagine the vertex coming out towards you. Experiment with different shapes, and try and convert them into 3D shapes by duplicating the vertices and increasing the z value.

okay i’m now using this:

[java]

Cylinder hexagon = new Cylinder(200,6,200,10,true);

[/java]

@tommy5696 said:
okay i'm now using this:
[java]
Cylinder hexagon = new Cylinder(200,6,200,10,true);
...
[/java]

I think I just died a little bit on the inside
2 Likes
@thetoucher said:
I think I just died a little bit on the inside

LOL. I think like we have "Box Worlds are not made of boxes" we're going to end up needing a "Hex worlds are not made of cylinders or hexoids (or whatever)". :)

xD ^^ ;o :brainsout:

1 Like

What they mean is: if you are making a hex world, you cannot use 6 sided cylinders. And if you are trying to learn how to these games work as a programming exercise, you just cheated yourself. You will find out very shortly that performance hits a brick wall, shrivels up an dies: “when I add more than 1000 hexagons to my scene I get 1 FPS”

Take a step back and learn how meshes are constructed. You will need to know this to build the scene out of just a few meshes (not thousands), as this is how box worlds and hex worlds work.

1 Like

…and that’s one of the reasons we’ve suggested you are starting from the hardest place. This isn’t about learning to swim from the deep end of the pool… it’s about learning to swim by being thrown into the ocean.

1 Like

so i’ll try it but i haven’t ideas for anything interesting and i’m not the best googler… are there any tutorials for this? so i want to create an endlessgame with a world-manager but it seemes that i’ve to few approaches for this. And how do i hexagons without meshes? thanks for help…

Read up on voxel worlds. You use meshes - but you create one mesh for the whole world (or big chunks of it at least) not hundreds of individual items, one for each hex.

If you are new to this you are better off using the proper terrain stuff (which there are tutorials for) as believe it or not it’s actually easier…

Read up on voxel worlds. You use meshes – but you create one mesh for the whole world (or big chunks of it at least) not hundreds of individual items, one for each hex.

okay, i'll try it.

If you are new to this you are better off using the proper terrain stuff (which there are tutorials for) as believe it or not it’s actually easier…

yes, that's waht i've done before, and now i want to learn some new things...