本文整理汇总了C#中Sledge.Editor.Documents.Document.Snap方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Snap方法的具体用法?C# Document.Snap怎么用?C# Document.Snap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sledge.Editor.Documents.Document
的用法示例。
在下文中一共展示了Document.Snap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTransformationMatrix
public override Matrix4? GetTransformationMatrix(Viewport2D viewport, ViewportEvent e, BaseBoxTool.BoxState state, Document doc)
{
var shearUpDown = state.Handle == BaseBoxTool.ResizeHandle.Left || state.Handle == BaseBoxTool.ResizeHandle.Right;
var shearTopRight = state.Handle == BaseBoxTool.ResizeHandle.Top || state.Handle == BaseBoxTool.ResizeHandle.Right;
var nsmd = viewport.ScreenToWorld(e.X, viewport.Height - e.Y) - state.MoveStart;
var mouseDiff = SnapIfNeeded(nsmd, doc);
if (KeyboardState.Shift)
{
mouseDiff = doc.Snap(nsmd, doc.Map.GridSpacing / 2);
}
var relative = viewport.Flatten(state.PreTransformBoxEnd - state.PreTransformBoxStart);
var shearOrigin = (shearTopRight) ? state.PreTransformBoxStart : state.PreTransformBoxEnd;
var shearAmount = new Coordinate(mouseDiff.X / relative.Y, mouseDiff.Y / relative.X, 0);
if (!shearTopRight) shearAmount *= -1;
var shearMatrix = Matrix4.Identity;
var sax = (float)shearAmount.X;
var say = (float)shearAmount.Y;
switch (viewport.Direction)
{
case Viewport2D.ViewDirection.Top:
if (shearUpDown) shearMatrix.M12 = say;
else shearMatrix.M21 = sax;
break;
case Viewport2D.ViewDirection.Front:
if (shearUpDown) shearMatrix.M23 = say;
else shearMatrix.M32 = sax;
break;
case Viewport2D.ViewDirection.Side:
if (shearUpDown) shearMatrix.M13 = say;
else shearMatrix.M31 = sax;
break;
}
var stran = Matrix4.CreateTranslation((float)-shearOrigin.X, (float)-shearOrigin.Y, (float)-shearOrigin.Z);
var shear = Matrix4.Mult(stran, shearMatrix);
return Matrix4.Mult(shear, Matrix4.Invert(stran));
}
示例2: SnapIfNeeded
protected static Coordinate SnapIfNeeded(Coordinate c, Document doc)
{
return doc.Snap(c);
}