public static string serializeNodeArray(Node[] nodeArray)
 {
     swellanimations.Animation animation = new swellanimations.Animation ();
             animation.frames.AddRange (nodeArray);
             ModeldataSerializer serializer = new ModeldataSerializer ();
             MemoryStream memStream = new MemoryStream ();
             serializer.Serialize (memStream, animation);
             byte[] arr = memStream.ToArray ();
             memStream.Close ();
             return Convert.ToBase64String (arr);
 }
    public static Node[] deserializeNodeArray(string serializedNodeArray)
    {
        byte[]              bytes      = Convert.FromBase64String(serializedNodeArray);
        MemoryStream        stream     = new MemoryStream(bytes, false);
        ModeldataSerializer serializer = new ModeldataSerializer();

        swellanimations.Animation animation = null;
        animation = (swellanimations.Animation)serializer.Deserialize(stream, null, typeof(swellanimations.Animation));
        stream.Close();
        return(animation.frames.ToArray());
    }
    public static string serializeNodeArray(Node[] nodeArray)
    {
        swellanimations.Animation animation = new swellanimations.Animation();
        animation.frames.AddRange(nodeArray);
        ModeldataSerializer serializer = new ModeldataSerializer();
        MemoryStream        memStream  = new MemoryStream();

        serializer.Serialize(memStream, animation);
        byte[] arr = memStream.ToArray();
        memStream.Close();
        return(Convert.ToBase64String(arr));
    }
Esempio n. 4
0
 public void GenerateAnimation()
 {
     if (points != null && points.Count > 0)
     {
         beginPostion  = model.position;
         beginRotation = model.rotation;
         currentFrame  = 0;
         ModelData modelData = AnimationData.CreateModelData(model, points, rotationPoints, detailLoaPoints, mutatorStrength);
         modelData.numberOfFrames = framesOfAnimation;
         swellanimations.Animation animation = BackendAdapter.GenerateFromBackend(modelData);
         frames = animation.frames.ToArray();
         serializedAnimation = BackendAdapter.serializeNodeArray(frames);
         //Debug.Log("Just serialized: " + serializedAnimation);
         ClearMaps();
         FillModelMap(model);
     }
 }
Esempio n. 5
0
 public void GenerateAnimation()
 {
     if (points != null && points.Count > 0)
     {
         currentFrame = 0;
         List <Vector3> line = points;
         if (smoothCurve && points.Count >= 4)
         {
             line = GetCatmullRomCurve(line);
         }
         ModelData modelData = AnimationData.CreateModelData(model, line, rotationPoints,
                                                             detailLoaPoints, framesOfAnimation, mutatorStrength);
         swellanimations.Animation animation = BackendAdapter.GenerateFromBackend(modelData);
         frames = animation.frames.ToArray();
         serializedAnimation = BackendAdapter.serializeNodeArray(frames);
         //Debug.Log("Animation generated");
         ClearMaps();
         FillModelMap(model);
     }
 }
    public static swellanimations.Animation GenerateFromBackend(ModelData modelData)
    {
        ModeldataSerializer serializer = new ModeldataSerializer();
        MemoryStream        memStream  = new MemoryStream();

        serializer.Serialize(memStream, modelData);
        byte[] arr = memStream.ToArray();
        //Debug.Log (Convert.ToBase64String (arr));
        int    size       = arr.Length;
        uint   outputSize = 0;
        IntPtr retData    = generateAnimation(arr, size, ref outputSize);
        var    bytes      = new byte[(int)outputSize];

        Marshal.Copy(retData, bytes, 0, (int)outputSize);
        //Debug.Log (Convert.ToBase64String (bytes));
        MemoryStream stream = new MemoryStream(bytes, false);

        swellanimations.Animation animation = null;
        animation = (swellanimations.Animation)serializer.Deserialize(stream, null, typeof(swellanimations.Animation));
        memStream.Close();
        stream.Close();
        return(animation);
    }