SDK PLugin development - painting tool

A forum dedicated to George scripting questions
Post Reply
User avatar
idragosani
Posts: 987
Joined: 06 May 2008, 00:39
Location: Germantown MD
Contact:

Re: SDK PLugin development - painting tool

Post by idragosani »

Maybe I should request the latest SDK and see if it plays better for Linux...
Brett W. McCoy -- http://www.brettwmccoy.com
TVP Pro 10 : Intel i7 2600 3.4 GHz : 8GB RAM : Ubuntu Studio 14.04 : Cintiq 21UX
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Im not having much luck using the msg PIDRAW_DRAW. Im not sure I want to use it, but Im trying to see if it works good. If I call TVInstallFunction when my plugin button is clicked, I get the msg and I can identify when a stroke is done, but there is no actual stroke, I mean, the brush tool stops working even though it is still active. If I click the button and then the brush tool again it draws but I don't get the messages. I tried calling TVInstallFunction in different places but it doesn't work. I didn't find any example of this.

What am I doing wrong?
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

Everything is normal :)

If you can have all the messages after you clicked on your plugin button, it means that's work, but it's up to you to draw what you want at the given coordinate on the image.
By these messages, you can/must create your own/customized tool to interact with the image.
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

I understand. Thats OK because the scribbles for painting must be completely solid any way. OK, so now I've got everything working except this, and its really cool. I don't understand how to update the display when getting the messages in realtime. I tries updating the iFilter->current buffer and then updating the display but it doesn't work. Should I call TVExecute every time I get this message, and then update the display in the PI_Work function?
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

Ok, if you draw on the iFilter->Current buffer, just call TVWriteLayerData( PIFilter, src, x, y, w, h, mod ) with the src set to 0, so TVPaint can know something change in the image and so update the display.

And about TVExecute(), you shouldn't use this function in your case, because its main use is for doing a same process (like FX) over a sequence of images.
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Thanks, it works. I have a simple square brush. It seems like the sampling of the mouse movement is not dense enough, and if I move fast the stroke is dashed, or maybe the processing takes too long. Should I interpolate between samples, or is there any built-in way/other solution, to do it?

Thanks
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

Yes, it's normal, you get the available cursor position.

To interpolate between each position, you can do want you want :)
Nothing is built-in, so you can interpolate as the way you want (dichotomous, as a segment, spline, ...)
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Yes, That's what I thought :? Well, maybe Ill add that sometime later, as I don't really know much about it. Linear interpolation is as far as I can go without looking for help elsewhere.
OK, Next problem. I have no choice but jumping around layers while processing. I need to read the outlines separate from the color strokes, and then write the resulting coloring to a third layer. It all works very nicely,
but I cannot do Undo correctly after my plugin executes. It seems what I do in the plugin is making a complete mess in the undo history.
I don't know, maybe Im doing something wrong, maybe I can take a snapshot of the chain or something. Either way, it is a very annoying problem. If there is no easy solution I think one should be added to the SDK.
Thanks, I hope to release the first version pretty soon.
User avatar
Mike
Posts: 1050
Joined: 16 Feb 2006, 08:58

Re: SDK PLugin development - painting tool

Post by Mike »

That's strange, could you open the history panel (Windows > Tools > History) and see what happens/adds when you execute your plugin.

And could you post a screenshot of the panel to see what it contains (with all the actions displayed if possible, and mark at which moment you start to use your plugin).
TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

Sorry for the delay. Here are some screenshots:
This before I click my plugin button:
Image

Now I click a button that installs a meta message and draw a scribble:
Image

Then I click the other button, which essentialy does the same thing and draw another scribble, and the plugin then paints the lowest layer:
Image

Then I click try to go back to the beginning in the history panel, and as you can see it makes little sense:
Image

Hope that helps.
PS, I can send you the plugin if you want. I'm pretty close to releasing a first version actually. I compiled and tested it for osx and windows (32 bit). I want to check the 64 bit version next
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: SDK PLugin development - painting tool

Post by Hervé »

oferk wrote: PS, I can send you the plugin if you want. I'm pretty close to releasing a first version actually. I compiled and tested it for osx and windows (32 bit). I want to check the 64 bit version next
Yes, it could be a good solution to help us to find the bug
Hervé ADAM, TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

OK, lets try with this one. Some usage instructions youll probably need:

1. You must have at least 3 visible layers in the project.
2. On the top layer you draw something, or use a scanned image (with after basic scan cleaner)
3. Then you select the middle layer, and draw the scribbles with the plugin on that layer. The plugin will write the resulting colors to the lowest layer.
4. Using the plugin:
The lazybrush algorithm takes two or more color scribbles (patches of color on the image) and assign each pixel to one of the scribbles, taking into account the outlines in the drawing layer. Unlike the fill tool, no pixel is left un-colored. You basically want one scribble for each region of your drawing, because more then that makes no sense.
5. Use the Add scribble button (in the lazybrush pulgin's panel), to add scribbles to the middle layer. You must have at least two different colors for the plugin to have something to do.

That should be enough, there is also a button for transparent scribbles, but it is not important.
Here is the plugin and two source files. The code is a still little messy...

https://www.dropbox.com/s/drf26rfsiuxhrtz/lazy.rar

I hope it works.
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: SDK PLugin development - painting tool

Post by Hervé »

First look on your code:

-Don't change the current layer during the TVExecute() process or don't use TVExecute() ( the undo bug come from here )

-Set only the area changed in TVWriteLayerData() and use the good flag ( CB_WRITE_QUIET don't refresh the display and CB_WRITE_UPDATE do the refresh )
TVWriteLayerData(iFilter, NULL, 0, 0, iFilter->ImageWidth, iFilter->ImageHeight, 0, CB_READ_CURRENT);

-Don't refresh all the display if you change only a small part ( in your case use CB_WRITE_UPDATE in TVWriteLayerData() and don't call TVUpdateDisplay )
TVUpdateDisplay(iFilter, iFilter->WorkArea_x1, iFilter->WorkArea_y1, iFilter->WorkArea_x2, iFilter->WorkArea_y2 );
Hervé ADAM, TVPaint Team
oferk
Posts: 94
Joined: 23 Jul 2011, 21:27

Re: SDK PLugin development - painting tool

Post by oferk »

OK, I will fix this. If I can't change the current layer I won't use the TVExecute function. That means It won't be possible to paint a sequence with one click.
OK, Ill see if it works better.

Thanks.
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: SDK PLugin development - painting tool

Post by Hervé »

oferk wrote:OK, I will fix this. If I can't change the current layer I won't use the TVExecute function. That means It won't be possible to paint a sequence with one click.
OK, Ill see if it works better.
Thanks.
You can get the current image selection with the cmd tv_layerselectinfo and apply yourself the effect on each frame.
Hervé ADAM, TVPaint Team
Post Reply