using Earthblend.Tts.Common.Core.Behaviors;
using Earthblend.Tts.Common.Core.Members;
using HelixToolkit.Wpf;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using VirtualCanvasTestCode.MeshGenerators;

public class LetterService
{
    #region Constructor(s)

    public LetterService()
    {

    }

    #endregion

    public GeometryModel3D AddRibbonTextItem(VirtualWorld3DPluginDataItem masterDataItem)
    {
        var idenfitiferDataItem = new VirtualWorld3DPluginDataItem() { Name = "RibbonText" };
        masterDataItem.TextLinked3DObjectId = idenfitiferDataItem.Id;

        RibbonTextMeshGenerator meshGenerator = new RibbonTextMeshGenerator();
        meshGenerator.Text = masterDataItem.Text;
        meshGenerator.FontDepth = masterDataItem.FontDepth;
        meshGenerator.FontSize = masterDataItem.TextFontSize;
        meshGenerator.RotateX = masterDataItem.TextRotationX;
        meshGenerator.RotateY = masterDataItem.TextRotationY;
        meshGenerator.RotateZ = masterDataItem.TextRotationZ;
        meshGenerator.PosX = masterDataItem.PosX;
        meshGenerator.PosY = masterDataItem.PosY;
        meshGenerator.PosZ = masterDataItem.PosZ;
        meshGenerator.TextOffsetX = masterDataItem.TextOffsetPosX;
        meshGenerator.TextOffsetY = masterDataItem.TextOffsetPosY;
        meshGenerator.TextOffsetZ = masterDataItem.TextOffsetPosZ;

        GeometryModel3D geometryModel3D = new GeometryModel3D() { Material = new DiffuseMaterial(new SolidColorBrush(Colors.White)), BackMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Black)) };
        geometryModel3D.SetName(masterDataItem.Id.ToString());
        geometryModel3D.SetValue(ObjectBinder.DataItemProperty, masterDataItem); //idenfitiferDataItem
        geometryModel3D.Geometry = meshGenerator.Geometry;

        Transform3DGroup transform3DGroup = new Transform3DGroup();
        TranslateTransform3D translateTransform3D = new TranslateTransform3D
        (
              masterDataItem.Ttx + masterDataItem.TextOffsetPosX
            , masterDataItem.Tty + masterDataItem.TextOffsetPosY
            , masterDataItem.Ttz + masterDataItem.TextOffsetPosZ
        );

        translateTransform3D.SetName("TestText");
        transform3DGroup.Children.Add(translateTransform3D);
        geometryModel3D.Transform = transform3DGroup;

        meshGenerator = null;

        return geometryModel3D;
    }
}