Пример #1
0
        private void DoEdit(InputStates input)
        {
            if (!TargetVertices.Any())
            {
                return;
            }

            if (input.MouseLeft.IsStartingJust)
            {
                TargetVertices = TargetMaterial.IsSelected.Where(p => p.Value).Select(p => p.Key);
                TotalOffset    = Matrix.Identity;
                StartPos       = input.MouseLeft.Start;
            }
            if (input.MouseLeft.IsDragging)
            {
                CurrentPos = input.MouseLeft.Current;
                UpdateParameter();
                // 頂点編集のプレビュー
                // 直接頂点位置を編集するわけにはいかないので見た目だけ変換する
                TargetMaterial.TemporaryTransformMatrices *= Offset;
                TotalOffset *= Offset;

                // オフセットを得た時点で現在地点を次の初期位置扱いする
                // 評価ごとの移動量にすることで累積が可能になる
                StartPos = CurrentPos;
            }
            if (input.MouseLeft.IsEndingJust)
            {
                // コマンド生成が可能であることを申告
                IsReady = true;
                // プレビュー表示のための変換行列を初期化
                TargetMaterial.TemporaryTransformMatrices = Matrix.Identity;
            }
        }
Пример #2
0
        public void Do()
        {
            (var min, var max) = TargetVertices.Select(vtx => vtx.UV.ToVector2()).MinMax();
            var center = ((min + max) / 2).ToVector3();

            bool XorBoth = ReverseAxis != Axis.Y;
            bool YorBoth = ReverseAxis != Axis.X;

            Matrix reverser = Matrix.Invert(Matrix.Translation(center)) * Matrix.Scaling(XorBoth ? -1 : 1, YorBoth ? -1 : 1, 1) * Matrix.Translation(center);

            TargetVertices.AsParallel().ForAll(vtx => vtx.UV = Vector2.TransformCoordinate(vtx.UV, reverser));
        }
Пример #3
0
        public void MultiplyWeight(float value)
        {
            if (TargetVertices == null || TargetVertices.Count == 0)
            {
                return;
            }

            _anyConverted = new List <MDL0ObjectNode>();
            foreach (Vertex3 v in TargetVertices)
            {
                MultiplyWeight(value, v);
            }

            UpdateBindState(TargetVertices.ToArray());
        }
 public void Undo()
 {
     TargetVertices.AsParallel().ForAll(vtx => vtx.UV = PreviousUV[vtx]);
 }
 public void Do()
 {
     PreviousUV = TargetVertices.AsParallel().ToDictionary(v => v, v => v.UV.Clone());
     TargetVertices.AsParallel().ForAll(vtx => vtx.UV = Vector2.TransformCoordinate(vtx.UV, Offset));
 }