Exemplo n.º 1
0
        /*
         * パーツのαを連動する。
         * @param model
         * @param partsGroup
         */
        public void copyOpacityOtherParts(ALive2DModel model, L2DPartsParam[] partsGroup)
        {
            for (int i_group = 0; i_group < partsGroup.Length; i_group++)
            {
                L2DPartsParam partsParam = partsGroup[i_group];

                if (partsParam.link == null)
                {
                    continue;                         // リンクするパラメータはない
                }
                if (partsParam.partsIndex < 0)
                {
                    continue;                           // 存在しないパーツ
                }
                float opacity = model.getPartsOpacity(partsParam.partsIndex);

                for (int i_link = 0; i_link < partsParam.link.Count; i_link++)
                {
                    L2DPartsParam linkParts = partsParam.link[i_link];

                    if (linkParts.partsIndex < 0)
                    {
                        //
                        linkParts.initIndex(model);
                    }

                    if (linkParts.partsIndex < 0)
                    {
                        continue;                          //
                    }
                    model.setPartsOpacity(linkParts.partsIndex, opacity);
                }
            }
        }
Exemplo n.º 2
0
 public void addPartsGroup(string[] idGroup)
 {
     L2DPartsParam[] item = new L2DPartsParam[idGroup.Length];
     for (int i = 0; i < idGroup.Length; i++)
     {
         item[i] = new L2DPartsParam(idGroup[i]);
     }
     this.partsGroupList.Add(item);
 }
Exemplo n.º 3
0
        public void addPartsGroup(string[] idGroup)
        {
            L2DPartsParam[] partsGroup = new L2DPartsParam[idGroup.Length];

            for (int i = 0; i < idGroup.Length; i++)
            {
                partsGroup[i] = new L2DPartsParam(idGroup[i]);
            }

            partsGroupList.Add(partsGroup);
        }
Exemplo n.º 4
0
        /*
         * JSONファイルから読み込む
         * 仕様についてはマニュアル参照。JSONスキーマの形式の仕様がある。
         * @param buf
         * @return
         */
        public static L2DPose load(char[] buf)
        {
            L2DPose ret = new L2DPose();

            Value json = Json.parseFromBytes(buf);

            // フェード時間の指定。Viewer2.1.8より指定可能。
            if (json.getMap(null).ContainsKey("fade_in"))
            {
                ret.fadeInMS = json.get("fade_in").toInt();
            }

            // パーツ切り替え一覧
            List <Value> poseListInfo = json.get("parts_visible").getVector(null);
            int          poseNum      = poseListInfo.Count;

            for (int i_pose = 0; i_pose < poseNum; i_pose++)
            {
                Value poseInfo = poseListInfo[i_pose];

                // IDリストの設定
                List <Value>    idListInfo = poseInfo.get("group").getVector(null);
                int             idNum      = idListInfo.Count;
                L2DPartsParam[] partsGroup = new L2DPartsParam[idNum];
                for (int i_group = 0; i_group < idNum; i_group++)
                {
                    Value         partsInfo = idListInfo[i_group];
                    L2DPartsParam parts     = new L2DPartsParam(partsInfo.get("id").toString());
                    partsGroup[i_group] = parts;

                    // リンクするパーツの設定
                    if (!partsInfo.getMap(null).ContainsKey("link"))
                    {
                        continue;                                             // リンクが無いときもある
                    }
                    List <Value> linkListInfo = partsInfo.get("link").getVector(null);
                    int          linkNum      = linkListInfo.Count;
                    parts.link = new List <L2DPartsParam>();
                    for (int i_link = 0; i_link < linkNum; i_link++)
                    {
                        //					string linkID = idListInfo.get(i_group).tostring();//parts ID
                        L2DPartsParam linkParts = new L2DPartsParam(linkListInfo[i_link].toString());
                        parts.link.Add(linkParts);
                    }
                }
                ret.addPartsGroup(partsGroup);
            }
            return(ret);
        }
Exemplo n.º 5
0
        public static L2DPose load(char[] buf)
        {
            L2DPose ret = new L2DPose();

            Value json = Json.parseFromBytes(buf);


            List <Value> poseListInfo = json.get("parts_visible").getVector(null);
            int          poseNum      = poseListInfo.Count;

            for (int i_pose = 0; i_pose < poseNum; i_pose++)
            {
                Value poseInfo = poseListInfo[i_pose];


                List <Value>    idListInfo = poseInfo.get("group").getVector(null);
                int             idNum      = idListInfo.Count;
                L2DPartsParam[] partsGroup = new L2DPartsParam[idNum];
                for (int i_group = 0; i_group < idNum; i_group++)
                {
                    Value         partsInfo = idListInfo[i_group];
                    L2DPartsParam parts     = new L2DPartsParam(partsInfo.get("id").toString());
                    partsGroup[i_group] = parts;


                    if (!partsInfo.getMap(null).ContainsKey("link"))
                    {
                        continue;
                    }
                    List <Value> linkListInfo = partsInfo.get("link").getVector(null);
                    int          linkNum      = linkListInfo.Count;
                    parts.link = new List <L2DPartsParam>();
                    for (int i_link = 0; i_link < linkNum; i_link++)
                    {
                        //					string linkID = idListInfo.get(i_group).tostring();//parts ID
                        L2DPartsParam linkParts = new L2DPartsParam(linkListInfo[i_link].toString());
                        parts.link.Add(linkParts);
                    }
                }
                ret.addPartsGroup(partsGroup);
            }
            return(ret);
        }
Exemplo n.º 6
0
 public void copyOpacityOtherParts(ALive2DModel model, L2DPartsParam[] partsGroup)
 {
     for (int i = 0; i < partsGroup.Length; i++)
     {
         L2DPartsParam param = partsGroup[i];
         if ((param.link != null) && (param.partsIndex >= 0))
         {
             float opacity = model.getPartsOpacity(param.partsIndex);
             for (int j = 0; j < param.link.Count; j++)
             {
                 L2DPartsParam param2 = param.link[j];
                 if (param2.partsIndex < 0)
                 {
                     param2.initIndex(model);
                 }
                 if (param2.partsIndex >= 0)
                 {
                     model.setPartsOpacity(param2.partsIndex, opacity);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
        /*
         * パーツのフェードイン、フェードアウトを設定する。
         * @param model
         * @param partsGroup
         * @param deltaTimeSec
         */
        public void normalizePartsOpacityGroup(ALive2DModel model, L2DPartsParam[] partsGroup, float deltaTimeSec)
        {
            int visibleParts = -1;
            float visibleOpacity = 1.0f;

            float phi = 0.5f;// 背景が出にくいように、1>0への変化を遅らせる場合は、0.5よりも大きくする。ただし、あまり自然ではない
            float maxBackOpacity = 0.15f;

            //  現在、表示状態になっているパーツを取得
            for (int i = 0; i < partsGroup.Length; i++)
            {
                int partsIndex = partsGroup[i].partsIndex;
                int paramIndex = partsGroup[i].paramIndex;

                if (partsIndex < 0) continue;// 存在しないパーツです

                if (model.getParamFloat(paramIndex) != 0)
                {
                    if (visibleParts >= 0)
                    {
                        break;
                    }
                    visibleParts = i;
                    visibleOpacity = model.getPartsOpacity(partsIndex);

                    //  新しいOpacityを計算
                    visibleOpacity += deltaTimeSec / ( fadeInMS/1000.0f );
                    if (visibleOpacity > 1)
                    {
                        visibleOpacity = 1;
                    }
                }
            }

            if (visibleParts < 0)
            {
                visibleParts = 0;
                visibleOpacity = 1;
            }

            //  表示パーツ、非表示パーツの透明度を設定する
            for (int i = 0; i < partsGroup.Length; i++)
            {
                int partsIndex = partsGroup[i].partsIndex;
                if (partsIndex < 0) continue;// 存在しないパーツです

                //  表示パーツの設定
                if (visibleParts == i)
                {
                    model.setPartsOpacity(partsIndex, visibleOpacity);// 先に設定
                }
                //  非表示パーツの設定
                else
                {
                    float opacity = model.getPartsOpacity(partsIndex);
                    float a1;// 計算によって求められる透明度
                    if (visibleOpacity < phi)
                    {
                        a1 = visibleOpacity * (phi - 1) / phi + 1; //  (0,1),(phi,phi)を通る直線式
                    }
                    else
                    {
                        a1 = (1 - visibleOpacity) * phi / (1 - phi); //  (1,0),(phi,phi)を通る直線式
                    }

                    // 背景の見える割合を制限する場合
                    float backOp = (1 - a1) * (1 - visibleOpacity);// 背景の
                    if (backOp > maxBackOpacity)
                    {
                        a1 = 1 - maxBackOpacity / (1 - visibleOpacity);
                    }

                    if (opacity > a1)
                    {
                        opacity = a1;//  計算の透明度よりも大きければ(濃ければ)透明度を上げる
                    }
                    model.setPartsOpacity(partsIndex, opacity);
                }
            }
        }
Exemplo n.º 8
0
        /*
         * パーツのαを連動する。
         * @param model
         * @param partsGroup
         */
        public void copyOpacityOtherParts(ALive2DModel model, L2DPartsParam[] partsGroup)
        {
            for (int i_group = 0; i_group < partsGroup.Length; i_group++)
            {
                L2DPartsParam partsParam = partsGroup[i_group];

                if (partsParam.link == null) continue;// リンクするパラメータはない
                if (partsParam.partsIndex < 0) continue;// 存在しないパーツ

                float opacity = model.getPartsOpacity(partsParam.partsIndex);

                for (int i_link = 0; i_link < partsParam.link.Count; i_link++)
                {
                    L2DPartsParam linkParts = partsParam.link[i_link];

                    if (linkParts.partsIndex < 0)
                    {
                        //
                        linkParts.initIndex(model);
                    }

                    if (linkParts.partsIndex < 0) continue;//
                    model.setPartsOpacity(linkParts.partsIndex, opacity);
                }
            }
        }
Exemplo n.º 9
0
        public void addPartsGroup(string[] idGroup)
        {
            L2DPartsParam[] partsGroup = new L2DPartsParam[idGroup.Length];

            for (int i = 0; i < idGroup.Length; i++)
            {
                partsGroup[i] = new L2DPartsParam(idGroup[i]);
            }

            partsGroupList.Add(partsGroup);
        }
Exemplo n.º 10
0
 public void addPartsGroup(L2DPartsParam[] partsGroup)
 {
     partsGroupList.Add(partsGroup);
 }
Exemplo n.º 11
0
        /*
         * JSONファイルから読み込む
         * 仕様についてはマニュアル参照。JSONスキーマの形式の仕様がある。
         * @param buf
         * @return
         */
        public static L2DPose load(char[] buf)
        {
            L2DPose ret = new L2DPose();

            Value json = Json.parseFromBytes(buf);

            // フェード時間の指定。Viewer2.1.8より指定可能。
            if (json.getMap(null).ContainsKey("fade_in"))
            {
               ret.fadeInMS = json.get("fade_in").toInt();
            }

            // パーツ切り替え一覧
            List<Value> poseListInfo = json.get("parts_visible").getVector(null);
            int poseNum = poseListInfo.Count;

            for (int i_pose = 0; i_pose < poseNum; i_pose++)
            {
                Value poseInfo = poseListInfo[i_pose];

                // IDリストの設定
                List<Value> idListInfo = poseInfo.get("group").getVector(null);
                int idNum = idListInfo.Count;
                L2DPartsParam[] partsGroup = new L2DPartsParam[idNum];
                for (int i_group = 0; i_group < idNum; i_group++)
                {
                    Value partsInfo = idListInfo[i_group];
                    L2DPartsParam parts = new L2DPartsParam(partsInfo.get("id").toString());
                    partsGroup[i_group] = parts;

                    // リンクするパーツの設定
                    if (!partsInfo.getMap(null).ContainsKey("link")) continue;// リンクが無いときもある
                    List<Value> linkListInfo = partsInfo.get("link").getVector(null);
                    int linkNum = linkListInfo.Count;
                    parts.link = new List<L2DPartsParam>();
                    for (int i_link = 0; i_link < linkNum; i_link++)
                    {
                        //					string linkID = idListInfo.get(i_group).tostring();//parts ID
                        L2DPartsParam linkParts = new L2DPartsParam(linkListInfo[i_link].toString());
                        parts.link.Add(linkParts);
                    }
                }
                ret.addPartsGroup(partsGroup);
            }
            return ret;
        }
Exemplo n.º 12
0
        public void normalizePartsOpacityGroup(ALive2DModel model, L2DPartsParam[] partsGroup, float deltaTimeSec)
        {
            int visibleParts = -1;
            float visibleOpacity = 1.0f;

            float phi = 0.5f;
            float maxBackOpacity = 0.15f;

            for (int i = 0; i < partsGroup.Length; i++)
            {
                int partsIndex = partsGroup[i].partsIndex;
                int paramIndex = partsGroup[i].paramIndex;

                if (partsIndex < 0) continue;

                if (model.getParamFloat(paramIndex) != 0)
                {
                    if (visibleParts >= 0)
                    {
                        break;
                    }
                    visibleParts = i;
                    visibleOpacity = model.getPartsOpacity(partsIndex);

                    visibleOpacity += deltaTimeSec / ( fadeInMS/1000.0f );
                    if (visibleOpacity > 1)
                    {
                        visibleOpacity = 1;
                    }
                }
            }

            if (visibleParts < 0)
            {
                visibleParts = 0;
                visibleOpacity = 1;
            }

            for (int i = 0; i < partsGroup.Length; i++)
            {
                int partsIndex = partsGroup[i].partsIndex;
                if (partsIndex < 0) continue;

                if (visibleParts == i)
                {
                    model.setPartsOpacity(partsIndex, visibleOpacity);
                }

                else
                {
                    float opacity = model.getPartsOpacity(partsIndex);
                    float a1;
                    if (visibleOpacity < phi)
                    {
                        a1 = visibleOpacity * (phi - 1) / phi + 1;
                    }
                    else
                    {
                        a1 = (1 - visibleOpacity) * phi / (1 - phi);
                    }

                    float backOp = (1 - a1) * (1 - visibleOpacity);
                    if (backOp > maxBackOpacity)
                    {
                        a1 = 1 - maxBackOpacity / (1 - visibleOpacity);
                    }

                    if (opacity > a1)
                    {
                        opacity = a1;
                    }
                    model.setPartsOpacity(partsIndex, opacity);
                }
            }
        }
Exemplo n.º 13
0
 public static L2DPose load(char[] buf)
 {
     L2DPose pose = new L2DPose();
     List<Value> list = Json.parseFromBytes(buf).get("parts_visible").getVector(null);
     int count = list.Count;
     for (int i = 0; i < count; i++)
     {
         Value value3 = list[i];
         List<Value> list2 = value3.get("group").getVector(null);
         int num3 = list2.Count;
         L2DPartsParam[] partsGroup = new L2DPartsParam[num3];
         for (int j = 0; j < num3; j++)
         {
             Value value4 = list2[j];
             L2DPartsParam param = new L2DPartsParam(value4.get("id").toString());
             partsGroup[j] = param;
             if (value4.getMap(null).ContainsKey("link"))
             {
                 List<Value> list3 = value4.get("link").getVector(null);
                 int num5 = list3.Count;
                 param.link = new List<L2DPartsParam>();
                 for (int k = 0; k < num5; k++)
                 {
                     L2DPartsParam item = new L2DPartsParam(list3[k].toString());
                     param.link.Add(item);
                 }
             }
         }
         pose.addPartsGroup(partsGroup);
     }
     return pose;
 }
Exemplo n.º 14
0
 public void normalizePartsOpacityGroup(ALive2DModel model, L2DPartsParam[] partsGroup, float deltaTimeSec)
 {
     int num = -1;
     float opacity = 1f;
     float num3 = 0.5f;
     float num4 = 0.5f;
     float num5 = 0.15f;
     for (int i = 0; i < partsGroup.Length; i++)
     {
         int partsIndex = partsGroup[i].partsIndex;
         int paramIndex = partsGroup[i].paramIndex;
         if ((partsIndex >= 0) && (model.getParamFloat(paramIndex) != 0f))
         {
             if (num >= 0)
             {
                 break;
             }
             num = i;
             opacity = model.getPartsOpacity(partsIndex) + (deltaTimeSec / num3);
             if (opacity > 1f)
             {
                 opacity = 1f;
             }
         }
     }
     if (num < 0)
     {
         num = 0;
         opacity = 1f;
     }
     for (int j = 0; j < partsGroup.Length; j++)
     {
         int num10 = partsGroup[j].partsIndex;
         if (num10 >= 0)
         {
             if (num == j)
             {
                 model.setPartsOpacity(num10, opacity);
             }
             else
             {
                 float num12;
                 float num11 = model.getPartsOpacity(num10);
                 if (opacity < num4)
                 {
                     num12 = ((opacity * (num4 - 1f)) / num4) + 1f;
                 }
                 else
                 {
                     num12 = ((1f - opacity) * num4) / (1f - num4);
                 }
                 float num13 = (1f - num12) * (1f - opacity);
                 if (num13 > num5)
                 {
                     num12 = 1f - (num5 / (1f - opacity));
                 }
                 if (num11 > num12)
                 {
                     num11 = num12;
                 }
                 model.setPartsOpacity(num10, num11);
             }
         }
     }
 }