BlackBerry - 图像 3D 转换 [英] BlackBerry - image 3D transform

查看:24
本文介绍了BlackBerry - 图像 3D 转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用 drawTexturePath:

int displayWidth = Display.getWidth();
int displayHeight = Display.getHeight();
int[] x = new int[] { 0, displayWidth, displayWidth, 0 };
int[] x = new int[] { 0, 0, displayHeight, displayHeight };
int angle = Fixed32.toFP( 45 );
int dux = Fixed32.cosd(angle );
int dvx = -Fixed32.sind( angle );
int duy = Fixed32.sind( angle );         
int dvy = Fixed32.cosd( angle );       
graphics.drawTexturedPath( x, y, null, null, 0, 0, dvx, dux, dvy, duy, image);

但我需要的是带有 3d 变换的简单图像的 3d 投影(类似于这个)

but what I need is a 3d projection of simple image with 3d transformation (something like this)

你能告诉我如何用 drawTexturedPath 做到这一点吗(我几乎可以肯定这是可能的)?
有其他选择吗?

Can you please advice me how to do this with drawTexturedPath (I'm almost sure it's possible)?
Are there any alternatives?

推荐答案

此函数使用的方法(2 个步行向量)与用于著名的 'rotozoomer' 效果的 oldskool 编码技巧相同.rotozoomer 示例视频

The method used by this function(2 walk vectors) is the same as the oldskool coding tricks used for the famous 'rotozoomer' effect. rotozoomer example video

此方法是旋转、缩放和倾斜图像的一种非常快速的方法.旋转只是通过旋转步行向量来完成的.缩放只是通过缩放步行向量来完成的.倾斜是通过相对于彼此旋转步行向量来完成的(例如,它们不再形成 90 度角).

This method is a very fast way to rotate, zoom, and skew an image. The rotation is done simply by rotating the walk vectors. The zooming is done simply by scaling the walk vectors. The skewing is done by rotating the walkvectors in respect to one another (e.g. they don't make a 90 degree angle anymore).

任天堂在他们的 SNES 中制作了硬件,以便在任何精灵和/或背景上使用相同的效果.这让位于一些非常酷的效果.

Nintendo had made hardware in their SNES to use the same effect on any of the sprites and or backgrounds. This made way for some very cool effects.

这种技术的一大缺点是不能透视地扭曲纹理.要做到这一点,每一条新的水平线,步行向量都应该稍微改变.(没有图很难解释).

One big shortcoming of this technique is that one can not perspectively warp a texture. To do this, every new horizontal line, the walk vectors should be changed slightly. (hard to explain without a drawing).

在 snes 上,他们通过改变每条扫描线的步行向量来克服这一点(在那些日子里,当显示器绘制任何扫描线时,可以设置中断).这种模式后来被称为 MODE 7(因为它表现得像一种新的虚拟图形模式).使用这种模式的最著名的游戏是马里奥赛车和 F-zero

On the snes they overcame this by altering every scanline the walkvectors (In those days one could set an interrupt when the monitor was drawing any scanline). This mode was later referred to as MODE 7 (since it behaved like a new virtual kind of graphics mode). The most famous games using this mode were Mario kart and F-zero

所以为了让这个在黑莓上工作,你必须绘制你的图像displayHeight"次(例如,每次图像的一个扫描线).这是达到预期效果的唯一方法.(这无疑会降低性能,因为您现在使用新值多次调用 drawTexturedPath 函数,而不仅仅是一次).

So to get this working on the blackberry, you'll have to draw your image "displayHeight" times (e.g. Every time one scanline of the image). This is the only way to achieve the desired effect. (This will undoubtedly cost you a performance hit since you are now calling the drawTexturedPath function a lot of times with new values, instead of just one time).

我想通过一些谷歌搜索,您可以找到一些公式(甚至是实现)如何计算不同的步行向量.用一点纸(考虑到你的数学不太差)你也可以自己推断出来.当我为 Gameboy Advance 制作游戏时,我自己也做过,所以我知道这是可以做到的.

I guess with a bit of googling you can find some formulas (or even an implementation) how to calc the varying walkvectors. With a bit of paper (given your not too bad at math) you might deduce it yourself too. I've done it myself too when I was making games for the Gameboy Advance so I know it can be done.

一定要预先计算一切!速度就是一切(尤其是在手机等慢速机器上)

Be sure to precalc everything! Speed is everything (especially on slow machines like phones)

为你做了一些谷歌搜索.这里详细解释了如何创建mode7效果.这将帮助您使用 Blackberry 功能实现相同的目标.模式 7 实施

did some googling for you. Here's a detailed explanation how to create the mode7 effect. This will help you achieve the same with the Blackberry function. Mode 7 implementation

这篇关于BlackBerry - 图像 3D 转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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