Advertisement

Dragging part of an image

Started by February 04, 2004 09:59 PM
2 comments, last by Leroy1891 21 years, 1 month ago
I have Microsoft''s Picture It! software and it allows you to grab a point on a picture and drag it around. Does anyone here know how I might be able to accomplish this myself?
on mousedown event:

obtain x and y from mouse.
find out which point is closest to that and store it''s id.
set a global flag indicating "dragging" is true.

on mousemove event:

if "dragging" is true, AND if the id has a value >= 0, set the x and z (or whatever you want) of the point stored in the id to the x and y value of the mouse (maybe transform them, depending on the mode you are in (glOrtho?))

on mouseup event:
set "dragging" to false
set id to e.g. -1, indicating no point is selected for dragging (optional)
Advertisement
Sorry I wasn''t perfectly clear there. I don''t mean the whole picture, I mean drag a small part of the picture to distort it
Try something like
draw picture as texture on high density gridselect start pointselect end pointget drag direction vectorscale down direction vector by something like    dx = dx / picture_width;    dy = dy / picture_height;for each vertex on grid    get distance from start point    if the vertex is in range of tool (it has some kind of too_radius)        use some gaussina or sinus based function to calculate force based on radius. something like force = cos( radius / tool_radius * Pi * 0.5f );        apply (force * direction vector) to texture coordinatesrepeat  


You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on February 5, 2004 3:37:16 AM]
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement