PDA

View Full Version : How to draw @data graphics in Lightwave Python?



sami
02-03-2014, 09:30 PM
You know how LScript allows you to have @data sections where you can store graphics in the script and then draw them to the panel or to a ctlinfo control by drawing them as a glyph? Well, how do you do that in Python?

I've seen this function in the sdk docs:


blitPanel( raster, srcx, srcy, panel, dstx, dsty, w, h )


but how do you define the raster in Python, and can I use the same @data serialization of the binary graphic data that LScript uses? How do you define that in Python??

thanks :)

iain_r
02-08-2014, 02:54 PM
Hi,

I've been having a try at getting the LWRasterFuncs() to work in python. I've taken the binview as my starting point, however I'm having difficulty getting the drawRGBPixel function to return a value. I've raised this as a fogbugz as I couldn't get any pixel values returned even when setting hard values for the colours. I've attached the python script as it stands, but I'm now waiting for the developers to show me how to get the functions to work. Once I get a reply I'll post on the forum.

Regards

Iain

sami
02-08-2014, 05:13 PM
thanks very much! I'm sure you've exhausted everything, but I'll have a play with your script and see if I can use it as inspiration to fix anything, assuming python isn't hampered by bugs in this instance.

Good job fogbugzing btw, i just did one on lscript and got a good response that it will be looked at - seems a detailed fogbugz is more likely to get traction than posts in the forums. Hopefully the devs will be addressing the scripting systems for 11.6.2 or whatever release is next...

iain_r
02-11-2014, 04:13 PM
Ok, not using any 3rd party libraries or external files I've managed to get the canvas to accept the information from the various arrays. I didn't use the blitPanel or any LWRasterFuncs. I'm still waiting to hear about the fogbugz that I raised, they were getting a developer to look at it.

I had a look at the blog, justaddmilk, and I had had an idea that the panel draw functions for drawRGBPixel could be solution after looking at the SDK again for some inspiration. Just need to see how to use it.

I've got a few other images I want try myself so I'll post how I get on with them.

Regards

Iain.

sami
02-11-2014, 08:28 PM
Ok, not using any 3rd party libraries or external files I've managed to get the canvas to accept the information from the various arrays. I didn't use the blitPanel or any LWRasterFuncs. I'm still waiting to hear about the fogbugz that I raised, they were getting a developer to look at it.

I had a look at the blog, justaddmilk, and I had had an idea that the panel draw functions for drawRGBPixel could be solution after looking at the SDK again for some inspiration. Just need to see how to use it.

I've got a few other images I want try myself so I'll post how I get on with them.

Regards

Iain.

Cool thanks! I will try it out tonight. I appreciate you sharing your findings :)

EDIT: I will examine your arrays and see if I can create a version of my MultiGenDatav99 script from here http://forums.newtek.com/showthread.php?140063-New-Lightwave-python-blog&p=1367055&viewfull=1#post1367055
- that generates the Lscript includes for the graphics. But if I recall, your arrays were color pixels, while the LScript @data's were pure binary bytes of the file just serialized into text form. If, in python, I have to have an array of color pixels (i.e. a 2d array of pixels' color values) - that is essentially just a bitmap, and that means we'd need chunk/binary readers for the various TGA, PNG, etc formats to turn them into this format. The @data format that Lscript uses seems to not care as the Glyph() function is smart enough to read PNGs or JPGs or whatever without us having to translate them to pixels. That script on my post will serialize *any* binary file which could be useful for other things like audio files or whatever too...

Guess I assumed that Python would be LScript on steroids and be the superset of functionality in it, but some things definitely are missing in it so far...

iain_r
02-12-2014, 01:48 PM
Hi Sami,

I'm currently looking at some TGA and PNG converters into c header files, these can be modified to output the necessary python layout.

Regards

Iain