Solved

Export 2D raster of 3D view


Badge +21

I have some different 3D-models in different formats. I want to batch create a 2D image without opening them with FME Data Inspector or another tool - take a screenshot and save as image.

Are there any way to do this?

Ie - do you know of any open source or other tools that can take as an input an inputfile (vector / 3D) - a viewpoint and write that as a raster?

icon

Best answer by lenaatsafe 31 October 2017, 00:57

View original

15 replies

Badge
So by saying you "want to batch create a 2D image", you basically mean you want to create a realistic looking 3D render and save/export that render as a JPG, for example?

 

I don't think FME will be very helpful here... you might want to take a look at Blender or some other 3D software (Rhino, Max, Maya etc. etc.), but at least Blender is free. @owen has a lot of experience with that, so he might be able to provide you some batch rendering/processing tips? However, depending on the amount of models you have, processing them might take a while! :)
Badge +1
Yes, tricky to do in FME. @LenaAtSafe was experimenting with doing this sort of thing with Blender and the PythonCaller. Otherwise if you know python you can script things within Blender

 

Userlevel 4
Badge +25
I was thinking about this recently. I thought with Dmitri's work on videos, I could take a series of snapshots of a 3D model and then animate it (sort of like the Game of Thrones introduction)!

 

Sadly, I can't think of any way to do this, at least not in FME. Feel free to add it as an idea though - I would certainly vote for it.

 

Userlevel 4
Badge +25
I was thinking about this recently. I thought with Dmitri's work on videos, I could take a series of snapshots of a 3D model and then animate it (sort of like the Game of Thrones introduction)!

 

Sadly, I can't think of any way to do this, at least not in FME. Feel free to add it as an idea though - I would certainly vote for it.

 

Having said that, you could always try rotating the model to the viewpoint you want with the 3DRotator transformer and writing it with the PNG Rasterizer writer. Would be a lot of effort to calculate the rotation I suspect, and even more if you wanted to apply it a number of times.

 

Badge
Having said that, you could always try rotating the model to the viewpoint you want with the 3DRotator transformer and writing it with the PNG Rasterizer writer. Would be a lot of effort to calculate the rotation I suspect, and even more if you wanted to apply it a number of times.

 

Hmm interesting, but would that look any good? I guess that it doesn't use a shader, so I assume the result will look very flat?

 

 

Userlevel 4
Badge +25
Hmm interesting, but would that look any good? I guess that it doesn't use a shader, so I assume the result will look very flat?

 

 

Yes, I think the rotation will be OK, but it depends on the writer - for example will it apply the appearances as well (it might not). So not a likely solution, but it's all I could think of, for pure FME anyway.

 

Badge +1
I attempted something similar with this map. https://owenpowell.files.wordpress.com/2015/07/1-toronto_sw-001.jpg

 

It involved deaggregating 3d objects to individual faces, calculating the angle and shading them differently based on that. Convoulted to say the least!

 

 

Badge +4
We have had a lot of fun generating animations by using the PointcloudCombiner to create pointclouds and then rotating them. After that making rasters with the ImageRasterizer. Works suprisingly well if you have the patience. In no remote way Blender or Owen quality but fun :-) (This idea came up a couple of years ago to produce those hyped pyramid hologram movies with FME by then calling ffmpeg).

 

 

pc-animation.fmwt - a simple example.

 

 

Userlevel 4
Badge +25
We have had a lot of fun generating animations by using the PointcloudCombiner to create pointclouds and then rotating them. After that making rasters with the ImageRasterizer. Works suprisingly well if you have the patience. In no remote way Blender or Owen quality but fun :-) (This idea came up a couple of years ago to produce those hyped pyramid hologram movies with FME by then calling ffmpeg).

 

 

pc-animation.fmwt - a simple example.

 

 

Ha! I had no idea the ImageRasterizer has a group-by setting. That's interesting. I will have to remember that.

 

Userlevel 3
Badge +13

So @LenaAtSafe did some work on this a while back and built some prototype custom xformers for driving Blender from within FME to do exactly what you want.

I'll ask Lena to be in touch and perhaps share those xformers in some way. We are planning to refine them with time but it might be good to get them out there for experimentation and feedback.

Below was an example workspace Lena had created:

And it produced this output from the original 3D OBJ file:

Badge

Hi @sigtill

I have uploaded custom transformer prototypes @daleatsafe mentioned in his comment to the HUB.

The transformers are in prototype stage (e.g. some parameters are hardcoded, GUI is not user friendly, the transformers themselves are... needy). Our goal was to assess whether we can do something with Blender - I am confident now: we can do good stuff with Blender. We will have these transformers (and a few more) implemented eventually. For now, you might be able to use some ideas we experimented with to automate your 3D models to 2D rasters workflow.

Let me provide you with a general overview of the workflow:

  • a 3D model is read or created during the translation;
  • one or several points are added that are converted into Blender lamps with BlenderLampStyler;
  • another point is added and converted into Blender camera with BlenderCameraStyler;
  • the whole model together with lamps and camera is written into a temporary blend-file with BlenderBlendCreator;
  • which is then rendered into JPG with BlenderRenderer.

You can download prototypeBlenderLampStyler and prototypeBlenderCameraStyler custom transformers from the HUB now. prototypeBlenderBlendCreator and prototypeBlendRenderer are uploaded as templates as they require external Python scripts - you can download them as well but will also need to open the templates and save them to get access to fmx- and py-files.

Please let me know if you have any questions. We can discuss your workflow/task further - I would be happy to brainstorm a Blender-based solution.

Badge

Hi @sigtill

I have uploaded custom transformer prototypes @daleatsafe mentioned in his comment to the HUB.

The transformers are in prototype stage (e.g. some parameters are hardcoded, GUI is not user friendly, the transformers themselves are... needy). Our goal was to assess whether we can do something with Blender - I am confident now: we can do good stuff with Blender. We will have these transformers (and a few more) implemented eventually. For now, you might be able to use some ideas we experimented with to automate your 3D models to 2D rasters workflow.

Let me provide you with a general overview of the workflow:

  • a 3D model is read or created during the translation;
  • one or several points are added that are converted into Blender lamps with BlenderLampStyler;
  • another point is added and converted into Blender camera with BlenderCameraStyler;
  • the whole model together with lamps and camera is written into a temporary blend-file with BlenderBlendCreator;
  • which is then rendered into JPG with BlenderRenderer.

You can download prototypeBlenderLampStyler and prototypeBlenderCameraStyler custom transformers from the HUB now. prototypeBlenderBlendCreator and prototypeBlendRenderer are uploaded as templates as they require external Python scripts - you can download them as well but will also need to open the templates and save them to get access to fmx- and py-files.

Please let me know if you have any questions. We can discuss your workflow/task further - I would be happy to brainstorm a Blender-based solution.

Great work, Lena! I was already hoping someone built some custom transformers to interact with Blender ;)

 

Badge +21

Hi @sigtill

I have uploaded custom transformer prototypes @daleatsafe mentioned in his comment to the HUB.

The transformers are in prototype stage (e.g. some parameters are hardcoded, GUI is not user friendly, the transformers themselves are... needy). Our goal was to assess whether we can do something with Blender - I am confident now: we can do good stuff with Blender. We will have these transformers (and a few more) implemented eventually. For now, you might be able to use some ideas we experimented with to automate your 3D models to 2D rasters workflow.

Let me provide you with a general overview of the workflow:

  • a 3D model is read or created during the translation;
  • one or several points are added that are converted into Blender lamps with BlenderLampStyler;
  • another point is added and converted into Blender camera with BlenderCameraStyler;
  • the whole model together with lamps and camera is written into a temporary blend-file with BlenderBlendCreator;
  • which is then rendered into JPG with BlenderRenderer.

You can download prototypeBlenderLampStyler and prototypeBlenderCameraStyler custom transformers from the HUB now. prototypeBlenderBlendCreator and prototypeBlendRenderer are uploaded as templates as they require external Python scripts - you can download them as well but will also need to open the templates and save them to get access to fmx- and py-files.

Please let me know if you have any questions. We can discuss your workflow/task further - I would be happy to brainstorm a Blender-based solution.

This is really great! I will post some screenshots of it ASAP when I get some spare time to play with it

 

 

Badge

Hi @sigtill

I have uploaded custom transformer prototypes @daleatsafe mentioned in his comment to the HUB.

The transformers are in prototype stage (e.g. some parameters are hardcoded, GUI is not user friendly, the transformers themselves are... needy). Our goal was to assess whether we can do something with Blender - I am confident now: we can do good stuff with Blender. We will have these transformers (and a few more) implemented eventually. For now, you might be able to use some ideas we experimented with to automate your 3D models to 2D rasters workflow.

Let me provide you with a general overview of the workflow:

  • a 3D model is read or created during the translation;
  • one or several points are added that are converted into Blender lamps with BlenderLampStyler;
  • another point is added and converted into Blender camera with BlenderCameraStyler;
  • the whole model together with lamps and camera is written into a temporary blend-file with BlenderBlendCreator;
  • which is then rendered into JPG with BlenderRenderer.

You can download prototypeBlenderLampStyler and prototypeBlenderCameraStyler custom transformers from the HUB now. prototypeBlenderBlendCreator and prototypeBlendRenderer are uploaded as templates as they require external Python scripts - you can download them as well but will also need to open the templates and save them to get access to fmx- and py-files.

Please let me know if you have any questions. We can discuss your workflow/task further - I would be happy to brainstorm a Blender-based solution.

Hi @LenaAtSafe

Where can I find py-files you mentioned at Hub site https://hub.safe.com/templates/prototypeblenderblendcreator:

  • styleCamera.py
  • addLamp.py
  • import3ds.py
  • importObj.py
  • importSvg.py ?
Badge

Hi @LenaAtSafe

Where can I find py-files you mentioned at Hub site https://hub.safe.com/templates/prototypeblenderblendcreator:

  • styleCamera.py
  • addLamp.py
  • import3ds.py
  • importObj.py
  • importSvg.py ?

Hi @arekpierchala

please download the template from the HUB, open it as a workspace with Workbench, and save it. As you save, Workbench will create a copy of the workspace as well as pythonScripts folder with all the source Python scripts.

I noticed that there is no importSvg.py... not sure why (maybe I simply forgot to include it or decided not to include it but forgot to remove from the description). Please let me know if you would like to see that script - I should be able to find it.

As this was a prototype, the scripts are not fully user-friendly and robust. They will give you an idea how to approach the task though. I'll be happy to try to answer your questions if you come up with any.

Reply