BabylonExporter.GLTFExporter.Light.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using BabylonExport.Entities;
  2. using GLTFExport.Entities;
  3. namespace Max2Babylon
  4. {
  5. partial class BabylonExporter
  6. {
  7. private GLTFNode ExportLight(BabylonLight babylonLight, GLTF gltf, GLTFNode gltfParentNode)
  8. {
  9. RaiseMessage("GLTFExporter.Light | ExportLight babylonLight.name=" + babylonLight.name, 1);
  10. // --------------------------
  11. // ---------- Node ----------
  12. // --------------------------
  13. RaiseMessage("GLTFExporter.Light | Node", 2);
  14. // Node
  15. var gltfNode = new GLTFNode();
  16. gltfNode.name = babylonLight.name;
  17. gltfNode.index = gltf.NodesList.Count;
  18. gltf.NodesList.Add(gltfNode);
  19. // Hierarchy
  20. if (gltfParentNode != null)
  21. {
  22. RaiseMessage("GLTFExporter.Light | Add " + babylonLight.name + " as child to " + gltfParentNode.name, 3);
  23. gltfParentNode.ChildrenList.Add(gltfNode.index);
  24. }
  25. else
  26. {
  27. // It's a root node
  28. // Only root nodes are listed in a gltf scene
  29. RaiseMessage("GLTFExporter.Light | Add " + babylonLight.name + " as root node to scene", 3);
  30. gltf.scenes[0].NodesList.Add(gltfNode.index);
  31. }
  32. // Transform
  33. gltfNode.translation = babylonLight.position;
  34. // No rotation defined for babylon light. Use identity instead.
  35. gltfNode.rotation = new float[4] { 0, 0, 0, 1 };
  36. // No scaling defined for babylon light. Use identity instead.
  37. gltfNode.scale = new float[3] { 1, 1, 1 };
  38. // Animations
  39. ExportNodeAnimation(babylonLight, gltf, gltfNode);
  40. return gltfNode;
  41. }
  42. }
  43. }