如何变形图像? [英] how to deform image?

查看:121
本文介绍了如何变形图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友
我想做一个简单的游戏应用程序用户点击汽车并且从那一点开始汽车休息意味着当用户点击汽车图像时图像变形很小。我知道使用大量图像可以实现一切,并在用户点击汽车图像时获得更改,但我不想使用这么多图像。

Hi Friends I Want to make a simple gaming Application in which the user hit the car and car breaks from that point means the image get little deformed when the user hit the car image. I know everything could be possible with using of lots of images and get change when user hit that car image but i don't want to use so many images.

是否有任何解决方案,我怎样才能使图像变形..对我的英语有所帮助但是,在这里我粘贴了一个关于flash的游戏链接是我真正想要的..

is there any solution for this , how can i deform the image ..sorry for my English but , here i paste a link of the game that is on flash and this is what i exactly want..

http://www.playgecogames.com/file.php?f=657&a=popup

请尽快回复
谢谢

please respond soon thanks

推荐答案

您不会说这是2D或3D,还是您要使用的技术。

You don't say if this is in 2D or 3D, or what techniques you're going to use.

如果您使用OpenGL实现游戏,那么它非常简单。对象可以由常规网格组成,图像作为映射到网格的纹理。当用户点击对象时,你只需要变形网格。

If you're implementing the game using OpenGL, it's fairly straightforward. The object can be made up of a regular mesh, with the image as a texture mapped to the mesh. When the user hits the object, you just deform the mesh.

一个简单的方法是在命中方向上取一个向量,用最接近的顶点移动一个向量。与撞击力成比例的量,然后扇出以使网格的其余部分变形减少量。通过变形网格,图像纹理将呈现您喜欢的所有凹痕或变形。

A simple method would be to take a vector in the direction of the hit, displace the nearest vertex by an amount proportional to the force of the strike, and then fan out in to deform the rest of the mesh in decreasing amounts. By deforming the mesh, the image texture will be rendered with all the dents or deformations you like.

如果您想要在没有OpenGL和直接图像的情况下进行此操作,您可以使用图像重新采样来模拟效果。您有原始的原始图像,经过过滤以构成生成的图像。起初没有变形,因此您逐字复制原始图像。每次用户点击对象时,您都可以在感兴趣的本地区域内使用过滤器或变换添加变形。此函数会以扭曲的方式重新采样源图像,使其看起来像是对象已损坏。

If you want to to this without OpenGL and just straight images, you could use image resampling to simulate the effect. You have your original pristine image which is 'filtered' to make up the resulting image. At first there are no deformations so you copy the original image verbatim. Each time the user hits the object, you can add a deformation using a filter or transform within a local region of interest. This function would resample the source image in a distorted manner, causing it to look like the object is damaged.

如果你查看一些关于游戏开发的好书,你会'我会找到很多对象碰撞,变形等方法。

If you look up some good books on game development, you'll find a great range of approaches to object collisions, deformations and so on.

这篇关于如何变形图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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