Howdy, Stranger!

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

In this Discussion

Tagged

Mesh textures
  • 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
    Posts: 3,611

    @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
    
  • Thanks Simeon. That's exactly how I tried but nothing happened. Now realized where I made mistake. Thanks :)

  • RodolpheRodolphe
    Posts: 130

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

  • Jmv38Jmv38
    Posts: 2,686

    @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.

  • RodolpheRodolphe
    Posts: 130

    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
    Posts: 2,686

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

  • SkyTheCoderSkyTheCoder
    Posts: 1,495

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

  • Jmv38Jmv38
    Posts: 2,686

    good point!

  • RodolpheRodolphe
    Posts: 130

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