示例#1
0
        public void SetMyPmx()
        {
            int allfacecount = 0;

            foreach (IPXMaterial mat in pmx.Material)
            {
                allfacecount += mat.Faces.Count;
            }
            message.LabelReflesh("モデル読み込み");
            message.StatusBar.Value = 0;
            message.Visible         = true;
            this.VertexArray        = new CustomVertex.PositionOnly[pmx.Vertex.Count];
            this.IndexArray         = new int[allfacecount * 3];
            this.Exmaterials        = new ExtendedMaterial[pmx.Material.Count];
            this.AttributeRanges    = new AttributeRange[pmx.Material.Count];
            this.IsUsedinMat        = new bool[pmx.Material.Count, pmx.Vertex.Count];

            //VertexArray
            SetVertex();

            //IsUsedMat
            //IndexArray
            SetFaces(allfacecount);

            //AttributeRanges
            //Exmaterials
            SetMaterial();
        }
示例#2
0
        /// <summary>
        /// 初期化とループ開始
        /// </summary>
        public void Run()
        {
            //メッセージフォームを作成
            message.Show();
            message.StatusText = "フォーム作成中";

            #region 基本イベント追加
            message.LabelReflesh("イベント追加中");

            form.ResizeBegin += (o, args) =>
            {
                this.ResourceDispose();
            };

            form.ResizeEnd += (o, args) =>
            {
                pps[0].BackBufferWidth  = form.ViewPanel.Width;
                pps[0].BackBufferHeight = form.ViewPanel.Height;
                Viewport vp = device.Viewport;
                vp.Height       = form.ViewPanel.Height;
                vp.Width        = form.ViewPanel.Width;
                device.Viewport = vp;
                device.Reset(pps);
                this.SetTextures();
                this.OnResourceLoad();
                this.Render();
            };

            form.Closed += (o, args) => { this.Dispose(); };

            form.SelectedMaterial.SelectedIndexChanged += (o, args) =>
            {
                this.vS.SelectedMaterial = this.form.SelectedMaterial.SelectedIndex;
                if (this.form.TabControll.SelectedIndex == 0)
                {
                    this.vS.selectedVertexIndex = new int[0];
                }
                this.Render();
            };

            form.UnDo.Click += (o, args) =>
            {
                this.form.Undo(this.mypmx);
                ResetMeshVertex();
                ResetSelectedBuffer();
                this.Render();
            };
            form.ReDo.Click += (o, args) =>
            {
                this.form.Redo(this.mypmx);
                ResetMeshVertex();
                ResetSelectedBuffer();
                this.Render();
            };
            form.SelectAll.Click += (o, args) =>
            {
                if (this.form.TabControll.SelectedIndex == 1)
                {
                    return;
                }
                List <int> tmpselectedlist = new List <int>();
                for (int i = 0; i < mypmx.VertexArray.Length; i++)
                {
                    bool contained = mypmx.IsUsedinMat[vS.SelectedMaterial, i];
                    if (contained)
                    {
                        tmpselectedlist.Add(i);
                    }
                }
                vS.selectedVertexIndex = tmpselectedlist.ToArray();
                ResetSelectedBuffer();
                this.Render();
            };

            CreateMouseEvent(form.ViewPanel);
            KeyBoardEvent.GetInstance().CreateInputEvent(form.ViewPanel);

            form.ReceiveSelectedButton.Click += (o, args) =>
            {
                this.vS.selectedVertexIndex = this.mypmx.ReceiveSelected(host.Connector, vS.SelectedMaterial);
                ResetSelectedBuffer();
                this.Render();
            };

            form.SendSelectedButton.Click += (o, args) =>
            {
                this.mypmx.SendSelected(host.Connector, this.vS.selectedVertexIndex);
            };

            form.ReceiveModelButton.Click += (o, args) =>
            {
                this.ResourceDispose();
                this.mesh.Dispose();
                this.form.SelectedMaterial.Items.Clear();
                this.mypmx.ReceiveModel(host.Connector);
                this.ConvertMyPMXtoMesh();
                this.SetTextures();
                this.vS.selectedVertexIndex = new int[0];
                ResetSelectedBuffer();
                this.uvmorphes.ReSetUVList(host.Connector, form);
                this.Render();
            };

            form.SendModelButton.Click += (o, args) =>
            {
                this.mypmx.SendModel(host.Connector);
            };

            form.MoveButton.Click  += (o, args) => { DrivingMode.Move.GetInstance().ButtonClicked(this, this.form.MoveValue); };
            form.ScaleButton.Click += (o, args) => { DrivingMode.Scale.GetInstance().ButtonClicked(this, this.form.ScaleValue, this.form.CenterValue); };
            form.RotButton.Click   += (o, args) => { DrivingMode.Rotate.GetInstance().ButtonClicked(this, this.form.RotValue, this.form.CenterValue); };

            form.ReadMorph.Click += (o, args) =>
            {
                this.uvmorphes.ReadMorph(host.Connector, this.mypmx, this.vS, form);
                this.form.MorphSlider.Value = this.form.MorphSlider.Maximum;
                ResetMeshVertex();
                ResetSelectedBuffer();
                Render();
            };
            form.SetMorph.Click += (o, args) =>
            {
                this.uvmorphes.MakeMorph(host.Connector, this.mypmx, this.vS, form);
                this.form.MorphSlider.Value = this.form.MorphSlider.Maximum;
                ResetMeshVertex();
                ResetSelectedBuffer();
                Render();
            };
            form.AddMorph.Click     += (o, args) => { this.uvmorphes.AddMorph(host, form); };
            form.MorphSlider.Scroll += (o, args) =>
            {
                float ratio = ((float)form.MorphSlider.Value) / form.MorphSlider.Maximum;
                this.uvmorphes.MoveMorph(mypmx, ratio);
                ResetMeshVertex();
                ResetSelectedBuffer();
                Render();
            };
            # endregion