PDA

View Full Version : Grease Pencil Max script


Dokun Oyetunde
03-09-2006, 07:43 PM
Hi Guys

Anyone interested in writing a 'Grease Pencil Script' like the one Maya has called the 'poor man's grease pencil', or something. Brilliant for roughing out Poses and your Lines of Action before animating. Pixar also used its own version for the incredible's.

This will be brilliant!

Thanks

joconnell
03-10-2006, 12:20 PM
Yup I'll take a look at it.

TheGameMaker
03-10-2006, 01:43 PM
i donīt have any expirience with maya, could u discripe it a little bit more??
greetz TGM

PEN
03-10-2006, 02:04 PM
You can write to the screen in Max with gw but I have never had good luck with it. If I remember right MEL had a bit better hendling on this. Bobo might correct me on this as I haven't tried using it in Max 7 or 8 but I know that my scripts that I set up in Max 6 still don't work overly well.

Any clue as to what the tool in Maya that you are using does? Does it draw open GL renders to the screen?

Breinmeester
03-10-2006, 02:10 PM
Jason Schleiffer wrote that tool. It uses Maya's pencil tool (to draw lines as objects) and links it to a frame number. You can then edit what drawing corresponds to what framenumber.

It sure would be handy to have in MAX. I was about to mail Autodesk the other day with some suggestions to ease up MAX as an animator's tool and the grease pencil was one of them.

Maybe Bobo or Jason can join in on the conversation??

PEN
03-10-2006, 02:50 PM
Hey how about that I have it working. It isn't drawing at my mouse yet which is odd as it is only in the screen Y axis that it is backwards. Very cool. I'll post it if I get it all working.

Breinmeester
03-10-2006, 03:28 PM
Sounds cool, man! I invited Jason, hope he drops around. Bobo had his PM list full, so couldn't invite him.

Keep us posted, Paul!

PEN
03-10-2006, 03:46 PM
Well here it is...

http://paulneale.com/scripts/PEN_whiteBoard.zip

Drop in the macro in 3dsMax8\UI\macroScripts and add it to your fav quad, button bar or menu and have fun.

PEN
03-10-2006, 03:47 PM
Oh sorry John:( I beat you to it.

joconnell
03-10-2006, 03:50 PM
Don't worry about it Paul - i'm getting used to it ;)

Bobo
03-10-2006, 04:01 PM
Maybe Bobo or Jason can join in on the conversation??

This is my first test:

http://www.scriptspot.com/bobo/mxs7/PencilTool/Bobo_s (http://www.scriptspot.com/bobo/mxs7/PencilTool/Bobo_s%20Tools-PencilTool.mcr) Tools-PencilTool.mcr (http://www.scriptspot.com/bobo/mxs7/PencilTool/Bobo_s%20Tools-PencilTool.mcr)

This one paints strokes to the viewport while in selection mode (which might be a bad idea, but I wanted to keep the interactivity of the scene behind it). So you should go to Paint Selection mode (the last in the selection tool flyout, or press Q multiple times).

You can set any color, use colors from the preset palette, delete all strokes or delete the last stroke. The drawing is registered as redraw view callback, too, so after you stop drawing, you can pan/zoom/orbit or work on your objects and the drawing will persist as long as the tool is open.

If you close the tool and open it again, the last drawing will be shown again and you can continue drawing. The data will be saved with the MAX file, so you can open a file, start the tool and continue working.

Options to delete a specific (not just the last) stroke could be added later. Same with changing the color of an existing stroke.

Next will be storing a painting per frame, onion skinning and animation playback...

PEN
03-10-2006, 04:38 PM
Geezzz, show me up or what:S I guess I got what was comming to me eh John?

Thanks bobo. I will learn alot form this as I didn't know you could do any of that.

PEN
03-10-2006, 04:48 PM
Bobo, the whole selection thing is a bit of a pain. Interesting how you are going about this. Just how are you able to orbit view ports and not loose the drawing, what are you doing different then mine?

PEN
03-10-2006, 04:52 PM
I think I see. You are saving the array of lines to persistent data and then redrawing them. Very cool. Please let me know if I'm on the right track. The selection mode drives me nuts but very cool.

jschleifer
03-10-2006, 04:57 PM
Heya folks, thanks for the invite! :)

the script for maya that I wrote is a pretty nasty hack.. basically I'm creating nurbs planes which are parented to the camera that are made "live" which can be drawn on with a curve tool.

So when you add a "draw frame", it creates a nurbs plane, parents it to the camera, sets it live, and then puts you in the pencil tool.

The nifty bit, though, is making it so onion skinning works (just templating the previous and next frames) and allowing you to modify the timing of your animation quickly by moving keys around in the text scroll list.

Also, having layers of drawings is incredibly helpful..

I'd like to add line width and color in the future. :)

JHaywood
03-10-2006, 05:32 PM
From what I understand, the really cool thing about the Disney version of this tool is that you can draw over a chain of bones and the bones will align themselves, as much as possible, to the line. So, for example, you have a spine setup with a few bones in a chain, or a some tentacles or a tail, and you draw on the viewport, the bones will rotate to match the curve. I'm guessing you'd have to draw in at least two viewports, like the front and side, to rotate the bone chain in three dimensions.

How's that for a challenge? :)

PEN
03-10-2006, 05:38 PM
Thanks for dropping in Jason. That does sound a bit of a hack but hey if it works. We are doing it in Max by drawing to the viewport and not creating geometry. I havn't looked at line thickness or transparency but that could be interesting but I don't know if it can be done with this method.

I'm sure Bobo will find a way though.

Bobo
03-10-2006, 05:41 PM
I think I see. You are saving the array of lines to persistent data and then redrawing them. Very cool. Please let me know if I'm on the right track. The selection mode drives me nuts but very cool.

I changed it so it freezes all objects when you enter the pencil mode, so you don't select anything accidently. With "show frozen in gray" enabled, of course...

Here is the latest version with:

*Support of drawings per frame (relative to the first frame in the segment)
*Frame Offset to define the start frame or shift the animation
*Onion Skinning (currently up to 5 frames) with user-defined color reduction per layer
*Copying of a whole frame to the next frame
*Instancing (!) of a whole frame to the next frame - drawing in either frame will update both
*Deleting a specified stroke - if the current stroke > 0, it will be shown in the Onion Skin color reduction factor
*Copying a specified stroke to the next frame - using the same number as above
*Changing the color of a selected stroke - using the same number as above
*Deleting one frame or all frames
*Deleting Last Stroke is still there as a quick undo.

I also added << and >> buttons for quickly sliding in time. Hold Shift to jump to first/last frame of the segment.

Same place, same file.

jschleifer
03-10-2006, 05:44 PM
I'd love to do it by drawing directly into an imageplane & saving the files as images.. but maya doesn't have the ability to do that right now, or at least I can't figure out how to get it to. :)

the nice thing about doing it as geometry, however, is that it saves with the file & you can export it & bring it into other files, too. :)

jschleifer
03-10-2006, 05:46 PM
sounds impressive, bobo! :)

wish I had max so I could try it out! haha :)

JHaywood
03-10-2006, 05:53 PM
Bobo, I've read posts on the public Max webboard saying that persistent globals == bad, but I notice you're using them here. I've been using custom attributes on the root node to store persistent data because of Larry's warnings about persistent globals. Is it really not that big of an issue?

Bobo
03-10-2006, 05:54 PM
I'd love to do it by drawing directly into an imageplane & saving the files as images.. but maya doesn't have the ability to do that right now, or at least I can't figure out how to get it to. :)

the nice thing about doing it as geometry, however, is that it saves with the file & you can export it & bring it into other files, too. :)

I used to have a "Freehand Spline" script that would have been rather useful to mimic what you did in Maya.
http://www.scriptspot.com/bobo/mxs2/freehandspline/

My current version uses virtual painting in the graphics window, so it is rather tricky to edit after the fact, but it is great for leaving notes in animation files. It reminds me of the way Cinesync works with Quicktime files.

I have a full bitmap painting utility as an example in the MAXScript Reference. (I wrote it in a similar fashion after somebody asked on a forum how to draw in a bitmap). It supports brush sizes and shapes, spray, texture coordinates unwrapping (with sprayed brushes these look very cool ;)), erasor and painting on scene objects in 3D. I could use that code to paint on an image plane with alpha channel the way I did here:
http://www.scriptspot.com/bobo/mxs6/VolumePreview/

So there are at least 3 approaches to get a painting in the viewport.
My current prototype just felt easier and more fun at this point.

Thanks for the inspiration!

Bobo
03-10-2006, 05:58 PM
Bobo, I've read posts on the public Max webboard saying that persistent globals == bad, but I notice you're using them here. I've been using custom attributes on the root node to store persistent data because of Larry's warnings about persistent globals. Is it really not that big of an issue?

Bad is relative. Only Sith speak in absolutes. ;)
Persistent globals have issues. For example, if you start merging a file and cancel, the persistent globals from that file would overwrite your current ones.
But I have never had any specific problems dealing with them, probably because the data I store in them is not really vital. I tend to store some tool-specific data so when a tool is reopened, it can find the last settings etc. It is not a big deal if the tool would reset back to defaults, but in 99.9% of the cases it works for me.
Also, I work in a relatively closed environment and I am nearly the only full-time scripter at Frantic (with Chris Harvey jumping in when needed), so I feel I know what I am doing.

In general though, Larry is right and I am wrong. Always.

joconnell
03-10-2006, 06:03 PM
From what I understand, the really cool thing about the Disney version of this tool is that you can draw over a chain of bones and the bones will align themselves, as much as possible, to the line. So, for example, you have a spine setup with a few bones in a chain, or a some tentacles or a tail, and you draw on the viewport, the bones will rotate to match the curve. I'm guessing you'd have to draw in at least two viewports, like the front and side, to rotate the bone chain in three dimensions.

How's that for a challenge? :)

That psycho kees rijnen has done that already...

JHaywood
03-10-2006, 06:08 PM
That psycho kees rijnen has done that already...

Waaaaa????? Where's that script!? :)

joconnell
03-10-2006, 06:12 PM
It was in a thread somewhere - Drop him a quick mail. He showed a video of a tool that did that which only worked with aniamte off though I think...

PEN
03-10-2006, 08:16 PM
Bad is relative. Only Sith speak in absolutes. ;)
Persistent globals have issues. For example, if you start merging a file and cancel, the persistent globals from that file would overwrite your current ones.
But I have never had any specific problems dealing with them, probably because the data I store in them is not really vital. I tend to store some tool-specific data so when a tool is reopened, it can find the last settings etc. It is not a big deal if the tool would reset back to defaults, but in 99.9% of the cases it works for me.
Also, I work in a relatively closed environment and I am nearly the only full-time scripter at Frantic (with Chris Harvey jumping in when needed), so I feel I know what I am doing.

In general though, Larry is right and I am wrong. Always.

Just read in the help that this isn't the case in Max 8 anymore.

PEN
03-10-2006, 08:23 PM
If any one cares here is my meger attempt. Thanks for the inspiration Bobo. I always learn from you. Mine doesn't have half the features of Bobo's, but hey, I'm not Bobo. I took a different approch to the drawing so you have to go in and out of drawing mode to change colours and navigate the viewport.

http://paulneale.com/scripts/PEN_whiteBoard.zip

PEN
03-10-2006, 08:33 PM
Of course now I'm seeing some odd errors. Can some one please test this for me and tell me if they get any errors? I can draw with it but eventualy I start to get errors.

PEN
03-10-2006, 09:01 PM
Ok I have some huge problems with this. If the curser leaves the viewport while drawing it will cause a line to be drawn down to the corner of the viewport. Often it will crash Max and I just got it to restart my computer for me.

JHaywood
03-10-2006, 09:50 PM
Ok I have some huge problems with this. If the curser leaves the viewport while drawing it will cause a line to be drawn down to the corner of the viewport. Often it will crash Max and I just got it to restart my computer for me.

I actually had that same problem with Bobo's script, although I can't reproduce it now. A line was drawn straight down to where the arrow was and Max crashed.

PEN
03-10-2006, 10:19 PM
The issue that I was having was caused by lines that were to long. I have forced a break in the line now so it doesn't try and draw ones that are to long. The only place that you notice is if you draw a really long line and do an undo.

http://paulneale.com/scripts/PEN_whiteBoard.zip

Chinwagon
03-11-2006, 03:03 AM
I really like both versions and think it would be great to mix the features of the two.
On my machine, bobo's drawings don't work properly. They only draw for so long before cutting out and if I start another line, it connects to the previous on and draws these strange connecting lines between the two splines (could it be a direct3d thing?).
I do however like the fact you can put different drawings on different frames and have onion skinning.
Paul's script draws fine on my machine and lines look how they should. I also like the docking window on the side. I would however prefer to have the lines to be only on the current frame and have the other time based options bobo's script has. Also, when I click on another viewport the lines copy to that one too and to any others I make active and the only way to get rid of them is to clear the whole thing (this is true for bobo's script as well).
I'd like to option to clear only the active viewport and a redo button would also be nice. Finally, I'd also like to be able to click on the draw button again to stop drawing along with the right click cancel option.
Oh and one more thing, it'd be nice to have the lines stay where you've drawn them so they're locked to the 3d position of where they were drawn. This would be better when working with character poses.
Nice work guys.
:Ž)

Boa
03-11-2006, 07:35 AM
Bobo's script works in max7, but crashes max8 as soon as I try to place the first stroke. Is it possible to make it work in max8 too?

Andrea

JHaywood
03-11-2006, 03:38 PM
Bobo's script works in max7, but crashes max8 as soon as I try to place the first stroke. Is it possible to make it work in max8 too?

Andrea

Hmm, I was using it in 8 with no problem. I'm running Max 8 with service pack 2.

rdg
03-11-2006, 04:54 PM
Max 8 SP1 crashed using Bobo's script after a few strokes.
Will update to SP2, and try again.

Georg

Bobo
03-11-2006, 05:23 PM
Bobo's script works in max7, but crashes max8 as soon as I try to place the first stroke. Is it possible to make it work in max8 too?

Andrea

I wrote it in max8 (without any SP applied).
The main difference might be that I am running with LOTS of MAXScript Heap memory (around 128MB) instead of the default. Since my script tries to record a point 100 times /second, it might be running out of memory on typical installs. Try bumping up your memory limit in Customize>Preferences>MAXScript tab and restart Max.

Please remember the script is a proof of concept (prototype) and is full of bugs.
Anyone interested can try to use it as a starting point. I don't think I will have the time to polish it into a production tool.
I might actually go the way of bitmap painting for a change...

Boa
03-11-2006, 05:54 PM
I wrote it in max8 (without any SP applied).
The main difference might be that I am running with LOTS of MAXScript Heap memory (around 128MB) instead of the default.

yes, you're right. After rising the memory every works fine. Must have done this in my max7 install and forgot to to so for max8.
thanks a lot,
Andrea

PEN
03-11-2006, 07:12 PM
I noticed mine was chewing up memory as well and would crash if it tried to draw one line that was to long. It not automaticaly breaks the length of the line after 50 steps to get around this.

I'm going to try and add some of the features that Bobo has added as I have several ideas now about how to work all of this. Thanks Bobo for the inspiration and guildence on how to make it all work. I haven't looked at Bobo's latest version yet and I'm going to try not to. the onion skinning part is the only thing that I don't understand how to do.

I'm going to change up the way that the data is stored so that it can handle unlimited layers and frames as well.

slebed
03-11-2006, 08:25 PM
I seem to have trouble downloading Bobo's version of the script. The linmk seems to be broken. This is the link I get when I clink on it...

http://www.scriptspot.com/bobo/mxs7/PencilTool/Bobo_s


Also, since I'm on the subject, a page with Bobo's scripts for max 7 on his site doesn't seem to work either...

Looking forward to try the grease pencil script.

Dokun Oyetunde
03-11-2006, 09:47 PM
Absolutely brilliant guys.

A Grease Pencil for Max at last. Bobo's links' dead though so I couldn't download that version neither however, I have been able to get to script.com but didn't find it. Guys kindly post a link or a zip or something.

Wouldn't it be just brilliant to roughen out all those hard fought for Key Poses before the 3D model gets animated.

Kindly post a zip for Bobo's version of the Grease pencil.

Thanks

Bobo
03-11-2006, 11:34 PM
Absolutely brilliant guys.

A Grease Pencil for Max at last. Bobo's links' dead though so I couldn't download that version neither however, I have been able to get to script.com but didn't find it. Guys kindly post a link or a zip or something.

Wouldn't it be just brilliant to roughen out all those hard fought for Key Poses before the 3D model gets animated.

Kindly post a zip for Bobo's version of the Grease pencil.

Thanks

I zipped it and removed the space from the name (I assume it was causing problems in some web browsers).

http://www.scriptspot.com/bobo/mxs7/PencilTool/PencilTool.zip

I also added code to increase HeapMemory by 64MB if it is set to less than that, and reduced the recording speed to 50 samples per second instead of 100.

Bobo
03-11-2006, 11:44 PM
I seem to have trouble downloading Bobo's version of the script. The linmk seems to be broken. This is the link I get when I clink on it...

http://www.scriptspot.com/bobo/mxs7/PencilTool/Bobo_s


Also, since I'm on the subject, a page with Bobo's scripts for max 7 on his site doesn't seem to work either...

Looking forward to try the grease pencil script.

Fixed both LightTable and SpinEdge.
Thanks for letting me know...

Dokun Oyetunde
03-12-2006, 11:04 AM
Thanks Bobo for reposting the link!

How the fun begins...

Blueman
04-04-2006, 12:41 AM
I was just curious if either of these two scripts might work in Max 6? I 'm looking for this exact script that will function in Max 6. ( Yes I know its an old version but its all that I have to work with at the current time. ) Thanks guys!!

PEN
04-04-2006, 01:20 PM
I don't have Max 6 loaded any more but I think that mine will. I could be wrong, give it a try as it will not cause any problems. I don't have time to complete my final version with all the bells and whistles as I'm knee deep in production at the moment. I will post it when it is done.

danimation
04-06-2006, 05:48 PM
Hi all!!, Iīve been following this thread closely because Iīm really used to work in Maya with the grease pencil Jason created.And now Iīve been recenly hired by a studio that works only with 3dMax!.:banghead:
Iīve tested Boboīs script and I have to say that itīs a great approach, but it didnīt work, because it keeps drawing even when you use the move or rotate tools. It should have a "draw tool " button just like grease pencil had. So you could pose your character as you use the sketch as reference. Because when you close Boboīs window, the drawings dissapear.Or maybe I donīt know how to use it properly.

The other think I found odd is the decision of making darker lines as they are further from the current frame in the onion skin. It would be more easy to see if the colors get to a grey color similar to the default viewport background.

I hope the efforts continue in translating this amazing tool to 3dmax! Congratulations to those taking the challenge!! , Iīm no programmer or scripter but I admire profoundly the people who do it. Thanks!!!:bowdown:

Bobo
04-07-2006, 05:02 AM
Iīve tested Boboīs script and I have to say that itīs a great approach, but it didnīt work, because it keeps drawing even when you use the move or rotate tools. It should have a "draw tool " button just like grease pencil had. So you could pose your character as you use the sketch as reference. Because when you close Boboīs window, the drawings dissapear.Or maybe I donīt know how to use it properly.

The other think I found odd is the decision of making darker lines as they are further from the current frame in the onion skin. It would be more easy to see if the colors get to a grey color similar to the default viewport background.


I must admit I have never seen the original grease pencil implementation in Maya, I just had an hour free and used it. My tool is just a draft, cannot and should not be used in production and was written mostly because I wanted to know whether it can be written. ;)
(And there is always the inner need to show you Maya heads that MAXScript is not as limited as some of you believe ;))

Locking the drawing to a certain view would not be a problem. I might do that. Remember that my approach was very different - I was not creating anything "physical" in the scene, so the script had to run to keep the drawing "alive" in the viewport. Drawing to a bitmap or creating splines (which I have done many years ago and don't see as a challenge anymore) would be a much better idea IMHO.

Finally, I don't need this tool myself, so given my general workload, I don't expect to work much on this code in the future. I encourage anyone with the knowledge and free time to use these protorypes to develop an actual production tool!

PEN
04-07-2006, 01:25 PM
Unlike Bobo I continued work on mine and have added lots of new features like locking drawings to specific viewports and frames as well as drawing in 3D so that they are locked to the grid that you have drawn them on. It is in a working test stage but I want to change up again the way that I'm storing all the data as it was getting slow to redraw but like Bobo with my current work load it isn't going to get completed any time soon as I don't need it right now either.

I will let every one know when it is done. Now my concern is if Bobo thinks that it should be done in a different way then I might want to rethink off if this even more. Not sure that at this point that I'm going to change the way that I'm drawing though as I like the fact that the lines are not objects in the Max scene.

graeme
04-09-2006, 04:11 AM
Iīve tested Boboīs script and I have to say that itīs a great approach, but it didnīt work, because it keeps drawing even when you use the move or rotate tools. It should have a "draw tool " button just like grease pencil had. So you could pose your character as you use the sketch as reference. Because when you close Boboīs window, the drawings dissapear.Or maybe I donīt know how to use it properly.

i thought the same thing so i added a couple of buttons to help with this; draw and hide.
i'm not a programmer or scripter either so i may have made it terribly buggy. oh well it seems to work

btw trying to run the script twice at once makes it so you can't close it, so don't do it ;)

eek
04-12-2006, 02:23 AM
Maybe a make movie? option /preview- would be cool too?

Edit: sorry im stupid. Nevermind.

PEN
04-12-2006, 01:33 PM
Maybe a make movie? option /preview- would be cool too?

Edit: sorry im stupid. Nevermind.

Is Bioware working you to hard Charles?

eek
04-12-2006, 03:42 PM
Is Bioware working you to hard Charles?

Ha! Paul ive got math on the brain :)

juako
11-22-2006, 04:43 PM
hi! i just want to know if somebody had continue working on this .
I think both scripts are fine, the only thing is that its really hard to use them if they keep jumping around viewports , it would be great if somebody could work this out.

brindsley
02-12-2007, 05:46 PM
Hi guys!

As I have to switch to Max as well for my next project, I would also be more than happy to have something like the GreasePencil tool. So did anyone further develop these scripts?
I would really appreciate seeing a final version of this. Great work done up to now by the way!

CGTalk Moderation
02-12-2007, 05:46 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.