如何在JavaFX中使用鼠标绘制或绘制网格,然后可以对其进行纹理处理和变形? [英] How to draw or plot a mesh using the mouse in JavaFX which can then be textured and deformed?

查看:275
本文介绍了如何在JavaFX中使用鼠标绘制或绘制网格,然后可以对其进行纹理处理和变形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中实现一个工具.该工具将允许用户使用鼠标绘制三角形网格.我到处都在寻找实现此目的的方法,教程,示例等,但都没有成功.我已经看到 FXyz库,但这并不能真正模拟我要完成的工作.该程序的目标如下所示:

I am trying to implement a tool into my application. the tool would allow the user to plot a triangle meshes using the mouse. I have looked everywhere for a way to do this, tutorials, examples, etc and have not been successful. I have seen the FXyz library but that does not really simulate What I am trying to accomplish. The goal of the program looks as follows:

用例序列:

  1. 用户将png图像添加到3D场景中或使用鼠标将其拖动到3D场景中.

  1. The user adds a png image to the 3D scene or drags it into the 3D scene using the mouse.

一旦显示了图像,用户便可以在图像周围绘制网格.

Once the image is being displayed the user would then be able to plot a mesh around the image.

用户完成绘制网格后.必须有一种方法可以将网格覆盖的图像作为纹理添加到网格.添加为纹理后,图像应看起来相同.这太难了还是超出了JavaFX可以实现的范围?

Once the user has finished plotting the mesh. There would have to be a way to add the image being overlayed by the mesh as a texture to the mesh. The image should look the same after being added as a texture. Is this too hard or beyond the scope of what can be achieve in JavaFX?

从理论上讲,可以将网格的顶点拖动到可拖动的点,然后将变换成功应用于纹理.这可能吗?

Theoretically It would then be possible to drag the vertices of the mesh at draggable points and successfully applying transformations to the texture. Would this be possible?

显示我要实现的目标的图像

如您所见,可能在绘制网格后,可以拖动连接顶点的点,以操纵或变换网格的形状.如果网格上有纹理.图像还能变形吗?

As you can see maybe after plotting the mesh the points connecting the vertices can be dragged in order to manipulate or transform the shape of the mesh. If the mesh has a texture over it. would the image then also transform ?

使用 TriangleMesh可以做到吗? JavaFX所具有的类,但那里几乎没有什么类,它解释了如何使用它以及这些点,面点和纹理点如何工作.非常令人困惑的=(.

Would this be possible with the TriangleMesh class that JavaFX has which by the way there is very little out there which explains how to use it and how the points, face points and texture points work. Very confusing =(.

目标最终结果

我的问题是,上图所示的操作类型是否可以在JavaFX中使用?可以使用 TriangleMesh来实现这种功能类还是JavaFX中的其他类似类?正如您所看到的,我真正要实现的是图像处理,如果您知道还有其他更好的方法,将不胜感激.

My question is would the type of manipulation shown in the image above be possible in JavaFX? Can this sort of functionality be achieved using the TriangleMesh class or other similar class in JavaFX ? As you can see what I am trying to achieve is really image manipulation I would appreciate knowing if there is another better way to do this.

很遗憾,我没有可以共享的任何代码.我似乎无法对此任务发表任何意见.我不要求提供代码或要求有人为我解决问题.我只是想看看如何将示例引导到正确的方向,以了解如何做到这一点,或者我是否应该放弃它!

I unfortunately do not have any code I can share. I just cant seem to produce any regarding this task. I am not asking to be given code or for someone to solve the problem for me. I just want to see examples be guided into the right direction on how to do this and to know if it is even possible or should I just give up on it!

如果您已读过本文,非常感谢您的宝贵时间.

推荐答案

我已经读完您的问题了:-)与这里的许多人相比,您至少提供了关于要实现的目标的清晰描述.根据我自己的经验,我想说,使用JavaFX可以轻松实现您想做的事情,而MeshView就是您的理想之选. 您可以将图像用作该网格的纹理,并且可以通过操纵该网格的顶点来使图像变形.我已经为一个项目自己实现了部分功能,所以我知道它可以工作.

I have read your question till the end :-) In contrast to many people here you are at least providing a clear description of what you want to achieve. According to my own experience I would say that what you want to do is easily possible with JavaFX and the MeshView is the way to go here. You can use your image as the texture for this mesh and you can distort the image by manipulating the vertices of this mesh. I have implemented part of your functionality myself for a project so I know that it works.

这篇关于如何在JavaFX中使用鼠标绘制或绘制网格,然后可以对其进行纹理处理和变形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆