is that available in coin? maybe we can add some bindings with pivy.
FYI, with pivy you can create an instance of any SoBase-derived class as soon as it's registered to the type system. So, when pivy doesn't offer a direct way to create an instance you always can go this way:
from pivy import coin
coin.SoShadowStyle() # => AttributeError: 'module' object has no attribute 'SoShadowStyle'
sotype=coin.SoType.fromName("SoShadowStyle")
sotype.isBad() # => 0, i.e. is OK
inst=sotype.createInstance()
inst.getTypeId().getName() # => ShadowStyle
wmayer wrote: ↑Tue Jan 09, 2018 10:51 am
FYI, with pivy you can create an instance of any SoBase-derived class as soon as it's registered to the type system
I would really like to have that as a builtin viewing mode in FreeCAD at some point... We might try to implement that after 0.17, no?
The way I see it:
- The whole scenegraph must be embedded inside a SoShadowGroup node
- A SoSpotLight must be added in order to produce shadows. The difficulty is to correctly position that light IRW the objects in the scene.
- There must be some control over that spotlight + the default light in FreeCAD (a UI to specify light position/color/intensity?)
Maybe, simply, the spotlight should be a document object, that the user can position/configure manually...
Maybe also:
- A UI to control shadow quality (maybe just a simple pref setting)
- Shadows can be switched on/off inside the SoShadowGroup. So maybe add a property to each document object?
yorik wrote: ↑Wed Jan 10, 2018 11:25 am
I would really like to have that as a builtin viewing mode in FreeCAD at some point... We might try to implement that after 0.17, no?
The way I see it:
- The whole scenegraph must be embedded inside a SoShadowGroup node
- A SoSpotLight must be added in order to produce shadows. The difficulty is to correctly position that light IRW the objects in the scene.
- There must be some control over that spotlight + the default light in FreeCAD (a UI to specify light position/color/intensity?)
Maybe, simply, the spotlight should be a document object, that the user can position/configure manually...
Maybe also:
- A UI to control shadow quality (maybe just a simple pref setting)
- Shadows can be switched on/off inside the SoShadowGroup. So maybe add a property to each document object?
I start to put these nodes into my darkroom view.
My idea is to have the soNodes as parametric objects in the document and compose them in a darkroom view.
on this way other nodes like vrml helper illustrations as trees and people sholuld be possible too.
Now when the use of lights and shadows is known a new game can start.
Today I tested whether it is possible to add pure inventor file with animation inside can be added.
And it works too.
The animation runs in FreeCAD without extra code
and it runs in the darkroom with shadows.
So we can add extra objects for illustration purposes.
the data file
import OfflineRenderingUtils
objs = [o for o in FreeCAD.ActiveDocument.Objects if o.ViewObject.Visibility == True] # gather visible objects
cam = FreeCADGui.ActiveDocument.ActiveView.getCamera() # gather the camera position
s = OfflineRenderingUtils.buildScene(objs) # build the coin scene
rn = OfflineRenderingUtils.embedLight(s,(1,1,-1)) # embed the wholescene in a ShadowGroup, add directional light
light = rn.getChild(0) # get a ref to the directional light for later
v = FreeCADGui.createViewer() # create an empty 3D view in FreeCAD
v.setCamera(cam) # set the camera
vv = v.getViewer().setSceneGraph(rn) # set our scene as its scenegraph
light.direction = (-1,-1,-1) # change light direction
Are them real time shadows?
Could you explain how to proceed in order to try it out? if I put the code in the Python console it doesn't work (it launches some errors)