BabylonExporter.ShadowGenerator.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. using BabylonExport.Entities;
  3. using MaxSharp;
  4. namespace Max2Babylon
  5. {
  6. partial class BabylonExporter
  7. {
  8. private BabylonShadowGenerator ExportShadowGenerator(Node lightNode, BabylonScene babylonScene)
  9. {
  10. var maxLight = (lightNode.Object as Light);
  11. var babylonShadowGenerator = new BabylonShadowGenerator();
  12. RaiseMessage("Exporting shadow map", true, false, true);
  13. babylonShadowGenerator.lightId = lightNode.GetGuid().ToString();
  14. babylonShadowGenerator.mapSize = maxLight.GetMapSize(0, Interval.Forever);
  15. var maxScene = Kernel.Scene;
  16. var list = new List<string>();
  17. var inclusion = maxLight._Light.ExclList.TestFlag(1); //NT_INCLUDE
  18. var checkExclusionList = maxLight._Light.ExclList.TestFlag(4); //NT_AFFECT_SHADOWCAST
  19. foreach (var meshNode in maxScene.NodesListBySuperClass(SuperClassID.GeometricObject))
  20. {
  21. if (meshNode._Node.CastShadows == 1)
  22. {
  23. var inList = maxLight._Light.ExclList.FindNode(meshNode._Node) != -1;
  24. if (!checkExclusionList || (inList && inclusion) || (!inList && !inclusion))
  25. {
  26. list.Add(meshNode.GetGuid().ToString());
  27. }
  28. }
  29. }
  30. babylonShadowGenerator.renderList = list.ToArray();
  31. babylonScene.ShadowGeneratorsList.Add(babylonShadowGenerator);
  32. return babylonShadowGenerator;
  33. }
  34. }
  35. }