/// <summary> /// Constructs a light which simulates a <see cref="Rhino.Render.Sun"/>. /// </summary> /// <param name="sun">A Sun object from the Rhino.Render namespace.</param> /// <returns>A light.</returns> public static Light CreateSunLight(Rhino.Render.Sun sun) { Rhino.Runtime.HostUtils.CheckForRdk(true, true); Rhino.Geometry.Light rc = new Rhino.Geometry.Light(); IntPtr pLight = rc.NonConstPointer(); IntPtr pConstSun = sun.ConstPointer(); UnsafeNativeMethods.Rdk_Sun_Light(pConstSun, pLight); return rc; }
/// <summary> /// Constructs a light which simulates a <see cref="Rhino.Render.Sun"/>. /// </summary> /// <param name="sun">A Sun object from the Rhino.Render namespace.</param> /// <returns>A light.</returns> public static Light CreateSunLight(Rhino.Render.Sun sun) { Rhino.Runtime.HostUtils.CheckForRdk(true, true); Rhino.Geometry.Light rc = new Rhino.Geometry.Light(); IntPtr pLight = rc.NonConstPointer(); IntPtr pConstSun = sun.ConstPointer(); UnsafeNativeMethods.Rdk_Sun_Light(pConstSun, pLight); return(rc); }
/// <summary> /// Creates a default light and enables the active shader /// </summary> private void SetupShader(RhGLShaderProgram shader, RMModel model, ViewportInfo viewport) { // Check to make sure we actually have an active shader... if (shader != null) { // Enable... shader.Enable(); // Now setup and initialize frustum and lighting... int near, far; viewport.GetScreenPort(out near, out far); viewport.SetScreenPort((int)Frame.Left, (int)Frame.Right, (int)Frame.Bottom, (int)Frame.Top, near, far); shader.SetupViewport(viewport); Rhino.Geometry.Light light = CreateDefaultLight(); shader.SetupLight(light); light.Dispose(); } }
static Rhino.Geometry.Light[] GetLightsHelper(Rhino.Display.DisplayPipeline pipeline) { var method = pipeline.GetType().GetMethod("GetLights"); if (method == null) { if (_preSR3Lights == null) { // just mimic the default light var light = new Rhino.Geometry.Light(); light.LightStyle = Rhino.Geometry.LightStyle.CameraDirectional; light.Direction = new Rhino.Geometry.Vector3d(1, -1, -3); light.ShadowIntensity = 0.7; _preSR3Lights = new Rhino.Geometry.Light[] { light }; } return(_preSR3Lights); } var lights = method.Invoke(pipeline, null) as Rhino.Geometry.Light[]; return(lights); }
/// <summary> /// Creates a light that matches the style of the default openNURBS light. /// </summary> private Rhino.Geometry.Light CreateDefaultLight() { Rhino.Geometry.Light light = new Rhino.Geometry.Light(); light.IsEnabled = true; light.Intensity = 1; light.PowerWatts = 0; light.LightStyle = Rhino.Geometry.LightStyle.CameraDirectional; light.Ambient = System.Drawing.Color.FromArgb(0, 0, 0); light.Diffuse = System.Drawing.Color.FromArgb(255, 255, 255); light.Specular = System.Drawing.Color.FromArgb(255, 255, 255); light.Direction = new Rhino.Geometry.Vector3d(0.0, 0.0, 1.0); light.Location = new Rhino.Geometry.Point3d(0.0, 0.0, 0.0); light.Length = new Rhino.Geometry.Vector3d(0.0, 0.0, 0.0); light.Width = new Rhino.Geometry.Vector3d(0.0, 0.0, 0.0); light.SpotAngleRadians = 180.0; light.SpotExponent = 0.0; light.HotSpot = 1.0; light.AttenuationVector = new Rhino.Geometry.Vector3d(1.0, 0.0, 0.0); light.ShadowIntensity = 1.0; return(light); }
void Initialize() { IntPtr pSceneServer = m_pSceneServer; if (pSceneServer != IntPtr.Zero) { //Pull in the list of objects m_scene_objects = new List <SceneObject>(); UnsafeNativeMethods.Rdk_SceneServer_ResetObjectEnum(pSceneServer); IntPtr pObject = UnsafeNativeMethods.Rdk_SceneServer_NextObject(pSceneServer); while (pObject != IntPtr.Zero) { Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh(); IntPtr pMaterial = UnsafeNativeMethods.Rdk_SceneServer_ObjectDetails(pObject, mesh.NonConstPointer()); if (pMaterial != IntPtr.Zero) { SceneObject o = new SceneObject(mesh, RenderContent.FromPointer(pMaterial) as RenderMaterial); m_scene_objects.Add(o); } pObject = UnsafeNativeMethods.Rdk_SceneServer_NextObject(pSceneServer); } //Now get the lights m_scene_lights = new List <Rhino.Geometry.Light>(); UnsafeNativeMethods.Rdk_SceneServer_ResetLightEnum(pSceneServer); IntPtr pLight = UnsafeNativeMethods.Rdk_SceneServer_NextLight(pSceneServer); while (pLight != IntPtr.Zero) { Rhino.Geometry.Light light = new Rhino.Geometry.Light(); UnsafeNativeMethods.Rdk_SceneServer_LightDetails(pLight, light.NonConstPointer()); m_scene_lights.Add(light); pLight = UnsafeNativeMethods.Rdk_SceneServer_NextLight(pSceneServer); } //And then fill in the blanks IntPtr pEnvironment = UnsafeNativeMethods.Rdk_SceneServer_Environment(pSceneServer); if (pEnvironment != IntPtr.Zero) { m_environment = RenderContent.FromPointer(pEnvironment) as RenderEnvironment; } else { m_environment = null; } m_content_instance_id = UnsafeNativeMethods.Rdk_SceneServer_InstanceId(pSceneServer); m_sig = UnsafeNativeMethods.Rdk_SceneServer_Signature(pSceneServer); //Just the view left... m_viewport = new Rhino.DocObjects.ViewportInfo(); UnsafeNativeMethods.Rdk_SceneServer_View(pSceneServer, m_viewport.NonConstPointer()); } m_pSceneServer = IntPtr.Zero; }
/// <summary> /// Creates a light that matches the style of the default openNURBS light. /// </summary> private Rhino.Geometry.Light CreateDefaultLight() { Rhino.Geometry.Light light = new Rhino.Geometry.Light (); light.IsEnabled = true; light.Intensity = 1; light.PowerWatts = 0; light.LightStyle = Rhino.Geometry.LightStyle.CameraDirectional; light.Ambient = System.Drawing.Color.FromArgb(0,0,0); light.Diffuse = System.Drawing.Color.FromArgb(255, 255, 255); light.Specular = System.Drawing.Color.FromArgb(255, 255, 255); light.Direction = new Rhino.Geometry.Vector3d(0.0, 0.0, 1.0); light.Location = new Rhino.Geometry.Point3d(0.0, 0.0, 0.0); light.Length = new Rhino.Geometry.Vector3d(0.0, 0.0, 0.0); light.Width = new Rhino.Geometry.Vector3d(0.0, 0.0, 0.0); light.SpotAngleRadians = 180.0; light.SpotExponent = 0.0; light.HotSpot = 1.0; light.AttenuationVector = new Rhino.Geometry.Vector3d(1.0, 0.0, 0.0); light.SpotLightShadowIntensity = 1.0; return light; }
void Initialize() { IntPtr pSceneServer = m_pSceneServer; if (pSceneServer != IntPtr.Zero) { //Pull in the list of objects m_scene_objects = new List<SceneObject>(); UnsafeNativeMethods.Rdk_SceneServer_ResetObjectEnum(pSceneServer); IntPtr pObject = UnsafeNativeMethods.Rdk_SceneServer_NextObject(pSceneServer); while (pObject != IntPtr.Zero) { Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh(); IntPtr pMaterial = UnsafeNativeMethods.Rdk_SceneServer_ObjectDetails(pObject, mesh.NonConstPointer()); if (pMaterial != IntPtr.Zero) { SceneObject o = new SceneObject(mesh, RenderContent.FromPointer(pMaterial) as RenderMaterial); m_scene_objects.Add(o); } pObject = UnsafeNativeMethods.Rdk_SceneServer_NextObject(pSceneServer); } //Now get the lights m_scene_lights = new List<Rhino.Geometry.Light>(); UnsafeNativeMethods.Rdk_SceneServer_ResetLightEnum(pSceneServer); IntPtr pLight = UnsafeNativeMethods.Rdk_SceneServer_NextLight(pSceneServer); while (pLight != IntPtr.Zero) { Rhino.Geometry.Light light = new Rhino.Geometry.Light(); UnsafeNativeMethods.Rdk_SceneServer_LightDetails(pLight, light.NonConstPointer()); m_scene_lights.Add(light); pLight = UnsafeNativeMethods.Rdk_SceneServer_NextLight(pSceneServer); } //And then fill in the blanks IntPtr pEnvironment = UnsafeNativeMethods.Rdk_SceneServer_Environment(pSceneServer); if (pEnvironment != IntPtr.Zero) { m_environment = RenderContent.FromPointer(pEnvironment) as RenderEnvironment; } else { m_environment = null; } m_content_instance_id = UnsafeNativeMethods.Rdk_SceneServer_InstanceId(pSceneServer); m_sig = UnsafeNativeMethods.Rdk_SceneServer_Signature(pSceneServer); //Just the view left... m_viewport = new Rhino.DocObjects.ViewportInfo(); UnsafeNativeMethods.Rdk_SceneServer_View(pSceneServer, m_viewport.NonConstPointer()); } m_pSceneServer = IntPtr.Zero; }