Reputation: 338
I am very novice in directx and want to know more, I was trying the code from directxtutorial.comI sthere any example\sample for D3DXCreateCylinder? Thanks
Upvotes: 0
Views: 2941
Reputation: 9671
By default, D3DXCreateCylinder API don't generate the texture coordinates for mapping a texture above the created cylindrical mesh.
Alternate you can formulate your own cylindrical Geometry like below for texture mapping:
for( DWORD i = 0; i < Sides; i++ )
{
FLOAT theta = ( 2 * D3DX_PI * i ) / ( Sides - 1 );
pVertices[2 * i + 0].position = D3DXVECTOR3(radius*sinf( theta ), -height, radius*cosf( theta ) );
pVertices[2 * i + 0].color = 0xffffffff;
pVertices[2 * i + 0].tu = ( ( FLOAT )i ) / ( Sides - 1 );
pVertices[2 * i + 0].tv = 1.0f;
pVertices[2 * i + 1].position = D3DXVECTOR3( radius*sinf( theta ), height, radius*cosf( theta ) );
pVertices[2 * i + 1].color = 0xff808080;
pVertices[2 * i + 1].tu = ( ( FLOAT )i ) / ( Sides - 1 );
pVertices[2 * i + 1].tv = 0.0f;
}
Upvotes: 0
Reputation: 86
These resources will help supplement the answer provided:
Upvotes: 0
Reputation: 531
Alright then,
D3DXCreateCylinder can be used as such
LPD3DXMESH cylinder; // Define a pointer to the mesh.
D3DXCreateCylinder(d3ddev, 2.0f, 0.0f, 10.0f, 10, 10, &cylinder, NULL);
So what is going on?
Tinker around with the values, experimenting can't hurt.
Upvotes: 1