Use Quad as Mesh Texture

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
RandomUserName
Prole
Posts: 7
Joined: Mon May 14, 2018 12:35 pm

Use Quad as Mesh Texture

Post by RandomUserName »

My Games Map is based on textured Meshes.
It works fine if I'm using a static Image as the Texture.
Now I'm trying to animate the Maps Tiles by using Quads in a Sprite Sheet as the Texture for the Meshes and switch them for every step in the Animation.
Problem being that Mesh:setTexture doesn't accept a Quad as an Arguement, neither does love.graphics.draw when using a Mesh as the drawable.

The only other way I can think of is defining a seperate Mesh for each Sprite, then cycling the Meshes to archieve an Animation.

Is the first approach even possible?
If so, which would run faster, given that the cycling happens thousands of times per Frame?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Use Quad as Mesh Texture

Post by pgimeno »

Welcome to the forums.

You can change the UV of the vertices of the mesh by hand, using Mesh:setVertexAttribute, but that depends a bit on how you created the mesh vertices.

The default attributes are listed here: Mesh:getVertexFormat
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Use Quad as Mesh Texture

Post by bobbyjones »

With meshes you define the u,v for the vertices. Which is essentially the coordinates for a quad in the texture. You can then add multiple sets of coords to one mesh and cycle through them with setDrawRange. (I think anyways. I've never tried this.)
RandomUserName
Prole
Posts: 7
Joined: Mon May 14, 2018 12:35 pm

Re: Use Quad as Mesh Texture

Post by RandomUserName »

Thanks, I'm now creating the Mesh in a for loop while using setDrawRange to get the desired uv coordinates.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests