Having some trouble implementing D3DXComputeNormals... any hints/advice?

Misha Koshelev misha680 at gmail.com
Mon Jul 12 18:11:02 CDT 2010


On Mon, 2010-07-12 at 22:54 +0200, Henri Verbeet wrote:
> On 12 July 2010 22:43, Misha Koshelev <misha680 at gmail.com> wrote:
> > Thank you Henri for the explanation. In fact it seems that this flag is
> > default on D3DXComputeTangentFrameEx:
> >
> >        D3DXTANGENT_WEIGHT_BY_AREA
> >                Weight the direction of the computed per-vertex normal
> >                or partial derivative vector according to the areas of
> >                triangles attached to that vertex. Mutually exclusive
> >                with D3DXTANGENT_WEIGHT_EQUAL.
> >
> Actually, looking at the docs for D3DXComputeTangentFrameEx() a bit
> more closely, it says in the description for dwOptions that if neither
> D3DXTANGENT_WEIGHT_BY_AREA nor D3DXTANGENT_WEIGHT_EQUAL is specified
> it does indeed weight the normals by the the angle of the outgoing
> edges for that face.

Henri:

I love your polite way of saying RTFM ;)

Anyway you are correct, I have made a patch:
http://github.com/misha680/wine/commit/f199b0fba2cdfb2b0987d1b9fac73f39762220bc

Next steps I believe are:
* Add tests for D3DXCreateCylinder with unequal radii
* Implement D3DXCreateCylinder
* Implement D3DXComputeNormals

One minor note about the patch - the compute_normal function is adapted
from a book, which I have credited in a comment


/*
 * Adapted from pg. 246, Frank D Luna, "Introduction to 3D Game
Programming with Direct X 9.0c:
 * A Shader Approach (Wordware Game and Graphics Library) [Paperback],"
2006.
 */

The function differs from the book in the:
* name
* parameters all on one line rather than separate lines (minor)
* use of D3DXVec3Subtract rather than operator- (only available in C++ I
believe)
* name of output parameter is normal vs out

I believe this should be okay for inclusion of this function. Plus it is
quite basic. However, if this is not ok let me know (I honestly can't
imagine such a case though...)

Misha





More information about the wine-devel mailing list