protected override void OnLoad(EventArgs e) { base.OnLoad(e); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext); OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd"; if (ofd2.ShowDialog() == DialogResult.OK) { IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true); model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay); } WorldSpace.AddResource(model); //②コントローラーフォームに対して読み込んだモデルを渡して表示します。 Controller controller = new Controller(model); controller.Show(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Model_Load_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog { RestoreDirectory = true, Title = "PMX file of the target to open", Filter = "PMX model file(*.pmx)|*.pmx" }; if (ofd.ShowDialog() == DialogResult.OK) { if (this.Model != null) { this._scContext.WorldSpace.RemoveResource(this.Model); } this.Model = PMXModelWithPhysics.OpenLoad(ofd.FileName, this.Context); this.Model.Transformer.Position = new Vector3(0, 0, 0); this._scContext.WorldSpace.AddResource(this.Model); Form1.Controller.setTargetModel(this.Model); Form1.Controller.Type = TransformController.TransformType.Translation; this.Motion_Load.Enabled = true; this.IsPlaying = true; Settings.Default.InitLoadModel = ofd.FileName; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext); OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd"; if (ofd2.ShowDialog() == DialogResult.OK) { IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true); model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay); } WorldSpace.AddResource(model); //③ カメラモーションの選択ダイアログを表示し、選ばれたものをScreenContext.CameraMotionProviderに代入する。 CameraControlSelector selector = new CameraControlSelector(model); selector.ShowDialog(this); ScreenContext.CameraMotionProvider = selector.ResultCameraMotionProvider; /* * ScreenContext.CameraMotionProviderに代入されたインターフェースのUpdateCameraが毎回呼ばれることによりカメラを更新している。 * この変数の型はICameraMotionProviderのため、これを実装すればカメラの動きは容易に定義可能である。 */ } }
//①Form.OnLoadをオーバーライドする。 protected override void OnLoad(EventArgs e) { base.OnLoad(e); //RenderFormはOnLoad内で3DCG空間を初期化しているため、base.OnLoadがOnLoad内で一番初めに呼ぶべきである。 //ファイルを開くダイアログ OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { //ダイアログの返値がOKの場合、モデルの読み込み処理をする //②モデルを読み込む PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);//MMDModel MMDModelWithPhysics.OpenLoad(string ファイル名,RenderContext);となっています //以下のように書けば、物理演算を無効にして読み込むことも可能 //MMDModel model=MMDModel.OpenLoad(ofd.FileName, RenderContext); //RenderContextはカメラの情報やデバイスの情報など3DCG描画に必要な変数である。RenderFormを継承している場合、メンバー変数として利用可能である。 //基本的にモデルなどの読み込みが必要なものは、DirectX11デバイスの情報などを保持するRenderContextの値を要求する場合が多い。 //③ワールド空間にモデルを追加する WorldSpace.AddResource(model); //WorldSpaceは、このフォームの描画する3D空間を示している。ここにモデルなど(IDrawableを実装している)ものを渡すと、描画してくれる。 //WorldSpaceは、ScreenContext.WorldSpaceと常に等しい。ウィンドウごとに必要な3DCG描画に必要な情報はScreenContextに保管されている。 } }
private void Add2Child_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "開く対象のPMXファイル"; ofd.Filter = "PMXモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { if (Model != null) { _sccContext.WorldSpace.RemoveResource(Model); } Model = PMXModelWithPhysics.OpenLoad(ofd.FileName, Context); Model.Transformer.Position = new Vector3(0, 0, 0); #region KinectFKテストコード #if KINECT updater = new KinectFKUpdater(device); updater.TrackingUser += updater_TrackingUser; Model.Skinning.KinematicsProviders[0] = updater; Model.Transformer.Position += new Vector3(0, 0, -30); #endif #endregion _sccContext.WorldSpace.AddResource(Model); Motion_Load.Enabled = true; isPlaying = true; } }
//①Form.OnLoadをオーバーライドする。 protected override void OnLoad(EventArgs e) { base.OnLoad(e); //The RenderForm Initializes the 3D space within the OnLoad for the base.OnLoadがOnLoad内で一番初めに呼ぶべきである。 //The file open dialog OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { //OK if the return value of the dialog to model loading process //②モデルを読み込む PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);//MMDModel MMDModelWithPhysics.OpenLoad(string ファイル名,RenderContext);となっています //Possible to disable physics if you write the following in the load //MMDModel model=MMDModel.OpenLoad(ofd.FileName, RenderContext); //RenderContext is required to draw the camera or device information, including 3D variable。RenderFormを継承している場合、メンバー変数として利用可能である。 //To request the value of RenderContext DirectX11 device information to hold a basically loads, such as those that require a lot。 //③ワールド空間にモデルを追加する WorldSpace.AddResource(model); //WorldSpace shows the 3D space to draw on this form.。ここにモデルなど(IDrawableを実装している)ものを渡すと、描画してくれる。 //WorldSpace is a ScreenContext.WorldSpaceと常に等しい。ウィンドウごとに必要な3DCG描画に必要な情報はScreenContextに保管されている。 } }
private void loadModel_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog(this) == DialogResult.OK) { model = PMXModelWithPhysics.OpenLoad(ofd.FileName, renderControl1.RenderContext); renderControl1.WorldSpace.AddResource(model); } }
private void Add2ChildForm_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, childForm.RenderContext); //RenderContext pass here are common in childForm form1 so good either childForm.WorldSpace.AddResource(model); } }
private void Add2ChildForm_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, childForm.RenderContext); //ここで渡すRenderContextはform1とchildFormで共通しているのでどちらでも良い childForm.WorldSpace.AddResource(model); } }
public void TestLoadmodel() { var form = new RenderForm(); RenderContext Context = new RenderContext(); ScreenContext _scContext = Context.Initialize(form); PMXModel Model = PMXModelWithPhysics.OpenLoad(@"C:\Users\ZhiYong\Documents\CodeBase\mmflex\debug\1.pmx", Context); Model.Transformer.Position = new Vector3(0, 0, 0); _scContext.WorldSpace.AddResource(Model); _scContext.Dispose(); Model.Dispose(); Context.Dispose(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext); WorldSpace.AddResource(model); //②ボーン、モーフの編集用に作成したサンプルのGUIを表示する TransformController controller=new TransformController(model); controller.Show(this); } }
public PlayerContext(GameContext context, int index) { Context = context; this.PlayerIndex = index; ViewForm = new PlayerViewForm(context.RenderContext); currentScene = new StartScreenScene(Context, this); ViewForm.Show(); //TODO キャラクターのファクトリクラスの作成など PlayerModel = PMXModelWithPhysics.OpenLoad("mona-.pmx", context.RenderContext); runMotion = PlayerModel.MotionManager.AddMotionFromFile("run.vmd", false); PlayerModel.MotionManager.ApplyMotion(runMotion); EyeTextureRenderer = new OculusDisplayRenderer(context.RenderContext, context.GameWorld, 0, context.OculusManager, this); ViewForm.WorldSpace.AddResource(EyeTextureRenderer); context.GameWorld.AddResource(PlayerModel); }
private void Add2Child_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "PMX file of the target to open"; ofd.Filter = "PMX model file (*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { if (this.Model != null) { this._sccContext.WorldSpace.RemoveResource(this.Model); } this.Model = PMXModelWithPhysics.OpenLoad(ofd.FileName, this.Context); this.Model.Transformer.Position = new Vector3(0, 0, 0); this._sccContext.WorldSpace.AddResource(this.Model); this.Motion_Load.Enabled = true; this.IsPlaying = true; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //②-A 描画に利用するリソースの初期化 textFormat = SpriteBatch.CreateTextformat("Meiriyo", 30, FontWeight.Bold); //Specify the text format alignment do。 textFormat.Format.ParagraphAlignment = ParagraphAlignment.Center; //Vertical alignment。Center:中央、Near:上、Far:下 textFormat.Format.TextAlignment = TextAlignment.Center; //Horizontal alignment。Center:中央、Near:左、Far:右 colorBrush = SpriteBatch.CreateSolidColorBrush(Color.OrangeRed); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "ビットマップファイル(*.bmp)|*.bmp|PNGファイル(*.png)|*.png|JPGファイル(*.jpg)|*.jpg|すべてのファイル(*.*)|*.*"; if (ofd.ShowDialog(this) == DialogResult.OK) { bitmap = SpriteBatch.CreateBitmap(ofd.FileName); } else { Close(); } /* * 画面がリサイズされた時などには、SpriteBatchが自動的にリサイズされる。 * この時、リソースも作り直す必要性があるためSpriteBatch.Create~~として取得できるD2DSprite~~は自動的に * リサイズ時などに同じ設定で再作成される。 * ただし、すべてのDirectWriteに利用するクラスについてこれは実装を完了していない。 */ OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Filter = "PMXモデルファイル(*.pmx)|*.pmx"; if (ofd2.ShowDialog(this) == DialogResult.OK) { WorldSpace.AddResource(PMXModelWithPhysics.OpenLoad(ofd2.FileName, RenderContext)); } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); //② 使い方は今までのサンプルとほとんど同じだが、Renderメソッドなどを呼び出す必要性はない。 //Also, you need to override WPFRenderControl if the RenderContext is created automatically, but this is disgusting。 //The initialization, such as recommended in the OnInitialized RenderControl.Background = new Color4(1, 0, 0, 1); BasicGrid grid = new BasicGrid(); grid.Load(RenderControl.RenderContext); RenderControl.WorldSpace.AddResource(grid); RenderControl.TextureContext.CameraMotionProvider = new WPFBasicCameraControllerMotionProvider(this); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderControl.RenderContext); RenderControl.WorldSpace.AddResource(model); } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); //② 使い方は今までのサンプルとほとんど同じだが、Renderメソッドなどを呼び出す必要性はない。 //また、RenderContextは自動的に作成されるが、これが嫌な場合はWPFRenderControlをオーバーライドする必要がある。 //初期化などはOnInitializedで行うことがおすすめ RenderControl.Background = new Color4(1, 0, 0, 1); BasicGrid grid = new BasicGrid(); grid.Load(RenderControl.RenderContext); RenderControl.WorldSpace.AddResource(grid); RenderControl.TextureContext.CameraMotionProvider = new WPFBasicCameraControllerMotionProvider(this); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderControl.RenderContext); RenderControl.WorldSpace.AddResource(model); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx"; if (ofd.ShowDialog() == DialogResult.OK) { PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext); //Establishment of preclusion to load dialog OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd"; if (ofd2.ShowDialog() == DialogResult.OK) { //OK if the return value of the dialog to model loading process //①モーションファイルを読み込む IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true); //Add the models for which you want to apply the motion Manager。 //IMotionProvider AddMotionFromFile(string ファイル名,bool すべての親ボーンを無視するかどうか); //Walking motion as the second argument to ignore the motion of all parent bones when you want to programmatically specify the movement itself, the //Move the entire model is in motion to prevent。 //②モーションファイルをモデルに対して適用する。 model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay); //Whether or not the second argument, replaying plays frame numbers begin to play, and the third argument is。 //If you leave without replay is Yctionyftermotion..Nothingを指定する //オマケ //(1) モーションをとめるときは? //model.MotionManager.StopMotion();と記述すれば止まります //(2) 現在何フレーム目なの? //model.MotionManager.CurrentFrameによって取得できます。 } WorldSpace.AddResource(model); } }