How to display a picture(.png) on one surface of a cube?

i have a model with three Material slot,
index 0 is green
index 1 is white
index 2 is a surface with a picture ( i need modify the picture dynamic!)

First, you need to describe the texture using UV coordinates, then, you need to maintain the texture that is being expressed via those UV coordinates. I am assuming your picture is changing. So if that is the case, you need to update the texture object.

Use :
YourModel->SetMaterial(0 , greenMaterial);
YourModel->SetMaterial(1 , whiteMaterial);
YourModel->SetMaterial(2 , pngPictureMaterial);

Normally your model must have 3 geometries and must have texture coords.
For creating the above mentioned materials see the Urho examples or just copy one of the materials that comes with urho and change it to your needs.
(Or use CoreData/DefaultGrey.xml and change it to white and greenetc)

i need modify the picture dynamic!

How much dynamic ? if it is just few frames , load them all and change the textures using a timer , but if it is a avi file or other video then it is another story. Serach the forum there are couple video players floating around.

Welcome to the forums! :confetti_ball: :slightly_smiling_face:

This thread may help you in the right direction to get the texture painting working:

I have already use SetMaterial(index , Material) ,the index 0 and index 1 is normal .but the index 3 need a picture, i export from blender (Blender to Urho3D Guide)
export texture only support uv coordinate, i need use the picture fill the entire surface.

i need like this

my state is this

how to define a xml which use picture(texture) fill the entire surface.

thank you everyone!

One way is to use two cubes, so a smaller picture cube is inside a larger container cube, except one face is slightly outside the container cube.

Then you don’t have to worry about just putting material on just one side.

Just create a file like this :

    <technique name="Techniques/Diff.xml" />
    <texture unit="diffuse" name="YourPath/YourTexture.png" />

it is not work!

my code is:
//test load dynamic
//load face

the result is :



my picture (41.png) is:

mj_0.xml content:


<technique name = “Techniques/Diff.xml” />

<texture unit = “diffuse” name = “Textures/41.png” />


how to describe the texture using UV coordinates? please give me a tools!

The second picture shows that you don’t have UV coords defined properly. It’s like a planar map. The easiest way o set UV coords is to edit them in blender.

1 Like

i think i need a planar mapping ,but i can not find anything in documents

or perhaps a decal is another way!

For the UVs a simple Cube Projection should work. In Blender, select your piece then enter Edit Mode [Tab] and:

  • Select All [A] (or at least the face that needs texturing)
  • UV Mapping [U]
  • Cube Projection [C]

In the UV/Image Editor you can improve the fit by grabbing, rotating and scaling faces or vertices, just like in the 3D View.