I want add a texture, this is an image(png), on the top of a cylinder. Unfortunately I have no idea about texturing.
Can anyone help me? This is my code:
turnTable = new Cylinder(100, 100, TABLERADIUS, 1, true);
Geometry turnTableGeo = new Geometry("turn-table", turnTable);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setColor("Diffuse", ColorRGBA.White);
mat.setColor("Specular", ColorRGBA.White);
Texture texture = assetManager.loadTexture("wood.jpg");
mat.setTexture("DiffuseMap", texture);
turnTableGeo.setMaterial(mat);
turnTableGeo.setLocalTranslation(0, -0.5f * TABLEHEIGHT, 0);
turnTableGeo.rotateUpTo(Vector3f.UNIT_Y);
You have to do this in a 3D modelling software like Blender! Best would be you combine both textures (the black one and the one which you want to add) to one new texture file. In Blender you will have to apply the texture coordinates to that cylinder model.
Well, if you really want to do it in JME (for whatever reason), which is way more complicated you could use a plane, move it so that it fits the top and then apply a texture with alpha channel.
This is not proper though!!! Really, do it in Blender!
Learning blender is a time investment with an amazing return if you do a lot of related stuff. I can’t believe how useful it’s been to me, I can literally make nice looking animated icons for anything in less then 2 minutes.
No example code could possibly fix that issue (well, unless you want solid colors). If you can’t learn a tool like Blender, you’ll have to obtain ready-made 3D assets that jME can work with.
You could try one of those low-poly graphics themes like this…
And before you say it, yes I know, using Blender feels like putting your brain in a Blender. But we can’t deny that it’s damn powerful, at the best possible (monetary) price.
Game engines are just that, engines. Not a 3d modeling tool. Modeling tools are very complex beasts that have a huge number of features to do such things as UV texturing.
In every game engine out there. You import models + textures from a modeling tool. Personally i think blender is a very good tool for the modeling part.
You will need to learn about texturing and you wouldn’t go wrong with a quick UV texture blender tutorial. There are many. Then you can just import it directly.
I know 3D stuff is really cool but I need just once then never again.
I’ve created a cylinder in blender and added texture but in blender the texture is only on the top and in jmonkey on both side and the edges, too.
Its about texture coordinates and then maths. You want to map a texture to a bunch of triangles that are arranged in a pie-like formation. You have to assign the correct coordinates in the texture (from 0,0 to 1,1) to the vertices that make up these triangles.