Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Mesh textures

edited April 2012 in Questions Posts: 65

I got a query. Is it possible to texturize a mesh object with an image object? I tried but failed to do. If its possible can some one give an example code to show how to do it?



  • SimeonSimeon Admin Mod
    Posts: 5,434

    @rashedlatif you can set the mesh.texture property to either a string (sprite name) or an image object. For example:

    myImage = image(400,400)
    -- Fill myImage with something
    m = mesh()
    m.texture = myImage
  • edited April 2012 Posts: 65

    Thanks Simeon. That's exactly how I tried but nothing happened. Now realized where I made mistake. Thanks :)

  • edited August 2014 Posts: 277

    furthermore, @Simeon, is it possible to make this texture more or less transparent?

  • Jmv38Jmv38 Mod
    Posts: 3,297

    @Rodolphe i suggest you read the mesh built in documentation. It explains it all. Or ignatz tuto on meshes. But the answer to your question is setColor() function: it will set the transparency of each vertex to what you want.

  • edited August 2014 Posts: 277

    oh excellent... thanks! I should have read the documentation at least, indeed (I did try setColor() but it didn't work, it should be something bad in my code then) :)

  • Jmv38Jmv38 Mod
    Posts: 3,297

    you must setColor for each vector of the mesh (or rect if you use them). Post your code if you cant find your error.

  • edited August 2014 Posts: 1,976

    @Jmv38 Or you can use setColors(color) to color ALL the vertices!

  • Jmv38Jmv38 Mod
    Posts: 3,297

    good point!

  • Posts: 277

    That's what I did, and it does work now! :)

Sign In or Register to comment.