Hello,
I would like to rotate an environment through Z-Axis in order to avoid the user having to rotate all objects, so anyone know if RhinoCommon provides any way to do that?
Thanks.
Kind regards.
Hello,
I would like to rotate an environment through Z-Axis in order to avoid the user having to rotate all objects, so anyone know if RhinoCommon provides any way to do that?
Thanks.
Kind regards.
I’m not quite sure what you mean by “environment.” Can you explain further what you are trying to do and why?
Hi Dale,
I mean reflection environment for rendering, here you are a video showing how to do it in design time, environment.mp4 (892.2 KB) but I’m not able to find the way to do that programatically.
Thanks and Regards.
Thanks Dale,
Could you show me an example in C#?
Thanks and Regards
The video shows that you actually want to rotate the local mapping of a HDR texture that happens to be attached as the child of an environment. In C++ you can do this using CRhRdkTexture::SetRotation(). To give more details would require me to know what object you already have access to (a Basic Environment?). I have no idea how you would do this in C# though.
No idea if this is the right way to do it, but it seems to work over here with the current environment:
import Rhino
def ZRotateCurrentEnvironment(deg=0.0):
tex = Rhino.Render.RenderEnvironment.CurrentEnvironment.FindChild("Texture")
context = Rhino.Render.RenderContent.ChangeContexts.UI
tex.SetRotation(Rhino.Geometry.Vector3d(0.0, 0.0, deg), context)
if __name__=="__main__":
ZRotateCurrentEnvironment(15.0)
c.
I’m not sure how null is handled here, but if ‘tex’ comes back as null because the child wasn’t found, it could crash. If it was C++ it would definitely crash without a null check.
you are right. Python just prints an error in this case. Below some Python code for completeness to handle the case when no environment texture has been assigned:
import Rhino
def ZRotateCurrentEnvironment(deg=0.0):
# get current environment
env = Rhino.Render.RenderEnvironment.CurrentEnvironment
if not env: return None
# get environment texture
tex = env.FindChild("Texture")
if not tex: return None
# rotate environment
context = Rhino.Render.RenderContent.ChangeContexts.UI
tex.SetRotation(Rhino.Geometry.Vector3d(0.0, 0.0, deg), context)
print "Current rotation = {}".format(tex.GetRotation().Z)
if __name__=="__main__":
ZRotateCurrentEnvironment(90)
c.