原文链接: http://www.iforce2d.net/forums/viewtopic.php?f=8&t=142

"Snap to grid" is scoring quite high in the feature voting. I am starting to think about ways to implement it, but since the item types in a Box2D scene are quite different, there does not seem to be any one specific way to handle them all. I'm wondering if people who have something specific in mind could comment here about what would help them out. Mainly I'm looking for people who have actually come across this issue in real situations in the past, rather than a general brainstorm.

Firstly the grid dimensions would need to be defined, which would go in the scene settings dialog, with x,y sizes for grid cells, for each edit mode (body, fixture, vertex, image, joint).

For some edit modes it seems quite straightforward, eg. for bodies, joints and vertices, I guess the position of the body/anchor/vertex could snap to the grid. For fixtures and images though it's not so simple. There does not seem to be any obvious way to align these with a grid, especially fixtures which are not even restricted to being rectangular. Any comments about this would be appreciated.

"Snap to grid"可以翻译成非连续的变换或者网格对齐,它在功能投票中拥有很高的分数,然后我就开始思考着怎么去实现它,但是在box2d中不同类型组件之间是相当不同的,好像没有一个很好的办法去处理所有的组件,我希望大家可以在这里讨论一下,怎么样用最好的方法来实现它,我也期盼有人在以前的软件开发中也碰到过这样相同的问题并且解决了它,这样比来一次头脑风暴更好。

首先,格子的尺寸需要被在【scene settings】对话框中被定义,用x,y尺寸来定义一个单元格,并且适用于所有的编辑模式。

在一个编辑模式下它可以很直接,例如在刚体关节和顶点模式下可以非连续变换,但是在夹具跟图片模式下,它就不那么简单了,这里没有一个明显有效的方法来排列它们,特别是夹具,它是不必限制为一个矩形的。

My understanding of snap to grid is simply that whatever you're dragging gets snapped to a grid point. Whether it's fixture vertices, bodies or joints, I don't see what the difference is?

I use this feature in Box2d Body Editor for creating large static fixtures for levels, e.g. mazes. I use arbitrarily shaped polygons but often need various points from different fixtures to line up along the same x/y plane. Without snap to grid, the only way to align them is manually setting the location in the Property panel.

Can you not implement it globally as a modifier to the mouse x/y coordinates if snap to grid is on?

我理解的非连续性变换是相当简单的,各种组件之间没有太大的区别。

我在刚体编辑模式下用这个功能去创建一个大的静态夹具,例如迷宫,我用任意形态的多边形但是经常需求跟另外的夹具在x/y轴做对齐操作,如果没有非连续性变换这个操作,就只有用手工设置它的变换属性

你可以不要把它做为一个全局的调节器来执行么?

The difference is that a body is a single point, which is easy and intuitive to snap to a grid, while a fixture can have hundreds of points.
Take this for example:

它们的区别在于:刚体只是一个单个的点,很简单直观地进行非连续性变换,但是一个夹具刚有成千上万个顶点

就像下面的例子:

It's all very well to say "just snap it to the grid" but how exactly? The only way I can think of is to have every point of the fixture checking for the closest grid-line to itself, and then choose the closest among them. Seems like a reasonable solution, but I was wondering if there was a better way.

You say that you line fixtures up along the same x/y plane... does this involve rotating them? Are we still talking about a grid, or are they being snapped to the position of other fixtures?

Yes, it would be implemented as a modifier to the mouse coordinates.

“非连续性变换”说起来简单,但是到处要怎么做呢?我能想到的唯一办法是让所有的夹具顶点检测它最近的网格线,然后选择离它们最近的那线,好像是一个有效的解决办法,但是我期望有一个更好的办法

你说的用x/y轴来对齐夹具,但是这样貌似不适用于旋转,我们不再是讨论一个网格,而是讨论对齐到一个夹具顶点

是的,它是要被执行成一个鼠标坐标调节器

Ideas for Snap to grid相关推荐

  1. arkit技术介绍_面向移动AR的触觉技术:如何以“触摸”感增强ARKit应用

    arkit技术介绍 by Neil Mathew 通过尼尔·马修(Neil Mathew) 面向移动AR的触觉技术:如何以"触摸"感增强ARKit应用 (Haptics for m ...

  2. RoI Pooling 与 RoI Align 有什么区别?

    ↑ 点击蓝字 关注视学算法 作者丨AlexChung@知乎 来源丨https://zhuanlan.zhihu.com/p/161540817 编辑丨极市平台 基本概念 RoI RoI(Region ...

  3. Delphi Form Designer (窗体设计器)之四

    对齐组件 不管Snap to Grid选项是否开着,在安放完组件后有时需要对齐.对齐组件是指沿某组件的边对齐几个组件,把组件放在窗体中央,或依一定距离间隔组件. 有两种方式对齐组件: 使用Alignm ...

  4. 使用Capture 制作元件库

    对于这里所说的元件库,里面就保存着用来放在原理图中的part.下面是创建元件Part的大致步骤. 1.  打开Capture CIS,File->New->Library,右击弹出的文件导 ...

  5. Delphi Form Designer (窗体设计器)之二

    选择组件 1. 选择单个组件 要选择单个组件,只要在上面点击即可.选择组件时,八个黑色大小标记符出现在组件周围以提示它被选择了.如图所示: 选择组件时Object Inspector会发生变化,以显示 ...

  6. ActiveReports 6.0 - 高效开发UI

    2019独角兽企业重金招聘Python工程师标准>>> 以往做报表相关的工作时,最害怕的是报表的UI设计工作,当遇到一个布局非常复杂的报表,往往会花上两.三天时间才能完成报表的UI设 ...

  7. GIMP - GNU 图像处理程序 用户手册

    法律提示 Permission is granted to copy, distribute and/or modify this document under the terms of the GN ...

  8. Together与Visual.Studio.NET的结合使用(三)

    通用选项: 图二十九:通用选项 Delete confirmation:此选项定义当你删除一个元素的时候是否需要进行确认. Automatically enable Together VS.NET s ...

  9. ActiveReports 9实战教程(3): 图文并茂的报表形式

    基于上面2节内容,我们搭建了AR9的开发环境,配置好了数据源.在本节,我们以官方提供的3个中文图文并茂的报表来展示AR9的功能,并通过实战的方式一一分享. 以往做报表相关的工作时,最害怕的是报表的UI ...

最新文章

  1. 公司inur php id_,PHP——个人信息管理系统
  2. Python学习路程day18
  3. 表单验证自定义二选一
  4. Java 数组中找最大值和最小值
  5. Oracle使用dblink连接SqlServer
  6. HDUOJ 1062 TEXT REVERSE
  7. Mysql主从延时解决办法
  8. 剑指offer面试题[14]-调整数组顺序使奇数位于偶数前面
  9. spring注解记录
  10. Exchange 2016之用EMS配置全局OWA语言和时区设置
  11. HCS12XEP100 ADC与SCI2的冲突解决 (2011-4-15)
  12. php微信公众号发送邮件,GitHub - DongDavid/notify: 消息发送组件-邮件、微信公众号、企业微信、小程序...
  13. linux rpm是什么意思中文,rpm是什么意思
  14. position的属性(sticky属性)
  15. 嵌入式硬件 软件测试,嵌入式系统软硬件功能测试方法及性能评估研究
  16. 【大底大顶接近预警】副图指标 分清大顶大底 轻松做波段 通达信 源码
  17. 蓝牙芯片设计看上海,终端产品找深圳
  18. matlab学习之蒙特卡罗 --渡口模型和赶火车问题(matlab编程)-----数模
  19. VAT-MART 、AdaAfford论文阅读总结
  20. html网站制作流程,网页制作过程(实际案例)

热门文章

  1. arcgis新建图层信息复制_怎么在arcgis中把一个图层复制到另一个图层上
  2. 爬虫利器 xpath 实践案例
  3. 甲骨文的CEO说 他眼里没有亚马逊和微软
  4. 一文读懂如何对混合型数据做聚类分析!
  5. windows虚拟机的一些操作
  6. 论文阅读:Adaptive Graph Convolution for Point Cloud analysis
  7. 这样设置,让你的 iPhone 用起来更加得心应手
  8. 自制FM单频道收音机
  9. 英语单词学习-8-39
  10. 关于adb出现的错误