Posted: Thu May 31, 2012 12:05 pm
Joined: 27 Mar 2012
Posts: 19
| gl1w07 wrote: |
Hi Reynolds,
Many thanks for posting the code.
That's very generous of you.
G
|
No problem, I'm just trying to give back to the community. blender is such a great tool, so I really like to contribute a tiny bit.
I'm currently working on having multiple cameras in the scene, so I can shoot from different directions / angles in one run.
In addition, I'd really like to rewrite the script for cycles, but can't seem to find a good reference / starting point to do it.
So if there's anybody out there who would want to clean up my code, add functionality or take a look at the cycles portation, please feel free to do so, but please post back and share!
Thanks and all the best
Reynolds
Posted: Thu May 31, 2012 3:51 pm
Joined: 10 May 2012
Posts: 4
Hi Reynolds,
thanks much for posting your code!
Nice turbulence in your movie
Best regards,
Klaus
Posted: Thu May 31, 2012 4:32 pm
Joined: 27 Mar 2012
Posts: 19
| Klaus@RZG wrote: |
Hi Reynolds,
thanks much for posting your code!
Nice turbulence in your movie
Best regards,
Klaus |
Thanks a lot Klaus, the resolution is still way to low to fully resolve the turbulence, but its a start. Hopefully I'll get a fully resolved version with some nice blender shaders and fancy lighting soon
Posted: Thu May 31, 2012 4:33 pm
Joined: 27 Mar 2012
Posts: 19
| Reynolds wrote: |
| Klaus@RZG wrote: | Hi Reynolds,
thanks much for posting your code!
Nice turbulence in your movie
Best regards,
Klaus |
Thanks a lot Klaus, the resolution is still way to low to fully resolve the turbulence, but its a start. Hopefully I'll get a fully resolved version with some nice blender shaders and fancy lighting soon  |
BTW: does the G stand for Garching?
Posted: Thu May 31, 2012 4:44 pm
Joined: 10 May 2012
Posts: 4
| Reynolds wrote: |
| BTW: does the G stand for Garching? |
Yep. Are we neighbours?
Posted: Thu May 31, 2012 4:49 pm
Joined: 27 Mar 2012
Posts: 19
| Klaus@RZG wrote: |
| Reynolds wrote: | | BTW: does the G stand for Garching? |
Yep. Are we neighbours? |
Well, on a european scale certainly. Just up the A8 for about 200km, then Ausfahrt Uni Stuttgart
Viele Grüße!
Posted: Sat Aug 04, 2012 6:40 pm
Joined: 27 Mar 2012
Posts: 19
Has anybody ever added to my work? Done anything useful with it?
Posted: Mon Sep 03, 2012 9:02 pm
Joined: 27 Aug 2012
Posts: 4
| Reynolds wrote: |
| Has anybody ever added to my work? Done anything useful with it? |
I've just made your code a little cleaner. Now I am trying to set a multi-camera. Do you have any idea how to use cycle? It seems that the "Vertex color paint" option is only available in Blender engine. I think we should find a way to copy the texture in Blender mode and use it in a material in cycle mode.
| Code: |
import bpy
#---------------------------------Definitions---------------------------------------#
path_tox3d='C:/Users/*****/Desktop/Test_blend/'
path_toimage='C:/Users/*****/Desktop/Test_blend/'
filename_ofx3d='file_'
filename_ofimage='newimage_'
startframe_ofx3d=0
endframe_ofx3d=5
#-----------------------------------------------------------------------------------#
bpy.ops.object.add()
bpy.data.objects['Empty'].select=True
bpy.data.objects['Empty'].name="Aux_Empty"
bpy.context.active_object.location =(0.0, 0.0, 0.0)
bpy.data.objects['Aux_Empty'].select=False
for currentframe in range(startframe_ofx3d,(endframe_ofx3d+1)):
bpy.context.scene.frame_set(currentframe)
bpy.data.objects['Aux_Empty'].select=True
bpy.context.scene.objects.active = bpy.data.objects['Aux_Empty']
obj = bpy.context.object
obj.location[2] = 0.0
obj.keyframe_insert(data_path='location')
bpy.data.objects['Aux_Empty'].select=False
#---------------------------Import the x3d file--------------------------------#
bpy.ops.import_scene.x3d(filepath=path_tox3d+filename_ofx3d+str(currentframe)+'.x3d', filter_glob="*.x3d;*.wrl", axis_forward='Z', axis_up='Y')
#-------------------------------------------------------------------------------#
#------------rename the geometry to "imported geometry"----------------#
#--Change the "ShapeIndexedFaceSet.002" according to your geometry--#
bpy.data.objects['ShapeIndexedFaceSet.002'].name="imported_geometry"
bpy.data.objects['imported_geometry'].select=True
bpy.context.scene.objects.active = bpy.data.objects['imported_geometry']
bpy.context.active_object.material_slots[0].material.use_vertex_color_paint=True
bpy.data.objects['imported_geometry'].select=False
#Delete all of the imported objects except for the"imported_geometry"----#
bpy.ops.object.delete()
#-----------------------Set the rendering options-----------------------------#
bpy.data.scenes['Scene'].render.resolution_percentage=100
bpy.ops.render.render(write_still=True)
bpy.data.images['Render Result'].file_format='PNG'
bpy.data.images['Render Result'].save_render(filepath=path_toimage+filename_ofimage+str(currentframe)+'.png')
bpy.data.objects['imported_geometry'].select=True
bpy.ops.object.delete()
#--------------------------------End of the loop------------------------------#
bpy.data.objects['Aux_Empty'].select=True
bpy.ops.object.delete()
|
Posted: Sun Sep 09, 2012 1:45 pm
Joined: 27 Aug 2012
Posts: 4
Finally found a way to use Cycle engine
The easy way:
1. Create a material in your scene while Cycle is selected as the render engine
2. Add an 'Attribute' node to color of Diffuse BSDF as shown in the picture.
Change the name to Col or whatever appears in 'Vertex Color' under Object data.
3. Add the following command in your code to change the material for all of the objects with vertex color to the newly created material:
| Code: |
| bpy.context.active_base.object.active_material= bpy.data.materials['Cycle_Mat'] |
Now your objects are rendered based on their color map that were exported with.
Complete way!
If you want to have more control over changing materials and manipulating nodes the following code fits you! It does what explained above but in python :
| Code: |
bpy.context.active_object.material_slots['Mat_name'].material.node_tree.nodes.new('ATTRIBUTE')
Att = bpy.context.active_object.material_slots['Mat_name'].material.node_tree.nodes['Attribute']
Diff = bpy.context.active_object.material_slots['Mat_name'].material.node_tree.nodes['Diffuse BSDF']
bpy.data.objects['Obj_name'].material_slots['Mat_name'].material.node_tree.nodes['Attribute'].attribute_name='Col'
bpy.context.active_object.material_slots['Mat_name'].material.node_tree.links.new(Att.outputs[0],Diff.inputs[0]) |
Enjoy the full power of Blender for post-processing !!
Posted: Thu Dec 20, 2012 8:00 am
Joined: 20 Dec 2012
Posts: 4
Hi guys,
I encounter pretty much the same situation described here. I've a time varying file in paraview that i would put into Blender to work on the rendering. So I export the different x3d files, I do my stuff as explained here.
Though, I was wondering: is there a way to interpolate between each time steps in Blender in order to get something smoother ? I don't really want to write something myself which is gonna create temp files with the interpolated values, it's gonna be extremely time consuming as I work with meshes with several million nodes...
So simple question: can Blender do that? if yes, how?
Posted: Thu Dec 20, 2012 9:59 am
Joined: 27 Aug 2012
Posts: 4
| werty_TSS wrote: |
Hi guys,
I encounter pretty much the same situation described here. I've a time varying file in paraview that i would put into Blender to work on the rendering. So I export the different x3d files, I do my stuff as explained here.
Though, I was wondering: is there a way to interpolate between each time steps in Blender in order to get something smoother ? I don't really want to write something myself which is gonna create temp files with the interpolated values, it's gonna be extremely time consuming as I work with meshes with several million nodes...
So simple question: can Blender do that? if yes, how? |
Well, Let's say you have your CFD results in Paraview and you import them into Blender. Now are you expecting Blender to interpolate you CFD data?!! I don't think it would be possible. Try increasing your time steps when obtaining results in your solver and your results should be smoother (Very obvious of course!
)
Posted: Thu Dec 20, 2012 10:04 am
Joined: 20 Dec 2012
Posts: 4
| SH_P wrote: |
Well, Let's say you have your CFD results in Paraview and you import them into Blender. Now are you expecting Blender to interpolate you CFD data?!! I don't think it would be possible. Try increasing your time steps when obtaining results in your solver and your results should be smoother (Very obvious of course! ) |
Yes, well that's what I'm trying to avoid.. I export x3d files from paraview, they just give RGB values to each nodes of my mesh. So I hoped Blender could interpolate between those RGB values for the different time steps, which is different than changing the timestep in my numerical scheme when I solve the equations at the beginning.
Posted: Thu Dec 20, 2012 10:12 am
Joined: 27 Aug 2012
Posts: 4
So your geometry is the same in every time-steps. You should alter the code in a way to change the color map instead of changing the whole geometry. This way you may be able to find a
function with the out put of RGB values at each node in your geometry. If there exists such a function, it would be straightforward to interpolate the values.
Look under the material and texture section of Python guide to see if there is function suitable for you...