开发者

Backface culling with Molehill

Using Flash 11 RC1 with the new Molehill API, I would like to enable backface culling. The beta documentation is pretty vague, but the example implies Molehill wants front-facing triangles to wind counter-clockwise, which is pretty normal.

But when my polygons wind counter-clockwise, I get the exact opposite behavior - in other words, it's as if contrary to its own examples Molehill expects front-facing triangles to wind clockwise. Since the documentation never explicitly states which winding is correct, I am stumped.

I don't want to just flip all my triangles around until it looks right before I am 100% on what Molehill actually wants, since that has a fair chance of hiding a fundamental misunderstanding.

I am using simple perspective pro开发者_如何学Pythonjection (a note regarding .transpose() below: because copyRawDataFrom expects data in column-major order, and I hated the way that looked in code, I decided to just enter it row-major and transpose the matrix afterwards - so sue me :P):

        var y:Number = 1.0 / Math.tan(pFOV / 2.0);
        var x:Number = y / pAspectRatio;
        _projectionMatrix.copyRawDataFrom(new<Number>[
                x       , 0        , 0                       , 0,
                0       , y        , 0                       , 0,
                0       , 0        , pFar/(pNear-pFar)       , pFar*pNear/(pNear-pFar),
                0       , 0        , -1                      , 0
            ]);
        _projectionMatrix.transpose();

Any clues?


You can use Context3D.setCulling to change the backface culling in molehill. See: http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/display3D/Context3D.html#setCulling()

Which side is front or back depends on your model input data, so trial and error is really yur best bet here. There are only two options :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜