开发者

From Rectangle into trapezoid

开发者_Go百科

how can i transform rectangle into trapezoid with ActionScript3

my trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).

 _____________
|  |     |   |
|  |_____|   |
|  /      \  |
| / trapez.\ |
|/__________\|


It depends on how the "rectangle" is represented in your program. Few options:

  1. If your rectangle is vector, and you have access to the anchor points:

    ---> o------o <---
         |      |
         |      |
         o------o
    

    Becomes:

           o--o
          /    \
         /      \
         o------o
    

    Simply translate the two top points and condense them to each other.

  2. If that 'rectangle' is actually a DisplayObject, you will need to 'stitch' two of the same DisplayObject to create a new one. This page has examples of what you want along with example code.

  3. Another option would be to use Papervision3D - which is using the above rendering method as a base.

  4. This one's a bit tricky, but it's an option. You can use displacement maps as described here. The code is AS2, but it should be fairly simple to "port".


EDIT

As par this answer, I suggest you use Papervision3D (see 3rd option) to do that, as you might want to move the camera around the "room". It will also take care of the other walls as well.


the idea is to divide it into triangles and then perform an affine transformation (using Matrix) on them ... senocular provided sample code (for AS2) ...

there's also a handful of libs online, but I can't find any right now ...


If you're targetting FlashPlayer 10 you can do it by rotating the clip's rotation values, see This post form Mike Chambers for details.

Otherwise you're going to need a 3D engine like Papervision. There's no simple way to do non-affine transformations in Flash Player 9.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜