{
  "Name": "LoadSmesh",
  "_id": "a8d45d3f-437c-41b3-a5c1-261d82e3e3b4",
  "Namespace": "lib.3d.generate",
  "Description": "Loads a geometry from File. \r\nYou can export Smesh.files from Maya with the exporter in /Helpers/Maya/.\r\n\r\n",
  "Inputs": [
    {
      "Name": "FilePath",
      "MetaInstanceID": "f25b0b48-ad3b-4939-90d8-76154a9a8859",
      "DefaultValue": {
        "Type": "Text",
        "Value": ""
      },
      "MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "Out",
      "MetaInstanceID": "5f5c7860-3887-4e77-a7f1-6cbaa4c2b064",
      "MetaID": "79122951-7bc4-4c68-b085-866eab828248"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "d8e6fa83-befd-4767-857c-6d9d16b3170d",
      "MetaID": "10141962-a1dc-4e08-9e1d-8b7ba9663c48",
      "Name": "LoadSmeshFunc",
      "Version": "e45ecafe-a77d-4323-92b8-d94a7189b8ae",
      "Type": "Scene",
      "IsMultiInput": "True",
      "Script": [
        "//>>> _using",
        "using System;",
        "using System.Collections.Generic;",
        "using System.Linq;",
        "using System.Text;",
        "using SharpDX;",
        "using SharpDX.Direct3D11;",
        "using SharpDX.Windows;",
        "//<<< _using",
        "using System.IO;",
        "",
        "namespace Framefield.Core.ID10141962_a1dc_4e08_9e1d_8b7ba9663c48",
        "{",
        "    public class Class_LoadSmesh : OperatorPart.Function,",
        "                                   Framefield.Core.OperatorPartTraits.IMeshSupplier",
        "    {",
        "        // IMeshSupplier",
        "        public void AddMeshesTo(ICollection<Mesh> meshes)",
        "        {",
        "            UpdateMesh(new OperatorPartContext(), OperatorPart.Connections);",
        "",
        "            if (_meshResource != null)",
        "            {",
        "                _meshResource.Meshes.ForEach(meshes.Add);",
        "            }",
        "        }",
        "",
        "        public override void Dispose()",
        "        {",
        "            Utilities.DisposeObj(ref _meshResource);",
        "        }",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx)",
        "        {",
        "",
        "            try",
        "            {",
        "                UpdateMesh(context, inputs);",
        "",
        "                context.Renderer.SetupEffect(context);",
        "                foreach (var mesh in _meshResource.Meshes)",
        "                {",
        "                    context.Renderer.Render(mesh, context);",
        "                }",
        "            }",
        "            catch (Exception)",
        "            {",
        "                //Logger.Error(this,\"error\");",
        "            }",
        "",
        "            return context;",
        "        }",
        "",
        "        private void UpdateMesh(OperatorPartContext context, IList<OperatorPart> inputs)",
        "        {",
        "            if (!Changed) ",
        "                return;",
        "",
        "            var FilePath = inputs[0].Eval(context).Text;",
        "",
        "            Dispose();",
        "            if(File.Exists( FilePath)) {",
        "                _meshResource = ResourceManager.ReadSmesh(FilePath);",
        "            }",
        "            else {",
        "                Logger.Warn(this, \"File does not exist '{0}'\", FilePath);",
        "            }",
        "                ",
        "                ",
        "            Changed = false;",
        "        }",
        "",
        "        private MeshResource _meshResource;",
        "    }",
        "}",
        "",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "f25b0b48-ad3b-4939-90d8-76154a9a8859",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "d8e6fa83-befd-4767-857c-6d9d16b3170d"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "d8e6fa83-befd-4767-857c-6d9d16b3170d",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "5f5c7860-3887-4e77-a7f1-6cbaa4c2b064"
    }
  ]
}