/* * パーツのαを連動する。 * @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); } } }
/* * モデルのパラメータを更新。 * @param model */ public void updateParam(ALive2DModel model) { if (model == null) { return; } // 前回のモデルと同じではないので初期化が必要 if (model != lastModel) { // パラメータインデックスの初期化 initParam(model); } lastModel = model; long curTime = UtSystem.getUserTimeMSec(); float deltaTimeSec = ((lastTime == 0) ? 0 : (curTime - lastTime) / 1000.0f); lastTime = curTime; // 設定から時間を変更すると、経過時間がマイナスになることがあるので、経過時間0として対応。 if (deltaTimeSec < 0) { deltaTimeSec = 0; } for (int i = 0; i < partsGroupList.Count; i++) { normalizePartsOpacityGroup(model, partsGroupList[i], deltaTimeSec); copyOpacityOtherParts(model, partsGroupList[i]); } }
/* * 表示を初期化。 * αの初期値が0でないパラメータは、αを1に設定する。 * @param model */ public void initParam(ALive2DModel model) { if (model == null) { return; } for (int i = 0; i < partsGroupList.Count; i++) { L2DPartsParam[] partsGroup = partsGroupList[i]; for (int j = 0; j < partsGroup.Length; j++) { partsGroup[j].initIndex(model); int partsIndex = partsGroup[j].partsIndex; int paramIndex = partsGroup[j].paramIndex; if (partsIndex < 0) { continue; // 存在しないパーツです } bool v = (model.getParamFloat(paramIndex) != 0); model.setPartsOpacity(partsIndex, (v ? 1.0f : 0.0f)); model.setParamFloat(paramIndex, (v ? 1.0f : 0.0f)); } } }
public void updateParam(ALive2DModel model) { if (model == null) { return; } if (model != lastModel) { initParam(model); } lastModel = model; long curTime = UtSystem.getUserTimeMSec(); float deltaTimeSec = ((lastTime == 0) ? 0 : (curTime - lastTime) / 1000.0f); lastTime = curTime; if (deltaTimeSec < 0) { deltaTimeSec = 0; } for (int i = 0; i < partsGroupList.Count; i++) { normalizePartsOpacityGroup(model, partsGroupList[i], deltaTimeSec); copyOpacityOtherParts(model, partsGroupList[i]); } }
public void loadModelData(String path) { IPlatformManager pm = Live2DFramework.getPlatformManager(); if (debugMode) { pm.log("Load model : " + path); } live2DModel = pm.loadLive2DModel(path); live2DModel.saveParam(); if (Live2D.getError() != Live2D.L2D_NO_ERROR) { pm.log("Error : Failed to loadModelData()."); return; } var w = live2DModel.getCanvasWidth(); var h = live2DModel.getCanvasHeight(); modelMatrix = new L2DModelMatrix(w, h); if (w > h) { modelMatrix.setWidth(2); } else { modelMatrix.setHeight(2); } modelMatrix.setCenterPosition(0, 0); }
/* * モデルのパラメータを更新。 * @param model */ public void updateParam(ALive2DModel model) { long timeMSec = UtSystem.getUserTimeMSec() - startTimeMSec; for (int i = 0; i < physicsList.Count; i++) { physicsList[i].update(model, timeMSec); } }
public void loadTexture(ALive2DModel model, int no, string path) { path = path.Replace(".png", "").Replace(".", "_"); Texture texture = ResourceManager.Load <Texture>(path); ((Live2DModelUnity)model).setTexture(no, (Texture2D)texture); }
public override bool updateParam(ALive2DModel model) { bool updated = base.updateParam(model); if (isFinished()) { currentPriority = 0; } return updated; }
public void updateParam(ALive2DModel model) { long timeMSec = UtSystem.getUserTimeMSec() - startTimeMSec; for (int i = 0; i < physicsList.Count; i++) { physicsList[i].update(model, timeMSec); } }
public void loadTexture(ALive2DModel model, int no, string path) { if (LAppDefine.DEBUG_LOG) { Debug.Log("Load texture " + path); } Texture2D texture = FileManager.LoadTexture(path.Replace(".png", string.Empty)); ((Live2DModelUnity) model).setTexture(no, texture); }
public override bool updateParam(ALive2DModel model) { bool flag = base.updateParam(model); if (base.isFinished()) { this.currentPriority = 0; } return flag; }
public void initIndex(ALive2DModel model) { if (this.type == 0) { this.paramIndex = model.getParamIndex("VISIBLE:" + this.id); } this.partsIndex = model.getPartsDataIndex(PartsDataID.getID(this.id)); model.setParamFloat(this.paramIndex, 1f); }
public override bool updateParam(ALive2DModel model) { bool updated = base.updateParam(model); if (isFinished()) { currentPriority = 0; // 재생 중 모션의 우선 순위 해제 } return(updated); }
public override bool updateParam(ALive2DModel model) { bool updated = base.updateParam(model); if (isFinished()) { currentPriority = 0; //再生中モーションの優先度を解除 } return(updated); }
/* * パラメータとパーツのインデックスを初期化する。 * @param model */ public void initIndex(ALive2DModel model) { if (type == TYPE_VISIBLE) { paramIndex = model.getParamIndex("VISIBLE:" + id);// パーツ表示のパラメータはVISIBLE:がつく。Live2Dアニメータの仕様。 } partsIndex = model.getPartsDataIndex(PartsDataID.getID(id)); model.setParamFloat(paramIndex, 1); //Log.d("live2d",id+ " param:"+paramIndex+" parts:"+partsIndex); }
void Start() { modelManager = GetComponent <LAppModelProxy>(); live2DModel = modelManager.GetModel().getLive2DModel(); motionMgr = new MotionQueueManager(); motion = Live2DMotion.loadMotion(motionFile.bytes); int i = 0; foreach (TextAsset t in motionFiles) { motions[i] = Live2DMotion.loadMotion(motionFiles[i].bytes); i++; } InvokeRepeating("RandomMotion", 10, 10); }
void Start() { modelManager = GetComponent <LAppModelProxy>(); live2DModel = modelManager.GetModel().getLive2DModel(); motionMgr = new MotionQueueManager(); motion = Live2DMotion.loadMotion(motionFile.bytes); target = GameObject.FindGameObjectWithTag("Player"); AtkMotion = Live2DMotion.loadMotion(AttackMotion.bytes); attack = StartCoroutine(Attack()); int Stage = PlayerPrefs.GetInt("stage", 1); Damage = 20 + (5 * Stage); HP = 100 + (10 * Stage); }
/** * モデルのパラメータを更新する。 * 引数の詳細はドキュメントを参照。 */ public override void updateParamExe(ALive2DModel model, long timeMSec, float weight, MotionQueueEnt motionQueueEnt) { for (int i = paramList.Count - 1; i >= 0; --i) { L2DExpressionParam param = paramList[i]; if (param.type == TYPE_ADD) { model.addToParamFloat(param.id, param.value, weight); //相対変化 加算 } else if (param.type == TYPE_MULT) { model.multParamFloat(param.id, param.value, weight); //相対変化 乗算 } else if (param.type == TYPE_SET) { model.setParamFloat(param.id, param.value, weight); //絶対変化 } } }
public void initParam(ALive2DModel model) { if (model != null) { for (int i = 0; i < this.partsGroupList.Count; i++) { L2DPartsParam[] paramArray = this.partsGroupList[i]; for (int j = 0; j < paramArray.Length; j++) { paramArray[j].initIndex(model); int partsIndex = paramArray[j].partsIndex; int paramIndex = paramArray[j].paramIndex; if (partsIndex >= 0) { bool flag = model.getParamFloat(paramIndex) != 0f; model.setPartsOpacity(partsIndex, !flag ? 0f : 1f); model.setParamFloat(paramIndex, !flag ? 0f : 1f); } } } } }
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); } } } } }
public abstract void updateParamExe(ALive2DModel model, long timeMSec, float weight, MotionQueueEnt motionQueueEnt);
public void updateParam(ALive2DModel model) { long time = UtSystem.getUserTimeMSec(); float eyeParamValue; float t = 0; switch (this.eyeState) { case EYE_STATE.STATE_CLOSING: t = (time - stateStartTime) / (float)closingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_CLOSED; this.stateStartTime = time; } eyeParamValue = 1 - t; break; case EYE_STATE.STATE_CLOSED: t = (time - stateStartTime) / (float)closedMotionMsec; if (t >= 1) { this.eyeState = EYE_STATE.STATE_OPENING; this.stateStartTime = time; } eyeParamValue = 0; break; case EYE_STATE.STATE_OPENING: t = (time - stateStartTime) / (float)openingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink(); } eyeParamValue = t; break; case EYE_STATE.STATE_INTERVAL: // if (this.nextBlinkTime < time) { this.eyeState = EYE_STATE.STATE_CLOSING; this.stateStartTime = time; } eyeParamValue = 1; break; case EYE_STATE.STATE_FIRST: default: this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink(); eyeParamValue = 1; break; } if (!closeIfZero) { eyeParamValue = -eyeParamValue; } model.setParamFloat(eyeID_L, eyeParamValue); model.setParamFloat(eyeID_R, eyeParamValue); }
/* * パーツのフェードイン、フェードアウトを設定する。 * @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); } } }
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); } } } }
public void loadModelData(String path) { IPlatformManager pm = Live2DFramework.getPlatformManager(); if (debugMode) pm.log("Load model : " + path); live2DModel = pm.loadLive2DModel(path); live2DModel.saveParam(); if (Live2D.getError() != Live2D.L2D_NO_ERROR) { pm.log("Error : Failed to loadModelData()."); return; } var w = live2DModel.getCanvasWidth(); var h = live2DModel.getCanvasHeight(); modelMatrix = new L2DModelMatrix(w, h); if (w>h) { modelMatrix.setWidth(2); } else { modelMatrix.setHeight(2); } modelMatrix.setCenterPosition(0, 0); }
/* * モデルのパラメータを更新。 * @param model */ public void updateParam(ALive2DModel model) { if (model == null) return; // 前回のモデルと同じではないので初期化が必要 if (model != lastModel) { // パラメータインデックスの初期化 initParam(model); } lastModel = model; long curTime = UtSystem.getUserTimeMSec(); float deltaTimeSec = ((lastTime == 0) ? 0 : (curTime - lastTime) / 1000.0f); lastTime = curTime; // 設定から時間を変更すると、経過時間がマイナスになることがあるので、経過時間0として対応。 if (deltaTimeSec < 0) deltaTimeSec = 0; for (int i = 0; i < partsGroupList.Count; i++) { normalizePartsOpacityGroup(model, partsGroupList[i], deltaTimeSec); copyOpacityOtherParts(model, partsGroupList[i]); } }
public void loadModelData(string path) { IPlatformManager manager = Live2DFramework.getPlatformManager(); if (this.debugMode) { manager.log("Load model : " + path); } this.live2DModel = manager.loadLive2DModel(path); ((Live2DModelUnity) this.live2DModel).setRenderMode(1); this.live2DModel.saveParam(); if (Live2D.getError() != 0) { manager.log("Error : Failed to loadModelData()."); } else { float w = this.live2DModel.getCanvasWidth(); float h = this.live2DModel.getCanvasHeight(); this.modelMatrix = new L2DModelMatrix(w, h); if (w > h) { this.modelMatrix.setWidth(2f); } else { this.modelMatrix.setHeight(2f); } this.modelMatrix.setCenterPosition(0f, 0f); } }
public override void updateParamExe(ALive2DModel model, long timeMSec, float weight, MotionQueueEnt motionQueueEnt) { for (int i = this.paramList.Count - 1; i >= 0; i--) { L2DExpressionParam param = this.paramList[i]; if (param.type == 1) { model.addToParamFloat(param.id, param.value, weight); } else if (param.type == 2) { model.multParamFloat(param.id, param.value, weight); } else if (param.type == 0) { model.setParamFloat(param.id, param.value, weight); } } }
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); } } }
public void updateParam(ALive2DModel model) { if (model != null) { if (model != this.lastModel) { this.initParam(model); } this.lastModel = model; long num = UtSystem.getUserTimeMSec(); float deltaTimeSec = (this.lastTime != 0) ? (((float) (num - this.lastTime)) / 1000f) : 0f; this.lastTime = num; if (deltaTimeSec < 0f) { deltaTimeSec = 0f; } for (int i = 0; i < this.partsGroupList.Count; i++) { this.normalizePartsOpacityGroup(model, this.partsGroupList[i], deltaTimeSec); this.copyOpacityOtherParts(model, this.partsGroupList[i]); } } }
public void updateParam(ALive2DModel model) { if (model == null) return; if (model != lastModel) { initParam(model); } lastModel = model; long curTime = UtSystem.getUserTimeMSec(); float deltaTimeSec = ((lastTime == 0) ? 0 : (curTime - lastTime) / 1000.0f); lastTime = curTime; if (deltaTimeSec < 0) deltaTimeSec = 0; for (int i = 0; i < partsGroupList.Count; i++) { normalizePartsOpacityGroup(model, partsGroupList[i], deltaTimeSec); copyOpacityOtherParts(model, partsGroupList[i]); } }
/* * モデルのパラメータを更新。 * @param model */ public void updateParam(ALive2DModel model) { long time = UtSystem.getUserTimeMSec(); float eyeParamValue;// 設定する値 float t = 0; switch (this.eyeState) { case EYE_STATE.STATE_CLOSING: // 閉じるまでの割合を0..1に直す(blinkMotionMsecの半分の時間で閉じる) t = (time - stateStartTime) / (float)closingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_CLOSED;// 次から開き始める this.stateStartTime = time; } eyeParamValue = 1 - t; break; case EYE_STATE.STATE_CLOSED: t = (time - stateStartTime) / (float)closedMotionMsec; if (t >= 1) { this.eyeState = EYE_STATE.STATE_OPENING;// 次から開き始める this.stateStartTime = time; } eyeParamValue = 0;// 閉じた状態 break; case EYE_STATE.STATE_OPENING: t = (time - stateStartTime) / (float)openingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_INTERVAL;// 次から開き始める this.nextBlinkTime = calcNextBlink();// 次回のまばたきのタイミングを始める時刻 } eyeParamValue = t; break; case EYE_STATE.STATE_INTERVAL: // if (this.nextBlinkTime < time) { this.eyeState = EYE_STATE.STATE_CLOSING; this.stateStartTime = time; } eyeParamValue = 1;// 開いた状態 break; case EYE_STATE.STATE_FIRST: default: this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink();// 次回のまばたきのタイミングを始める時刻 eyeParamValue = 1;// 開いた状態 break; } if (!closeIfZero) eyeParamValue = -eyeParamValue; // ---- 値を設定 ---- model.setParamFloat(eyeID_L, eyeParamValue); model.setParamFloat(eyeID_R, eyeParamValue); }
/* * パーツのαを連動する。 * @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); } } }
public void updateParam(ALive2DModel model) { long time = UtSystem.getUserTimeMSec(); float eyeParamValue; float t = 0; switch (this.eyeState) { case EYE_STATE.STATE_CLOSING: t = (time - stateStartTime) / (float)closingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_CLOSED; this.stateStartTime = time; } eyeParamValue = 1 - t; break; case EYE_STATE.STATE_CLOSED: t = (time - stateStartTime) / (float)closedMotionMsec; if (t >= 1) { this.eyeState = EYE_STATE.STATE_OPENING; this.stateStartTime = time; } eyeParamValue = 0; break; case EYE_STATE.STATE_OPENING: t = (time - stateStartTime) / (float)openingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink(); } eyeParamValue = t; break; case EYE_STATE.STATE_INTERVAL: // if (this.nextBlinkTime < time) { this.eyeState = EYE_STATE.STATE_CLOSING; this.stateStartTime = time; } eyeParamValue = 1; break; case EYE_STATE.STATE_FIRST: default: this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink(); eyeParamValue = 1; break; } if (!closeIfZero) eyeParamValue = -eyeParamValue; model.setParamFloat(eyeID_L, eyeParamValue); model.setParamFloat(eyeID_R, eyeParamValue); }
/* * 表示を初期化。 * αの初期値が0でないパラメータは、αを1に設定する。 * @param model */ public void initParam(ALive2DModel model) { if (model == null) return; for (int i = 0; i < partsGroupList.Count; i++) { L2DPartsParam[] partsGroup = partsGroupList[i]; for (int j = 0; j < partsGroup.Length; j++) { partsGroup[j].initIndex(model); int partsIndex = partsGroup[j].partsIndex; int paramIndex = partsGroup[j].paramIndex; if (partsIndex < 0) continue;// 存在しないパーツです bool v = (model.getParamFloat(paramIndex) != 0); model.setPartsOpacity(partsIndex, (v ? 1.0f : 0.0f)); model.setParamFloat(paramIndex, (v ? 1.0f : 0.0f)); } } }
public void updateParam(ALive2DModel model, MotionQueueEnt motionQueueEnt) { }
/* * パーツのフェードイン、フェードアウトを設定する。 * @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); } } }
/** * モデルのパラメータを更新。 * @param model */ public void updateParam(ALive2DModel model) { long time = UtSystem.getUserTimeMSec(); float eyeParamValue; //設定する値 float t = 0; switch (this.eyeState) { case EYE_STATE.STATE_CLOSING: //閉じるまでの割合を0..1に直す(blinkMotionMsecの半分の時間で閉じる) t = (time - stateStartTime) / (float)closingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_CLOSED; //次から開き始める this.stateStartTime = time; } eyeParamValue = 1 - t; break; case EYE_STATE.STATE_CLOSED: t = (time - stateStartTime) / (float)closedMotionMsec; if (t >= 1) { this.eyeState = EYE_STATE.STATE_OPENING; //次から開き始める this.stateStartTime = time; } eyeParamValue = 0; //閉じた状態 break; case EYE_STATE.STATE_OPENING: t = (time - stateStartTime) / (float)openingMotionMsec; if (t >= 1) { t = 1; this.eyeState = EYE_STATE.STATE_INTERVAL; //次から開き始める this.nextBlinkTime = calcNextBlink(); //次回のまばたきのタイミングを始める時刻 } eyeParamValue = t; break; case EYE_STATE.STATE_INTERVAL: // if (this.nextBlinkTime < time) { this.eyeState = EYE_STATE.STATE_CLOSING; this.stateStartTime = time; } eyeParamValue = 1; //開いた状態 break; case EYE_STATE.STATE_FIRST: default: this.eyeState = EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = calcNextBlink(); //次回のまばたきのタイミングを始める時刻 eyeParamValue = 1; //開いた状態 break; } if (!closeIfZero) { eyeParamValue = -eyeParamValue; } //---- 値を設定 ---- model.setParamFloat(eyeID_L, eyeParamValue); model.setParamFloat(eyeID_R, eyeParamValue); }
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); } } }
/* * モデルのパラメータを更新する。 * 引数の詳細はドキュメントを参照。 */ public override void updateParamExe(ALive2DModel model, long timeMSec, float weight, MotionQueueEnt motionQueueEnt) { for (int i = paramList.Count - 1; i >= 0; --i) { L2DExpressionParam param = paramList[i]; if (param.type == TYPE_ADD) { model.addToParamFloat(param.id, param.value, weight);// 相対変化 加算 } else if (param.type == TYPE_MULT) { model.multParamFloat(param.id, param.value, weight);// 相対変化 乗算 } else if (param.type == TYPE_SET) { model.setParamFloat(param.id, param.value, weight);// 絶対変化 } } }
public void updateParam(ALive2DModel model) { float num2; long num = UtSystem.getUserTimeMSec(); float num3 = 0f; switch (this.eyeState) { case live2d.framework.EYE_STATE.STATE_INTERVAL: if (this.nextBlinkTime < num) { this.eyeState = live2d.framework.EYE_STATE.STATE_CLOSING; this.stateStartTime = num; } num2 = 1f; break; case live2d.framework.EYE_STATE.STATE_CLOSING: num3 = ((float) (num - this.stateStartTime)) / ((float) this.closingMotionMsec); if (num3 >= 1f) { num3 = 1f; this.eyeState = live2d.framework.EYE_STATE.STATE_CLOSED; this.stateStartTime = num; } num2 = 1f - num3; break; case live2d.framework.EYE_STATE.STATE_CLOSED: num3 = ((float) (num - this.stateStartTime)) / ((float) this.closedMotionMsec); if (num3 >= 1f) { this.eyeState = live2d.framework.EYE_STATE.STATE_OPENING; this.stateStartTime = num; } num2 = 0f; break; case live2d.framework.EYE_STATE.STATE_OPENING: num3 = ((float) (num - this.stateStartTime)) / ((float) this.openingMotionMsec); if (num3 >= 1f) { num3 = 1f; this.eyeState = live2d.framework.EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = this.calcNextBlink(); } num2 = num3; break; default: this.eyeState = live2d.framework.EYE_STATE.STATE_INTERVAL; this.nextBlinkTime = this.calcNextBlink(); num2 = 1f; break; } if (!this.closeIfZero) { num2 = -num2; } model.setParamFloat(this.eyeID_L, num2); model.setParamFloat(this.eyeID_R, num2); }