Example #1
0
 /// <summary>
 /// Creates a empty GraphDocument with no layers and a standard size of A4 landscape.
 /// </summary>
 public GraphDocument()
 {
     _camera   = new Camera.OrthographicCamera();
     _lighting = new LightSettings();
     RootLayer = new HostLayer()
     {
         ParentObject = this
     };
     RootLayer.Location = new ItemLocationDirect
     {
         SizeX = RADouble.NewAbs(DefaultRootLayerSizeX),
         SizeY = RADouble.NewAbs(DefaultRootLayerSizeY),
         SizeZ = RADouble.NewAbs(DefaultRootLayerSizeZ)
     };
 }
Example #2
0
		public void SetLighting(LightSettings lightSettings)
		{
			if (null == lightSettings)
				throw new ArgumentNullException(nameof(lightSettings));

			_lightSettings = lightSettings;
		}
Example #3
0
 public void SetCamera(Altaxo.Graph.Graph3D.Camera.CameraBase camera, Altaxo.Graph.Graph3D.LightSettings lightSettings)
 {
     _scene.SetCamera(camera);
     _scene.SetLighting(lightSettings);
 }
Example #4
0
			public void SetLighting(LightSettings lightSettings, CameraBase camera)
			{
				Matrix4x3 cameraM = Matrix4x3.Identity;
				if (lightSettings.IsAnyLightAffixedToCamera)
				{
					// if a light is affixed to the camera, its position is considered to be in camera coordinates
					// but here we need the light in world coordinates
					// cameraM transforms from camera coordinates to world coordinates
					cameraM = camera.InverseLookAtRHMatrix;
				}

				// first ambient light
				var al = lightSettings.AmbientLight;
				SetAmbientLight(al.ColorBelow.Color, al.ColorAbove.Color, al.LightAmplitude, al.IsAffixedToCamera ? cameraM.Transform(al.DirectionBelowToAbove) : al.DirectionBelowToAbove);

				for (int idx = 0; idx < 4; ++idx)
				{
					var l = lightSettings.GetDiscreteLight(idx);
					if (null == l)
					{
						ClearSingleLight(idx);
					}
					else if (l is DirectionalLight)
					{
						var dl = (DirectionalLight)l;
						SetDirectionalLight(
							idx,
							dl.Color.Color,
							dl.LightAmplitude,
							dl.IsAffixedToCamera ? cameraM.Transform(dl.DirectionToLight) : dl.DirectionToLight
							);
					}
					else if (l is PointLight)
					{
						var pl = (PointLight)l;
						SetPointLight(
							idx,
							pl.Color.Color,
							pl.LightAmplitude,
							pl.IsAffixedToCamera ? cameraM.Transform(pl.Position) : pl.Position,
							pl.Range
							);
					}
					else if (l is SpotLight)
					{
						var sl = (SpotLight)l;

						// calculation of SpotCosInnerConeRcp: it is in reality not 1/CosInnerConeAngle, but it is  1/(Cos(InnerConeAngle) - Cos(OuterConeAngle))
						double diffCos = Math.Cos(sl.InnerConeAngle) - Math.Cos(sl.OuterConeAngle);
						double SpotCosInnerConeRcp = diffCos >= 1E-18 ? 1 / diffCos : 1E18;

						SetSpotLight(
							idx,
							sl.Color.Color,
							sl.LightAmplitude,
							sl.IsAffixedToCamera ? cameraM.Transform(sl.Position) : sl.Position,
							sl.IsAffixedToCamera ? cameraM.Transform(sl.DirectionToLight) : sl.DirectionToLight,
							sl.Range,
							Math.Cos(sl.OuterConeAngle),
							SpotCosInnerConeRcp
							);
					}
					else
					{
						throw new NotImplementedException(string.Format("The type of lighting ({0}) is not implemented here."));
					}
				}

				AssembleLights();
			}