shadows in the freecad viewport
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
shadows in the freecad viewport
Proof of concept, it works!!! It's even pretty fast!
Apparently you need a good 3D hardware. It works with my nvidia chip, but not when running on the intel...
Attached is the .iv file...
Apparently you need a good 3D hardware. It works with my nvidia chip, but not when running on the intel...
Attached is the .iv file...
- Attachments
-
- shadow-test.iv
- (266.83 KiB) Downloaded 515 times
Re: shadows in the freecad viewport
Hey Yorik, that looks great. Is it easy to position the light source, or length of shadow or whatever method is used? Like can it have a variable setting? Also, if this actually easy to implement, is it the same for other features like mirror Z, mirror texture, atmosphere, and whatever other goodies there are available?
Mark
Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
Re: shadows in the freecad viewport
If you look in the .iv file you'll see how it works: You need a spotlight (IFAICS directionalLights don't work), the cutOffAngle and dropOffRate control how the shadows look like. There is more info on http://coin3d.bitbucket.org/Coin/classS ... Group.html
Implementing this FreeCAD-wide seems not specially difficult (one just needs to "encapsulate" the whole scene inside a SoShadowGroup object and add a ground plane, maybe modify the default lights too), then there could easily be some setting to switch that behaviour on/off.
About the other features, I haven't looked much yet. Fog seems easy too, same system ( http://coin3d.bitbucket.org/Coin/classS ... nment.html ), mirroring I don't remember exactly how Jürgen did it, but I think it involved copying all the scene contents... As for advanced texturing, that's a whole more complex matter, it involves implementing stuff at object level, and will ask for mch more complex controls...
Implementing this FreeCAD-wide seems not specially difficult (one just needs to "encapsulate" the whole scene inside a SoShadowGroup object and add a ground plane, maybe modify the default lights too), then there could easily be some setting to switch that behaviour on/off.
About the other features, I haven't looked much yet. Fog seems easy too, same system ( http://coin3d.bitbucket.org/Coin/classS ... nment.html ), mirroring I don't remember exactly how Jürgen did it, but I think it involved copying all the scene contents... As for advanced texturing, that's a whole more complex matter, it involves implementing stuff at object level, and will ask for mch more complex controls...
Re: shadows in the freecad viewport
Hi Yorik,
This looks really great...
What do you think about it?
Best regards: Balázs
This looks really great...
Where do you position your spotlight? From an architect point of view a SoDirectionalLight (as the model of the Sun) would be important, too. For it, a practical set of control properties would beyorik wrote:If you look in the .iv file you'll see how it works: You need a spotlight (IFAICS directionalLights don't work), the
- a north arrow
- latitude of the building (or a major city, but that may come in the future)
- month and day
- local time
What do you think about it?
Best regards: Balázs
Re: shadows in the freecad viewport
If coin3d doesn't produce shadows from directional lights, there is little we can do unfortunately. Note that blender also doesn't do that... There must be something that prevents it, most probably it is not supported by OpenGL.
But we could still find something that allows to place a light automatically at a correct sun position.
But we could still find something that allows to place a light automatically at a correct sun position.
Re: shadows in the freecad viewport
Like 1.5E14 mm from the origin?yorik wrote:But we could still find something that allows to place a light automatically at a correct sun position.
Re: shadows in the freecad viewport
Yes, something like it. A distance big enough to give a good approximate of the Sun - which itself is also far closer than infinityshoogen wrote:Like 1.5E14 mm from the origin?
Yorik, have you tried smoothBorder > 0 in SoShadowGroup?
Re: shadows in the freecad viewport
Hey, that's only about 1.58553512 × 10^-5 light years. Hummm, sounds about right.shoogen wrote:Like 1.5E14 mm from the origin?yorik wrote:But we could still find something that allows to place a light automatically at a correct sun position.
This post made with 0.0% Micro$oft products - GOT LINUX?
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: shadows in the freecad viewport
I have done some experiments with inventor/vrml-lights and the seem to work - but there is to much light by default.
Is there a way to shut off the light in the 3D scene to get a dark room?
EDIT
I have 3 spotlights to the cones, but there is still some ambient light
the spotlights still do not work as in the examples of the inventor mentor book
I cannot see the end of the light cones
Is there a way to shut off the light in the 3D scene to get a dark room?
EDIT
I have 3 spotlights to the cones, but there is still some ambient light
the spotlights still do not work as in the examples of the inventor mentor book
I cannot see the end of the light cones
- Attachments
-
- bn_553.png (66.17 KiB) Viewed 13821 times
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: shadows in the freecad viewport
some years later I found where to turn the light on and off ...microelly2 wrote: ↑Thu Mar 05, 2015 9:54 am Is there a way to shut off the light in the 3D scene to get a dark room?
Code: Select all
from pivy import coin
rGrp=FreeCAD.ParamGet('User parameter:BaseApp/Preferences/View')
atr="HeadlightIntensity"
rGrp.GetInt(atr)
#set headlight on
rGrp.SetInt(atr,100)
# or off
rGrp.SetInt(atr,0)
myCustomNode=Gui.ActiveDocument.ActiveView.getSceneGraph()
l=coin.SoSpotLight()
l.direction.setValue(coin.SbVec3f(-100,-0,-100))
l.color.setValue(coin.SbColor(1,1,0))
l.location.setValue(coin.SbVec3f(200,0,100))
l.cutOffAngle.setValue(0.3)
l.dropOffRate.setValue(0.)
myCustomNode.insertChild(l,0)
l=coin.SoSpotLight()
l.direction.setValue(coin.SbVec3f(-30,50,-100))
l.color.setValue(coin.SbColor(0,1,1))
l.location.setValue(coin.SbVec3f(200,-150,300))
l.cutOffAngle.setValue(.1)
l.dropOffRate.setValue(0.)
myCustomNode.insertChild(l,0)
l=coin.SoSpotLight()
l.direction.setValue(coin.SbVec3f(350,200,-300))
l.color.setValue(coin.SbColor(1,0,1))
l.location.setValue(coin.SbVec3f(-200,-200,300))
l.cutOffAngle.setValue(0.05)
l.dropOffRate.setValue(0.)
myCustomNode.insertChild(l,0)
rGrp=FreeCAD.ParamGet('User parameter:BaseApp/Preferences/View')
atr="HeadlightIntensity"
#set headlight on
rGrp.SetInt(atr,100)