I have the following code:
[java]
Spatial card = assetManager.loadModel("/Object/Card/card.blend");
card.setLocalTranslation(3f, -2f, 0.0f);
card.scale(1f);
Material card_mat = new Material(assetManager, "/Common/MatDefs/Misc/Unshaded.j3md");
card_mat.setTexture("ColorMap", assetManager.loadTexture("/Icon/Monkey.png"));
card.setMaterial(card_mat);
rootNode.attachChild(card);
[/java]
But the pic is not being applied to the object which has a shape of card. It is just black.
@yang71 After going through the tutorial, it seemed to be that UV is for mapping 3D to 2D. But my model is already a plane for a card. What should be done in this case?
Your card probably have many faces (triangles). Esp. if it has some thickness, and even more rounded angles.
You have to tell your shader how to draw you texture on any of these triangles. This is what the UV does.
tsogtoo: Learning about UV Mapping seems to be your next quest. Its a bit like wrapping a christmas present … only in reverse funnily enough. Its a tool of the trade which must be learned if you want things textured.
Hey, I haven’t understood the answers properly. Let me explain what I exactly need.
I am designing a scene for a poker game that includes a table, chairs, cards, players and chips. I have designed the models for each one of them in blender, but haven’t applied textures or materials to the card model. The card model is simply a plane made into a rectangle. Now, when I try to apply a .png image to the card model in jMonkey using addTexture(), it does not show any texture.
What is required, and how is it done? Please explain a little in detail because I have not used blender or jMonkey too much before.
All we have said is still valid. Since the texture has not been applied in Blender, it has no texture coordinates (UV-map). Therefore it cannot be textured in JME.