Missing hexagon

Hi,

first of all, i’m fairly new to this, so maybe i just searched the wrong way. I need a hexagon for my project, and some quick googling revealed this. There is a hexagon listed (and some other forms) but i can’t import it for some reason.

import com.jme3.scene.shape.<…> only offers me AbstractBox, Box, Curve, Cylinder, Dome, Line, PQTorus, Quad, Sphere, Torus.



do i need to download the other forms somewhere and include them, or what’s the deal here?

Thanks in advance for your help!

jME3 doesn’t expect you to use the basic shapes but either load models or define the vertexes for your shape yourself: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes

You’d seldom build a game world from primitive shapes, not even minecraft does that, although it looks like it :wink:

honestly, it will only use basic shapes :o it’s an adaption of a board game, which only contains hexagons, cylinders, and cubes. (well, some circles for markers too)

Ahah… but are the hexagons flat or 3D shapes? Is there going to be one of them or is it a whole flat game board of hexagons?



Beyond the very simplest of shapes things rapidly take on a life of their own and either become so general to be overly complex or so specific to one use-case as to eliminate all others.



You can sort of simulate a hexagonal shape with a cylinder with the proper number of radials. If it’s flat shaded it might work otherwise it will look round if you are going for something 3D.

Depending on the size you won’t, as around 3000 object count will start to kill fps badly!



For a smalll monopoly sized field there is no much need for more intelligent system, same might go for D&D dungeon, but if you think about battle isle or similar you better do a more intelligent approach

ah, i think i see your point :slight_smile: still, i’d like to know why they aren’t included anymore. they certainly would come in handy for some playing around while learning :smiley:

More code = more bugs = more maintenance. No reason to keep things around like that, I guess… plus it’s pretty easy to create custom meshes or just run a modeling tool to build something quickly.



The current primitives are nice for debugging other things and testing that the scene graph works as expected when learning… but even they are extremely limited in what they provide.



…besides, a cylinder with 6 radials is a hexagon.

Sudden… Urge… To play… Q-Bert… WHY O WHY…



:stuck_out_tongue:



EDIT: And so I did. Man I still suck at level 3. T_T



~FlaH

tehflah said:
Sudden.... Urge.... To play.... Q-Bert.... WHY O WHY...

:p

EDIT: And so I did. Man I still suck at level 3. T_T

~FlaH


...except Q-bert was cubes. :) Ah, though I guess in isometric perspective the cubes had the outlines of hexagons.

Yeah, that’s why I was WHY O WHY. It didn’t make sense because those are cubes, even if the isometric perspective fools the eye into the hexagon patterns. I have no idea why it popped into my head, but I thought it might get a chuckle or two :stuck_out_tongue:



And besides, Q-Bert is awesome. That is all. :slight_smile:



~FlaH

hello



here is code for a class I made because I needed a grid of hexagons as well. This shape has its normals pointing along the positive Y axis so you may need to rotate the shape if you are using a different orientation. Also, I did not do the tex-coords correctly, I can almost guarantee, so you will need to fix that before applying any textures to the Mesh.



The argument value of a for this shape is the value of Side as found within this picture

http://www.emanueleferonato.com/images/hexagon.png



anyways, here you go



[java]import com.jme3.export.InputCapsule;

import com.jme3.export.JmeExporter;

import com.jme3.export.JmeImporter;

import com.jme3.export.OutputCapsule;

import com.jme3.scene.Mesh;

import com.jme3.util.BufferUtils;

import java.io.IOException;

import com.jme3.scene.VertexBuffer.Type;

/**

*

  • @author Joshua Aurich

    */

    public class Hexagon extends Mesh{

    float a;

    float rt = (float) Math.sqrt(3);

    /**

    *
  • @param a_value : Note see 30-60-90 triangle

    /

    public Hexagon(float a_value){

    super();

    a = a_value;

    updateGeometry();

    }



    public void updateGeometry() {

    // setVertexCount(6);

    setTriangleCount(4);

    float[] vert = {

    0,0,a
    rt, //1

    a,0,0, //2

    3a,0,0, //3

    4
    a,0,art, //4

    3
    a,0,2art, //5

    a,0,2art}; //6



    float[] norm = {

    0,1,0,

    0,1,0,

    0,1,0,

    0,1,0};



    int[] index = {

    0,5,1,

    2,4,3,

    1,4,2,

    4,1,5

    };

    setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vert));

    setBuffer(Type.Normal, 3, BufferUtils.createFloatBuffer(norm));

    setBuffer(Type.Index, 3,BufferUtils.createIntBuffer(index));

    // setBuffer(Type.TexCoord, 2, new float[]{0, 0,

    // 1, 0,

    // 1, 1,

    // 0, 1,1,1,1,0});

    updateBound();

    updateCounts();



    }



    public void read(JmeImporter e) throws IOException {

    super.read(e);

    InputCapsule capsule = e.getCapsule(this);

    a = capsule.readFloat("a", 0);

    rt = capsule.readFloat("rt", 0);

    }



    public void write(JmeExporter e) throws IOException {

    super.write(e);

    OutputCapsule capsule = e.getCapsule(this);

    capsule.write(a, "a", 0);

    capsule.write(rt, "rt", 0);

    }

    }

    [/java]