Discussion:
very basic question - tessellation and fewer vertices than I started
Misha Koshelev
2010-07-24 22:32:21 UTC
Permalink
Dear All:

My apologies first of all if my post is too simple for this list.

I am working on the Wine project, specifically on implementing D3DX9.

I have done some work for this bug:
http://bugs.winehq.org/show_bug.cgi?id=22918

implementing D3DXCreateSphere, D3DXCreateCylinder, and D3DXCreateBox.
These can be found on my github site:

http://github.com/misha680/wine

Mainly as a motivation to learn more DirectX 9/OpenGL, but also
hopefully to get it into Wine, I have been doing some work on trying to
reproduct D3DXCreateTeapot (exact vertices and indices) using Newell's
original data:
http://www.sjbaker.org/teapot/teaset.tgz

My current approach mostly lies in figuring out the ordering difference
between the two versions (MS and Newell).

I have succeeded in using ID3DXPatchMesh to tesselate the Newell teapot.
Further, I can rotate and scale the MS teapot to match the Newell (I
have attached tester.cpp - the actual program come, compile -
compilation script for Ubuntu 10.04 using mingw32 4.2.1dfsg-1ubuntu2,
teapot.newell - Newell's original data, and test.bat - program to run
the test).

Further, I have attached a file vertices which simply isolates the
vertices ("points") from Newell's original data.

Now, I find something rather odd, and I thought you might be able to
help me with this.

My tessellation code:
// create mesh for tesselation
FLOAT fTessLevel=1.0f;
DWORD Adaptive=FALSE;
DWORD NumTriangles,NumVertices;
if (!
SUCCEEDED(p_mesh->GetTessSize(fTessLevel,Adaptive,&NumTriangles,&NumVertices)))
assert(FALSE);
LPD3DXMESH mesh = NULL;
if (!
SUCCEEDED(D3DXCreateMeshFVF(NumTriangles,NumVertices,D3DXMESH_MANAGED,D3DFVF_XYZ,d3ddev,&mesh)))
assert(FALSE);

// tesselate
assert(Adaptive==FALSE);
if (!SUCCEEDED(p_mesh->Tessellate(fTessLevel,mesh)))
assert(FALSE);
printf("Generated tesselated mesh at level %f with %d triangles, %d
vertices\n",fTessLevel,NumTriangles,NumVertices);
p_mesh->Release();

uses non-adaptive tessellation at level 1.0f. Per
http://msdn.microsoft.com/en-us/library/bb174094%28v=VS.85%29.aspx
fTessLevel [in]
FLOAT

Tessellation level. This is the number of vertices introduced
between existing vertices. The range of this float parameter is
0 < fTessLevel <= 32.

It seems that this would mean at least _one_ extra vertex is inserted
between existing ones.

Now the strange thing. Initially we have 306 vertices, 294 of which are
unique:

***@misha-d630:~/wine/tester$ cat /tmp/vertices | wc
306 306 4653
***@misha-d630:~/wine/tester$ cat /tmp/vertices | sort -u | wc
294 294 4479

Oddly though, tessellation results in _128_ vertices:
---
Loaded patch teapot.newell with 32 patches and 306 vertices.
Generated tesselated mesh at level 1.000000 with 64 triangles, 128
vertices
Newell teapot has 64 triangles, 128 vertices
MS teapot has 2256 triangles, 1178 vertices

Newell teapot center is (0.046875,1.725,0)
MS teapot center is (1.28115e-007,-7.50032e-006,3.36478e-009)
MS teapot center needs to be translated by
(0.0468749,1.72501,-3.36478e-009)
MS teapot center is now (0.0468749,1.725,3.36478e-009)

Newell teapot extents are (-3,0,-2) (3.3,3.15,2)
MS teapot extents are (-2.99538,-0.0136373,-2) (3.43425,3.13636,2)
---

I am quite confused as to how an operation that _introduces_ vertices
can actually result in fewer unique vertices than at the start.

(For your reference, I am not a complete newbie at this - and have
implemented a very basic tessellator in OpenGL for the same problem:
http://bugs.winehq.org/attachment.cgi?id=29818
)

Perhaps I am missing something simple?

Thank you, and cc on replies much appreciated :)

Thank you and I eagerly await your thoughtful response.

Misha

Loading...