Howdy, Stranger!

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

In this Discussion

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?

Tagged:

Comments

  • Posts: 3,763

    @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: 147

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

  • Posts: 2,813

    @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: 147

    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) :)

  • Posts: 2,813

    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,741

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

  • Posts: 2,813

    good point!

  • Posts: 147

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

Sign In or Register to comment.