BabylonExporter.ShadowGenerator.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections.Generic;
  2. using Autodesk.Max;
  3. using BabylonExport.Entities;
  4. namespace Max2Babylon
  5. {
  6. partial class BabylonExporter
  7. {
  8. private BabylonShadowGenerator ExportShadowGenerator(IINode lightNode, BabylonScene babylonScene)
  9. {
  10. var maxLight = (lightNode.ObjectRef as ILightObject);
  11. var babylonShadowGenerator = new BabylonShadowGenerator();
  12. RaiseMessage("Exporting shadow map", 2);
  13. babylonShadowGenerator.lightId = lightNode.GetGuid().ToString();
  14. babylonShadowGenerator.mapSize = maxLight.GetMapSize(0, Tools.Forever);
  15. var list = new List<string>();
  16. var inclusion = maxLight.ExclList.TestFlag(1); //NT_INCLUDE
  17. var checkExclusionList = maxLight.ExclList.TestFlag(4); //NT_AFFECT_SHADOWCAST
  18. foreach (var meshNode in Loader.Core.RootNode.NodesListBySuperClass(SClass_ID.Geomobject))
  19. {
  20. if (meshNode.CastShadows == 1)
  21. {
  22. var inList = maxLight.ExclList.FindNode(meshNode) != -1;
  23. if (!checkExclusionList || (inList && inclusion) || (!inList && !inclusion))
  24. {
  25. list.Add(meshNode.GetGuid().ToString());
  26. }
  27. }
  28. }
  29. babylonShadowGenerator.renderList = list.ToArray();
  30. babylonScene.ShadowGeneratorsList.Add(babylonShadowGenerator);
  31. return babylonShadowGenerator;
  32. }
  33. }
  34. }