开发者

3d maths in Flash AS3

开发者 https://www.devze.com 2022-12-08 19:49 出处:网络
I\'m trying to code a 3d wall like http://www.flashloaded.com/flashcomponents/3dwall/ The shape I am looking to create is like a bath or arena where it is a curve cornered rectangle with sloping side

I'm trying to code a 3d wall like http://www.flashloaded.com/flashcomponents/3dwall/

The shape I am looking to create is like a bath or arena where it is a curve cornered rectangle with sloping sides.

The image below shows what i'开发者_C百科m trying to achieve if viewed from above. I hope that helps.

3d maths in Flash AS3

Can anyone give me some ideas on the maths to create this shape using primitive rectangle shapes.

Thanks, Josh


http://en.wikipedia.org/wiki/Matrix_multiplication

http://en.wikipedia.org/wiki/Transformation_matrix

http://www.devmaster.net/wiki/Transformation_matrices

A rectangle has 4 3D points (vectors)

Define a vector this way

3d maths in Flash AS3

To move/rotate/scale just multiply each vector by the transformation matrix.

This matrix rotates around X-axis:

3d maths in Flash AS3

For perpective projection (camera) look at: http://en.wikipedia.org/wiki/3D_projection

For example: you can create rectangles and rotate them around an axis to create a cylinder like this:

3d maths in Flash AS3


(source: flashloaded.com)

your pit:
note: the angle is not correct, it should be pi-a (180º-a)

3d maths in Flash AS3

create all rectangles centered at origin (0,0,0), then rotate them as needed and move to desired position. I recommend you to code the matrix routines first like rotate(), move(), scale() and a simple paint function (just line drawing, without perspective) the rest is just playing with the matrices.

0

精彩评论

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