Create cylinder with image on the top disk

hi all

anyone knows how to create a cylinder with an image on the top ?


Why not just make a model in blender or something with the texture you want then import the model asset?

could u give me more code details please?

Well there’s not so much code as there is some modeling to do then follow some of the tutorials regarding importing assets.

How to import assets into a project:

As to how to make the actual asset that depends greatly on the application you choose (i.e. Blender, Maya, 3D Studio Max)

Do some texturing/material tutorials.

Create Cylinder.

Create Geometry using the cylinder mesh.

Create Material.

Set Texture to material.

Set material to Geometry.

I ve done but image is completely deformed


cylinderGeometry = new Geometry("money", cylinder);

material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

material.setTexture("DiffuseMap", tex2);

material.setFloat("Shininess", 5f);




Yes, because the texture coordinates are completely wrong for your goal. Create a model in Blender, adjust the uv coordinates INSIDE Blender so that the image sits the way you want it and then you can load everything using assetManger.loadModel(“file.blend”)

but not exists a simple instruction with jme3

i download blender but it’s hard to build a cylinder with an image ate the top

afraid not, as @Dodikles said, blender + UV’s is what you need. Create a cylinder, go into edit mode, go to the top view, select the top faces, click U, then unwrap from project view. That will give you UV’s for the top of a cylinder.

It is a simple instruction: import your model from blender with properly mapped texture coordinates for your texture.

You need to practice with some blender tutorials to understand how texture mapping works.

Theres a detailed explanation on how to create a proper model in blender at the bottom of the page that was linked by thecyberbob:

And no, there is still no JmeSystem.doWhatDilemboWants(), you still have to read the tutorials and docs. That seems to work for most people so I can’t really believe you ever tried it that way.

LoL :stuck_out_tongue: Dilembo is still the good ol’ troll :smiley:

normen said:
And no, there is still no JmeSystem.doWhatDilemboWants()

There's only a JmeSystem.doWhatMadJackWants() method, but it's broken beyond repair. ;)

lol i like dilembo :P, he seems to know how to annoy normen like no other :smiley:

never seen such a shitty tool as blender

Well ya get what ya pay for… Oh ya. Blender is free.

I have never seen such an incapable developer like dilembo xD Ah, no consultant… Best care not to consult this guy xD

I ran into this problem just today. And, I too, am not a fan of using modelling software, if I can avoid it. So, I wrote this:

public static Geometry setUVPlanaerProject(Geometry geometry, Vector3f projectionNormal) {
    VertexBuffer position = geometry.getMesh().getBuffer(VertexBuffer.Type.Position);
    VertexBuffer texcoord = geometry.getMesh().getBuffer(VertexBuffer.Type.TexCoord);

    // Calculate the transform vectors
    projectionNormal = projectionNormal.normalize();
    float b = 0.0f != projectionNormal.x ? projectionNormal.x : projectionNormal.z;
    float a = 0.0f != projectionNormal.y ? projectionNormal.y : projectionNormal.z;

    Vector3f uVect = new Vector3f(a, -b, 0).normalize();
    Vector3f vVect = projectionNormal.cross(uVect);

    for (int i = 0; i < position.getNumElements(); i++) {
        // Read from vertex buffer
        Vector3f vector = new Vector3f();
        vector.x = ((Float) position.getElementComponent(i, 0));
        vector.y = ((Float) position.getElementComponent(i, 1));
        vector.z = ((Float) position.getElementComponent(i, 2));
        vector = vector.normalize();
        // Calculate uv coordinates
        float u =;
        float v =;
        // Write to the uv coords the the Texcoord buffer.
        texcoord.setElementComponent(i, 0, u);
        texcoord.setElementComponent(i, 1, v);

    return geometry;

Now I call this method for my cylinder geometry, and pass Vector3f.UNIT_Z, as the second argument.

Works like a charm! Enjoy!