The MyScene function calls the MakeMyWrap function to create and apply texture coordinates to the sphere loaded by the MakeMyMesh function. MakeMyWrap calls the IDirect3DRMMeshBuilder::GetBox method to retrieve the bounding box that contains the sphere, and uses the dimensions of that bounding box in a call to the IDirect3DRM::CreateWrap method, which creates a cylindrical texture wrap and retrieves the IDirect3DRMWrap interface. A call to the IDirect3DRMWrap::Apply method applies the texture coordinates to the sphere.
/////////////////////////////////////////////////////////////////////
//
// MakeMyWrap
// Creates and applies wrap for texture.
//
/////////////////////////////////////////////////////////////////////
void MakeMyWrap(LPDIRECT3DRMMESHBUILDER sphere3_builder,
LPDIRECT3DRMWRAP * lpWrap)
{
D3DVALUE miny, maxy, height;
D3DRMBOX box;
sphere3_builder->lpVtbl->GetBox(sphere3_builder, &box);
maxy = box.max.y;
miny = box.min.y;
height = maxy - miny;
lpD3DRM->lpVtbl->CreateWrap
(lpD3DRM, D3DRMWRAP_CYLINDER, NULL,
D3DVAL(0.0), D3DVAL(0.0), D3DVAL(0.0),
D3DVAL(0.0), D3DVAL(1.0), D3DVAL(0.0),
D3DVAL(0.0), D3DVAL(0.0), D3DVAL(1.0),
D3DVAL(0.0), D3DDivide(miny, height),
D3DVAL(1.0), D3DDivide(-D3DVAL(1.0), height),
lpWrap);
(*lpWrap)->lpVtbl->Apply(*lpWrap, (LPDIRECT3DRMOBJECT)
sphere3_builder);
}