/// <summary> /// モーションのタイムライン描画処理 /// </summary> /// <param name="g">描画管理クラス</param> /// <param name="inWidth">描画先の幅</param> /// <param name="inHeight">描画先の高さ</param> public void DrawTime(Graphics g, int inWidth, int inHeight) { int inLineNo = ClsSystem.GetSelectLineNo(); int inFrameNo = ClsSystem.GetSelectFrameNo(); //以下、選択中フレームのラインを表示する処理 Brush clBrush = new SolidBrush(Color.DarkGreen); int inX = inFrameNo * FormControl.CELL_WIDTH; g.FillRectangle(clBrush, inX, 0, FormControl.CELL_WIDTH, inHeight); //以下、エレメント描画処理 int inCnt, inMax = this.mListElem.Count; for (inCnt = 0; inCnt < inMax; inCnt++) { ClsDatElem clElem = this.mListElem[inCnt]; clElem.DrawTime(g, inLineNo, inFrameNo, this.mMaxFrameNum, inWidth, inHeight); } //以下、最終フレームの境界線描画処理 Pen clPen = new Pen(Color.Green); inX = this.mMaxFrameNum * FormControl.CELL_WIDTH; g.DrawLine(clPen, inX, 0, inX, inHeight); }
/// <summary> /// オプションの情報を修正する処理 /// </summary> /// <param name="clParam">パラメーター情報</param> public void ChangeElemFromParam(ClsParam clParam) { ClsDatMotion clMotion = ClsSystem.GetSelectMotion(); if (clMotion == null) { return; } ClsDatElem clElem = ClsSystem.GetElemFromSelectLineNo(); if (clElem == null) { return; } int inSelectFrameNo = ClsSystem.GetSelectFrameNo(); //以下、表示設定 object clValue2 = ClsParam.GetDefaultValue2(EnmTypeOption.DISPLAY); this.ChangeElem(clElem, EnmTypeOption.DISPLAY, inSelectFrameNo, clParam.mDisplayKeyFrame, false, false, null, null, clParam.mDisplay, clValue2); //以下、座標設定 this.ChangeElem(clElem, EnmTypeOption.POSITION, inSelectFrameNo, clParam.mPositionKeyFrame, clParam.mPositionXTween, clParam.mPositionYTween, clParam.mTweenPositionX, clParam.mTweenPositionY, clParam.mX, clParam.mY); //以下、回転設定 clValue2 = ClsParam.GetDefaultValue2(EnmTypeOption.ROTATION); this.ChangeElem(clElem, EnmTypeOption.ROTATION, inSelectFrameNo, clParam.mRotationKeyFrame, clParam.mRotationTween, false, clParam.mTweenRotation, null, clParam.mRZ, clValue2); //以下、スケール設定 this.ChangeElem(clElem, EnmTypeOption.SCALE, inSelectFrameNo, clParam.mScaleKeyFrame, clParam.mScaleXTween, clParam.mScaleYTween, clParam.mTweenScaleX, clParam.mTweenScaleY, clParam.mSX, clParam.mSY); //以下、オフセット設定 this.ChangeElem(clElem, EnmTypeOption.OFFSET, inSelectFrameNo, clParam.mOffsetKeyFrame, clParam.mOffsetXTween, clParam.mOffsetYTween, clParam.mTweenOffsetX, clParam.mTweenOffsetY, clParam.mCX, clParam.mCY); //以下、反転設定 this.ChangeElem(clElem, EnmTypeOption.FLIP, inSelectFrameNo, clParam.mFlipKeyFrame, false, false, null, null, clParam.mFlipH, clParam.mFlipV); //以下、透明設定 clValue2 = ClsParam.GetDefaultValue2(EnmTypeOption.TRANSPARENCY); this.ChangeElem(clElem, EnmTypeOption.TRANSPARENCY, inSelectFrameNo, clParam.mTransKeyFrame, clParam.mTransTween, false, clParam.mTweenTrans, null, clParam.mTrans, clValue2); //以下、カラー設定 clValue2 = ClsParam.GetDefaultValue2(EnmTypeOption.COLOR); this.ChangeElem(clElem, EnmTypeOption.COLOR, inSelectFrameNo, clParam.mColorKeyFrame, clParam.mColorTween, false, clParam.mTweenColor, null, clParam.mColor, clValue2); //以下、ユーザーデータ設定 clValue2 = ClsParam.GetDefaultValue2(EnmTypeOption.USER_DATA); this.ChangeElem(clElem, EnmTypeOption.USER_DATA, inSelectFrameNo, clParam.mUserDataKeyFrame, false, false, null, null, clParam.mUserData, clValue2); //以下、行番号を振り直す処理 clMotion.RefreshLineNo(); //以下、メインウィンドウ更新処理 this.mFormMain.RefreshAll(); }
/// <summary> /// 選択中のキーフレームを取得する処理 /// </summary> /// <returns>選択中のキーフレーム</returns> private static ClsDatKeyFrame GetKeyFrameFromSelectFrame() { ClsDatItem clItem = ClsSystem.GetItemFromSelectLineNo(); if (clItem == null) { return(null); } //以下、エレメント設定 ClsDatElem clElem = null; ClsDatOption clOption = null; if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.ELEM) { clElem = clItem as ClsDatElem; clOption = clElem.mDicOption[EnmTypeOption.DISPLAY]; } else if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.OPTION) { clOption = clItem as ClsDatOption; clElem = clOption.mElemParent; } if (clOption == null) { return(null); } int inIndex = ClsSystem.GetSelectFrameNo(); if (inIndex != 0) { bool isExist = clOption.IsExistKeyFrame(inIndex); if (!isExist) { return(null); } } //以下、キーフレーム取得処理 ClsDatKeyFrame clKeyFrame = clOption.GetKeyFrame(inIndex); return(clKeyFrame); }
private void RefreshControl() { ClsDatMotion clMotion = ClsSystem.GetSelectMotion(); if (clMotion == null) { return; } int inSelectFrameNo = ClsSystem.GetSelectFrameNo(); int inMaxFrameNum = clMotion.GetMaxFrameNum(); int inSelectLineNo = ClsSystem.GetSelectLineNo(); ClsDatItem clItem = clMotion.GetItemFromLineNo(inSelectLineNo); //以下、削除ボタン有効化設定 bool isEnable = false; if (clItem != null) { if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.ELEM) { isEnable = true; } else if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.OPTION) { ClsDatOption clOption = clItem as ClsDatOption; isEnable = clOption.IsRemoveOK(); } } this.button_ItemRemove.Enabled = isEnable; //以下、アトリビュートウィンドウ設定 if (this.mFormMain != null) { if (this.mFormMain.mFormAttribute != null) { ClsDatElem clElem = ClsSystem.GetElemFromSelectLineNo(); this.mFormMain.mFormAttribute.Init(clElem, inSelectFrameNo, inMaxFrameNum); } } //以下、上ボタン有効化設定 isEnable = false; if (clItem != null) { ClsDatElem clElem = null; if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.ELEM) { clElem = clItem as ClsDatElem; if (clElem.mElem == null) { isEnable = clMotion.CanMoveUp(clElem); } else { //isEnable = clElem.mElem.CanMoveUp(clElem); //自分が長男かチェックする } } /* * else if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.OPTION) * { * ClsDatOption clOption = clItem as ClsDatOption; * clElem = clOption.mElem; * // isEnable = clElem.CanMoveUp(clOption); * } */ } this.button_ItemUp.Enabled = isEnable; //以下、下ボタン有効化設定 isEnable = false; if (clItem != null) { ClsDatElem clElem = null; if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.ELEM) { clElem = clItem as ClsDatElem; if (clElem.mElem == null) { isEnable = clMotion.CanMoveDown(clElem); } else { } } /* * else if (clItem.mTypeItem == ClsDatItem.TYPE_ITEM.OPTION) * { * ClsDatOption clOption = clItem as ClsDatOption; * clElem = clOption.mElem; * // isEnable = clElem.CanMoveDown(clOption); * } */ } this.button_ItemDown.Enabled = isEnable; }
/// <summary> /// 描画処理 /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { //以下、時間計測処理 TimeSpan stDiff = DateTime.Now - this.mTimeOld; this.mTimeOld = DateTime.Now; double doTimeDiff = stDiff.TotalMilliseconds; double doFPS = 1000.0 / doTimeDiff; //以下、モーション描画処理 int inFrameNoNow = 0; int inMaxFrameNum = ClsSystem.DEFAULT_FRAME_NUM; ClsDatMotion clMotion = ClsSystem.GetSelectMotion(); if (clMotion != null) { inFrameNoNow = ClsSystem.GetSelectFrameNo(); inMaxFrameNum = clMotion.GetMaxFrameNum(); clMotion.DrawPreview(this, inFrameNoNow, inMaxFrameNum); } //以下、キャンバスサイズ設定処理 this.mCanvasWidth = this.Width; this.mCanvasHeight = this.Height; int inWidth = this.Width; int inHeight = this.Height; //以下、一番引きのスクリーンでのグリッド表示処理を決める //(一番引きのスクリーンでは、グリッド間隔を最大にしても密度が濃くてラインで描く必要がないのと、ラインを大量に描画する必要があり重いため) bool isDammyGrid = false; if (this.mGridVisible) { if (this.mScale <= 0.125f) { isDammyGrid = true; } } //以下、OpenGL初期化処理 Wgl.wglMakeCurrent(this.hDC, this.hRC); //レンダリングコンテキストをカレントにする Gl.glLineWidth(1); //ラインの太さを1dotにする //以下、背景色設定処理 if (isDammyGrid) { Gl.glClearColor(this.mGridColor.R / 255.0f, this.mGridColor.G / 255.0f, this.mGridColor.B / 255.0f, 1.0f); } else { Gl.glClearColor(this.mBackColor.R / 255.0f, this.mBackColor.G / 255.0f, this.mBackColor.B / 255.0f, 1.0f); } //以下、バッファをクリアする処理 Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); //以下、ビューポートの設定処理 Gl.glViewport(0, 0, inWidth, inHeight); /* * if (this.Width > this.Height) * { * int inY = -(this.Width - this.Height) / 2; * Gl.glViewport(0, inY, this.Width, this.Width); * } * else * { * int inX = -(this.Height - this.Width) / 2; * Gl.glViewport(inX, 0, this.Height, this.Height); * } */ //以下、射影行列の設定処理 Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glOrtho(-inWidth / 2, inWidth / 2, -inHeight / 2, inHeight / 2, 0.0, 4.0); //以下、カメラの位置を設定する処理 Glu.gluLookAt(0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //視点の設定 //以下、モデルビュー行列の設定 Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); //以下、グリッドライン描画処理 if (this.mGridVisible) { if (!isDammyGrid) { this.DrawGridLine(this.mGridColor, this.mGridSpan * this.mScale); } } //以下、中心ライン描画処理 if (this.mCrossBarVisible) { this.DrawCrossBarLine(this.mCrossColor); } //以下、モーション描画処理 if (clMotion != null) { clMotion.DrawPreview(this, inFrameNoNow, inMaxFrameNum); } //以下、FPSのライン表示 { Gl.glLoadIdentity(); //マトリクス設定 Gl.glLineWidth(5); float flX1 = -(inWidth / 2.0f) + 0; float flY = (inHeight / 2.0f) - 5; float flX2 = (float)(flX1 + (doFPS / 60.0f) * inWidth); Color stColor = Color.Red; if (doFPS > 30.0) { stColor = Color.LimeGreen; } else if (doFPS > 15.0) { stColor = Color.Yellow; } this.DrawLine(stColor, flX1, flY, flX2, flY); } //以下、FPS描画処理 if (this.mImageFont != null) { string clFPS = doFPS.ToString("F1"); this.DrawFont(0, 0, "FPS " + clFPS, inWidth, inHeight); } //ダブルバッファ Wgl.wglSwapBuffers(this.hDC); }
private void button_Tween_Click(object sender, EventArgs e) { Button clButton = sender as Button; EnmParam enParam = EnmParam.NONE; if ("button_TweenX".Equals(clButton.Name)) { enParam = EnmParam.POSITION_X; } else if ("button_TweenY".Equals(clButton.Name)) { enParam = EnmParam.POSITION_Y; } else if ("button_TweenRZ".Equals(clButton.Name)) { enParam = EnmParam.ROTATION; } else if ("button_TweenSX".Equals(clButton.Name)) { enParam = EnmParam.SCALE_X; } else if ("button_TweenSY".Equals(clButton.Name)) { enParam = EnmParam.SCALE_Y; } else if ("button_TweenCX".Equals(clButton.Name)) { enParam = EnmParam.OFFSET_X; } else if ("button_TweenCY".Equals(clButton.Name)) { enParam = EnmParam.OFFSET_Y; } else if ("button_TweenT".Equals(clButton.Name)) { enParam = EnmParam.TRANS; } else if ("button_TweenC".Equals(clButton.Name)) { enParam = EnmParam.COLOR; } if (enParam == EnmParam.NONE) { return; } //以下、トゥイーンウィンドウ設定処理 int inFrameNo = ClsSystem.GetSelectFrameNo(); FormTween clForm = null; ClsDatTween clTween = clButton.Tag as ClsDatTween; if (clTween == null) { clForm = new FormTween(this.mFormMain, enParam, 10, 20, inFrameNo); } else { clForm = new FormTween(this.mFormMain, enParam, 10, 20, inFrameNo, clTween.mPos, clTween.mListVec); } clForm.ShowDialog(); if (clForm.DialogResult != DialogResult.OK) { return; } //以下、トゥイーン設定 clTween = clForm.GetTween(); FormTween.CreateTweenWeight(clTween); //重みリスト作成処理 clButton.Image = clTween.mImage; clButton.Tag = clTween; this.Param_ValueChanged(sender, e); }