Sign in to follow this  
cnboy0212

Verlet and rendering in 2D

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Texture coordinates are usually defined for each vertex and do not change when the object is transformed. What are you trying to achieve? Edited by apatriarca

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 Edited by serumas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this