MoI discussion forum
MoI discussion forum

Full Version: Save image from MOI

Show messages:  1-20  21-38

From: Michael Gibson
24 Oct 2007   [#21] In reply to [#20]
Hi Pilou, that's true, the image on the screen will only change with the second parameter.

But that script isn't about changing stuff on the screen, it is about changing stuff on the image that is sent to the clipboard. You don't see that image on the screen until you paste it into an image processing program.

The idea of the script is to work like this:


Set line width to a larger number.

Call renderToClipboard() - this will do a special rendering that you don't see on the screen, but the rendering will use all the parameters that are normally set to change the appearance including the larger line width. This rendering is never displayed directly, it goes directly to a bitmap instead.

Then the second call to setting the line width restores it to its original default so that there won't be any change to the regular screen display.


So it is intended that when you run the script, you should not see any change immediately on the screen at all, that's why you want to leave the second parameter to set lineWidth back to 1.

When you change the first line width, you will be changing the appearance of the image that is on the clipboard, paste it in somewhere each time to see the different result.

I hope this clears it up!

- Michael
From: Frenchy Pilou (PILOU)
24 Oct 2007   [#22] In reply to [#21]
hehe I have now full understand
But maybe it's more practical to see the result as soon as in Moi before to past in the 2D prog ;)

another thing is that artifact normal in the 2d prog image ? corners lines are separated!
(that makes the same of course in Moi ; with the 2 parameters changed :)
here I put 64 , (image is 35 % reducted) :)

Ps and my maxi seems to be 2048 * 2048 (in Moi with the past to clipboard) with a video card with 128 megas : normal?

Attachments:
artifact1.jpg


From: Michael Gibson
24 Oct 2007   [#23] In reply to [#22]
> another thing is that artifact normal in the 2d prog image ? corners lines are separated!

Hi Pilou, this is normal at least for now - each edge of the solid is drawn as a separate line so that is the end of each line.

When you have curve segments that are joined together like with a rectangle curve, that will produce ends that are mitered, but completely separate curve objects (which is the case with edge curves like you show) do not get mitered between each other.


> Ps and my maxi seems to be 2048 * 2048 (in Moi with the past to clipboard)
> with a video card with 128 megas : normal?

Yes, this is normal, different video cards will have different limitations. Sometimes the limit is not just in memory but also just what the driver is programmed to allow.

I would generally expect cards that are newer and have more memory to allow larger sizes.

- Michael
From: Frenchy Pilou (PILOU)
24 Oct 2007   [#24] In reply to [#23]
Thx
:) my hardware is some old but works fine (for the moment) :)
From: pitrak
23 May 2009   [#25]
Just tried out this technique, it works great. I was just wondering if it's also possible to grab a screenshot without the shading, so only with the lines. That would allow for some more refined layering in PS!
thanks,
patrick
From: Michael Gibson
23 May 2009   [#26] In reply to [#25]
Hi Patrick - re: hide the shading when taking high res screenshot.

Yup - it's possible to get a wireframe-type view that you can screenshot by hiding all the face sub-objects.

That will leave only the edge-subobjects of solids or surfaces showing, giving you that wireframe type display. Then to get back to normal you show all the faces.

In v1 you can do this by a script, let me know if you need that.

In v2 it's a lot easier to do this by using the "Types" section in the Scene Browser. Go click on the eye icon for "Faces", and it will hide them all (click it again when you are done to show them again):



In the current beta, you can't select solid or surface objects if their faces are hidden, so you need to turn faces back on to being displayed before you can continue working on stuff. But this is fixed up to work better in the next v2 beta, where you can select objects even if their faces are hidden.

- Michael

Image Attachments:
scene_browser_faces.jpg 


From: pitrak
23 May 2009   [#27]
Hi Michael,
apparently I'm not the only one who doesn't get much sleep these days :)

Silly question, I still have to get used to the new functionality of the v2..

That's in fact quite a convenient basis for making non-photorealistic renders:
The only downside is that you cannot have the hidden lines separated as they disappear with the faces.

p
From: Michael Gibson
24 May 2009   [#28] In reply to [#27]
Hi Patrick,

> That's in fact quite a convenient basis for making non-photorealistic
> renders:
> The only downside is that you cannot have the hidden lines
> separated as they disappear with the faces.

Yeah at the moment to make "hidden lines" you also have to have faces showing. There is not any way to have hidden lines but also not have faces displayed with shading at the same time.

But I've now added an option in for the next v2 beta that will allow for that.

The new option will basically make it possible to get a screenshot where the shaded drawing of the faces is eliminated, but the effect of faces on generating hidden lines is retained.

However, this still has the same limitation as the previous "just hide all faces" type wireframe that silhouettes are not dealt with, so it is not a completely proper hidden line wireframe display except for things that happen to already have an edge where a silhouette is at. For example things like spheres will not look proper with this kind of wireframe display, because it only shows surface edgse and spheres only have one edge in them.

I do want to add more proper silhouette type stuff in the future but that will be a lot more work than just adding in an option.

But anyway, the new option will allow for doing screenshots like the following which may be of use:



- Michael

Image Attachments:
SemiHiddenLine.png 


From: pitrak
26 May 2009   [#29] In reply to [#28]
Michael, on pushpullbar we would say CRACQUER!

Great, thanks a lot for implementing this. I'm already looking forward to the next beta!

Thanks a lot,
patrick
From: Frenchy Pilou (PILOU)
26 May 2009   [#30] In reply to [#29]
"Craqueur" is the good Belgian / French word but it's a neologism ;)
Meaning is something like "to merit clapping for the amazing tricky work"
From: Ambimind
2 Jul 2011   [#31]
Have just realised the potential of rendering with MOI while reading this thread. While experimenting with the script I thought that it would be useful if we could also:
1 - Hide grid only in the rendering
2 - Hide hidden lines only in the rendering
3 - Change the background color only in the rendering(I'm thinking to black or green to use as an alpha channel)
4 - Enable 'constant' shading only in the rendering(that is, without shadowing) - this has the side effect of allowing accurate bitmap to vector conversion.
5 - Increase meshing resolution only in rendering
Thanks,

Ambimind
From: Michael Gibson
2 Jul 2011   [#32] In reply to [#31]
Hi Ambimind, yup I think all that should be possible - note how the script already increases the line width just for the rendering and then puts it back to normal after the snapshot is taken - that's the part of the script that says moi.view.lineWidth = 4; and moi.view.lineWidth = 1;


The grid is made up of 2 parts - the regular grid lines and the darker xy axis lines.

To hide the grid would use this script:

moi.grid.display = false; moi.grid.showXYAxes = false;

and to restore it, say = true instead of = false. These would go sandwiched around the call that does the snapshot just like setting the line width currently.


Hidden line display is controlled in script by:

moi.view.showHiddenLines = true;


Setting the background color is controlled by the moi.view.viewportBackgroundColor property, which takes a 24-bit number made up of 3 bytes packed together, the 3 bytes contain the red, green, and blue values. So something like this should work to set it to red = 25, green = 51, blue = 255:

moi.view.viewportBackgroundColor = (25 << 16) | (51 << 8) | 255;


Constant shading can be done by setting high value for light intensities of the custom light levels under Lighting options, see here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=3135.3

To set the lighting style in script, you can use:

moi.view.lightingStyle = 'CustomLevels';

and to restore to default:

moi.view.lightingStyle = 'Default';

You can use the following values for lightingStyle: 'Default', 'MoreFill', 'LessFill', 'KeyOnly', 'CustomLevels', 'Hemispheric', and 'Headlight' - each of these corresponds to an entry in the dropdown that you see in the lighting options dialog.

Then for custom levels to set the levels to a high value, use:

moi.view.customKeyLightLevel = 100.0;
moi.view.customFillLightLevel = 100.0;


You may run into some problems increasing meshing resolution, because that can consume quite a large amount of memory setting that to a tighter value. If you do want to try it, it's settable from script by:

moi.view.meshAngle = 10.0;


So anyway these are the various script calls that you can use to adjust the settings you are asking about - to assemble the script you build it up as one long line of text and put one setting to the left side of the snapshot and the restoring part to the right side of the snapshot.


Let me know if any of these doesn't work as expected.

- Michael
From: Ambimind
2 Jul 2011   [#33] In reply to [#32]
Fantastic, thank you!

For anyone else interested, here is the script that produces the type of rendering visible in the following image:

script:var v = moi.ui.getActiveViewport(); if ( v != null ) { moi.view.lineWidth = 3; moi.grid.display = false; moi.view.meshAngle = 5.0; moi.grid.showXYAxes = false; moi.view.showHiddenLines = false; moi.view.lightingStyle = 'CustomLevels'; moi.view.customKeyLightLevel = 100.0; moi.view.customFillLightLevel = 100.0; v.renderToClipboard(2048, 2048 ); moi.view.lineWidth = 1; moi.grid.display = true; moi.view.meshAngle = 10.0; moi.view.lightingStyle = 'Default'; moi.grid.showXYAxes = true; moi.view.showHiddenLines = true; }


BTW, I found that the default grey background works perfectly when using "Magic Wand" with a 1px tolerance - so as to mask the background(image below is .png so as to show this):


Image Attachments:
Boat.png 


From: BurrMan
3 Jul 2011   [#34] In reply to [#33]
Very nice Ambimind, Me likey!! Thanks for sharing it.
From: rosto
26 Jun 2022   [#35] In reply to [#20]
This is a wonderful thing - changing the line thickness!
Is there a solution to change the line tips to rounded like in Illustrator?
What would not appear gaps at the corners.

Image Attachments:
linetips.png 


From: Michael Gibson
26 Jun 2022   [#36] In reply to [#35]
Hi rosto,

re:
> Is there a solution to change the line tips to rounded like in Illustrator?

Not with this particular method since it's using the realtime viewport display engine which is heavily oriented for speed.

But you should get rounded line tips if you generate a drawing by exporting to PDF, AI, or SVG formats instead of using this screen display capture method.

- Michael
From: Rudl
26 Jun 2022   [#37]
This is a screenshot of a pyramid with a lot of stones. Can I avoid the interferences with a pdf and how are the settings.

Image Attachments:
1102.jpg 


From: Michael Gibson
26 Jun 2022   [#38] In reply to [#37]
Hi Rudl, I'm not sure if PDF export will have less of a Moiré pattern but it would be worth a try. Give it a try with default settings.

You may need to adjust the image in an image processing program to reduce that kind of pattern, search for something like "Moire pattern removal" to get some information on that.

- Michael

Show messages:  1-20  21-38