Пример #1
0
    void plotIndividual(string singlePose)
    {
        string[] p   = singlePose.Split(']');
        float    min = 999;

        for (int i = 0; i < points.Length; ++i)
        {
            float[] temp = p[i].Replace("[", "").Replace(Environment.NewLine, "").Split(',').Where(s => s != "").Select(f => float.Parse(f)).ToArray();
            points[i] = new Vector3(temp[0], temp[2], temp[1]);
            if (temp[2] < min)
            {
                min = temp[2];                                  // height adjust
            }
        }

        //draw Interaction
        for (int i = 0; i < InteractionPointContainer.Count; ++i)
        {
            if (Vector3.Distance(InteractionPointContainer[i], points[1]) < Interact_Dis_Thre)
            {
                DrawLine3D(InteractionPointContainer[i], points[1], interact_mat);
            }
        }

        //draw Bones
        InteractionPointContainer.Add(points[1]);
        for (int i = 0; i < bones_num; ++i)
        {
            if ((Vector3.Distance(points[Bones[i, 0]], points[Bones[i, 1]]) < 1.2) && (Vector3.Distance(points[Bones[i, 0]], points[Bones[i, 1]]) > 0))
            {
                DrawLine3D(points[Bones[i, 0]], points[Bones[i, 1]], skeleton_mat);
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (NowFrame < Frames && Play_Continuously)
        {
            Timer += Time.deltaTime;
            if (Timer > (1 / FrameRate))
            {
                Timer = 0;
                StreamReader fi = null;
                fi = new StreamReader(Application.dataPath + Data_Path + File_Name + NowFrame.ToString() + ".json");
                Debug.Log(Data_Path + File_Name + NowFrame.ToString() + ".json");
                NowFrame++;
                string   allPose     = fi.ReadToEnd();
                string[] singlePoses = allPose.Split('*');

                LinePointContainer.Clear();
                InteractionPointContainer.Clear();
                ClearLineObjects();

                for (int i = 0; i < singlePoses.Length - 1; ++i)
                {
                    plotIndividual(singlePoses[i]);
                }
                fi.Close();
            }
        }
        if (!Play_Continuously)
        {
            StreamReader fi = null;
            fi = new StreamReader(Application.dataPath + "/pose.json");
            Debug.Log(Application.dataPath + "/pose.json");
            string   allPose     = fi.ReadToEnd();
            string[] singlePoses = allPose.Split('*');
            for (int i = 0; i < singlePoses.Length - 1; ++i)
            {
                plotIndividual(singlePoses[i]);
            }
            fi.Close();
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //clear all(for debug only)
            InteractionPointContainer.Clear();
            LinePointContainer.Clear();
            ClearLineObjects();
        }
    }
Пример #3
0
        public void GetAttributes(Frame[] frames, Animation[] animations, string code, byte[] sp12, byte[] sp34)
        {
            GlobalPalette = new GlobalColorPaletteContainer();
            GlobalPalette.ToGlobalColorPaletteContainer();
            Code = code;
            SP12 = sp12;
            SP34 = sp34;
            List <HitBox>           hbs = new List <HitBox>();
            List <InteractionPoint> ips = new List <InteractionPoint>();

            foreach (Frame f in frames)
            {
                foreach (HitBox hb in f.HitBoxes)
                {
                    if (!hbs.Contains(hb))
                    {
                        hbs.Add(hb);
                    }
                }

                foreach (InteractionPoint hb in f.InteractionPoints)
                {
                    if (!ips.Contains(hb))
                    {
                        ips.Add(hb);
                    }
                }
            }

            Hitboxes = new HitboxContainer[hbs.Count];
            int i = 0;

            foreach (HitBox hb in hbs)
            {
                if (hb.GetType() == typeof(RectangleHitBox))
                {
                    Hitboxes[i] = new RectangleHitboxContainer();
                }
                else
                {
                    Hitboxes[i] = new HitboxContainer();
                }
                Hitboxes[i].ToHitboxContainer(hb);
                Hitboxes[i].Name = "" + i + "_" + Hitboxes[i].Name;
                i++;
            }

            InteractionPoints = new InteractionPointContainer[ips.Count];
            i = 0;

            foreach (InteractionPoint hb in ips)
            {
                InteractionPoints[i] = new InteractionPointContainer();
                InteractionPoints[i].ToHitboxContainer(hb);
                InteractionPoints[i].Name = "" + i + "_" + InteractionPoints[i].Name;
                i++;
            }

            Frames = new FrameContainer[frames.Length];
            i      = 0;

            foreach (Frame f in frames)
            {
                Frames[i] = new FrameContainer();
                Frames[i].ToFrameContainer(f, hbs, ips);
                i++;
            }

            Animations = new AnimationContainer[animations.Length];

            for (i = 0; i < animations.Length; i++)
            {
                Animations[i] = new AnimationContainer();
                Animations[i].ToAnimationContainer(animations[i]);
            }
        }