Verlet and rendering in 2D

Started by
3 comments, last by serumas 11 years, 8 months ago
Let say I have a 2D box with 4 vertex and 6 constrains, and I have a texture of a box that goes with it. After some collision the box will rotate. How I know how much the box rotated so I can draw the box correctly oriented to the rotation of the vertex? I know I can simply loop through the vertex and plug the texture in the correct corner(I am using OpenGL btw), but I don't think this would help for textures that are not the same size or the same shape as the polygon.
Advertisement
Texture coordinates are usually defined for each vertex and do not change when the object is transformed. What are you trying to achieve?
You know the new positions of your vertices (which individually, by the way, have no rotation; only lines, such as the edges of your box, rotate) and you know the unchanging texture coordinates of your vertices, which is all you need to draw a quad or a pair of triangles. This works for any texture coordinates, irrespective of texture size or where the texture coordinates are within the texture; in fact there is no need for the texture coordinates of the four vertices to be arranged in a rectangle.

There is no such thing as textures with the same size and shape as a screen polygon, it makes even less sense than comparing the size of a pile of floor tiles and a room in which they could be applied.

Omae Wa Mou Shindeiru

I am thinking of something like this

the black lines and the red dots are the points and contrains, and the blue box being where the texture is suppose to be.
I could share my code of quad drawing on verlet, depending on 2 verlet points and them positions on texture...
With params:
a.vec b.vec -verlet vectors
atvec btvec - texture vectors for a and b
minvec,maxvec - texture min and max shape vecs initialy for sprite (0,0,1,1)
stretchx,stretchy - change size, initialy 1,1

its not a sprite drawing, but triangles with vertexes, but it could be easely remade to sprite

This topic is closed to new replies.

Advertisement