The progressive mesh is a form of mesh that allows for progressive refinement. Conceptually, it consists of a base mesh representation and a number of "vertex split" records. A mesh can be stored as a much coarser mesh together with records of how to incrementally refine the mesh. This allows for a generalized level of detail to be set on the mesh, as well as progressive download of the mesh from a remote source.
The progressive mesh is a visual in Microsoft® Direct3D® Retained Mode and may be used in the standard ways that visuals are used. That is, a progressive mesh can be added to frame hierarchies, multiply instanced and picked.
The Direct3DRMProgressiveMesh object is created by using the IDirect3DRM2::CreateProgressiveMesh method. After creation, the object can be added to a hierarchy, but will not render until at least the base mesh is available.
For a conceptual overview, see IDirect3DRMProgressiveMesh.
In addition to the standard IUnknown and IDirect3DRMObject methods, this API contains the following members:
| Creating and Copying Meshes | Clone |
| CreateMesh | |
| Duplicate | |
| GetBox | |
| Loading | Abort |
| GetLoadStatus | |
| Load | |
| Setting Quality | SetQuality |
| GetQuality | |
| Managing Details | GetDetail |
| GetFaceDetail | |
| GetFaceDetailRange | |
| GetVertexDetail | |
| GetVertexDetailRange | |
| SetDetail | |
| SetFaceDetail | |
| SetMinRenderDetail | |
| SetVertexDetail | |
| Registering Events | RegisterEvents |
The IDirect3DRMProgressiveMesh interface, like all COM interfaces, inherits the IUnknown interface methods. The IUnknown interface supports the following three methods:
| AddRef |
| QueryInterface |
| Release |
In addition, the IDirect3DRMProgressiveMesh interface inherits the following methods from the IDirect3DRMObject interface:
| AddDestroyCallback |
| Clone |
| DeleteDestroyCallback |
| GetAppData |
| GetClassName |
| GetName |
| SetAppData |
| SetName |
Terminates the currently active download.
HRESULT Abort(
DWORD dwFlags
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
If the base mesh has been downloaded before this method is used, the effect is as if the progressive mesh has loaded, the vertex splits are in a valid state, and the progressive mesh is renderable. The other progressive mesh methods will work. If the base mesh has not been downloaded before the IDirect3DRMProgressiveMesh::Abort call and you have added the progressive mesh to a scene, the Render will succeed but the progressive mesh will not be rendered. Also, if the base mesh has not been downloaded, when you try to use the progressive mesh (to create a mesh or clone, for example) the call will return D3DRMERR_NOTENOUGHDATA.
If there are any outstanding events, they are signaled.
Creates a copy of the currently loaded Direct3DRMProgressiveMesh object.
HRESULT Clone(
LPDIRECT3DRMPROGRESSIVEMESH* lplpD3DRMPMesh
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_NOTENOUGHDATA |
The progressive mesh being cloned must have at least its base mesh loaded. If you use this method on a progressive mesh that is currently being asynchronously loaded, the cloned mesh only has as much detail as the loading progressive mesh had at the time it was cloned. Any vertex splits loaded after the duplication are not available to the cloned mesh.
This method does not try to share any of the progressive mesh's internal data, whereas the IDirect3DRMProgressiveMesh::Duplicate does.
IDirect3DRMProgressiveMesh::Duplicate
Builds a mesh from the current level of detail.
HRESULT CreateMesh(
LPDIRECT3DRMMESH* lplpD3DRMMesh
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_NOTENOUGHDATA |
If the application has requested a level of detail that is not yet available, or the base mesh is not yet available, this method returns the error D3DRMERR_NOTENOUGHDATA.
Creates a copy of the Direct3DRMProgressiveMesh object. The copy shares all geometry and face data with the original, but has a detail level that can be set independently of the original. This enables the same mesh data to be used in different parts of the hierarchy but with different levels of detail. In essence, you almost have two instances of a progressive mesh within the frame hierarchy.
HRESULT Duplicate(
LPDIRECT3DRMPROGRESSIVEMESH* lplpD3DRMPMesh
)
Returns DD_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_NOTENOUGHDATA |
The progressive mesh being duplicated must have at least its base mesh loaded. If you use this method on a progressive mesh that is currently being asynchronously loaded, the duplicated mesh only has as much detail as the loading progressive mesh had at the time it was duplicated. Any vertex splits loaded after the duplication are not available to the duplicated mesh.
A progressive mesh has a set of data representing the base mesh, and a set of data representing the vertex splits. The base mesh data and data describing the current state of the progressive mesh and the current level of detail isn't shared between meshes that are duplicated, but the vertex splits are. This method creates a new instance of the progressive mesh that shares all geometry and face data with the original, but has a detail level that can be set independently of the original.
Retrieves the bounding box containing a Direct3DRMProgressiveMesh object. The bounding box gives the minimum and maximum coordinates relative to a child frame, in each dimension.
HRESULT GetBox(
D3DRMBOX * lpD3DRMBox
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Returns the current detail level of the progressive mesh normalized between 0.0 and 1.0.
HRESULT GetDetail(
LPD3DVALUE lpdvVal
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
If the base mesh has not yet downloaded then this method will return D3DRMERR_PENDING. If a requested level of detail has been set, the return value will increase on each subsequent call until the requested level has been met. If no level has been requested, the detail will increase until all vertex splits have been downloaded.
The normalized value 0.0 represents the minimum number of vertices (the number of vertices in the base mesh), and the normalized value 1.0 represents the maximum number of vertices.
Retrieves the number of faces in the progressive mesh.
HRESULT GetFaceDetail(
LPDWORD lpdwCount
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_PENDING |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
If the number of faces is not available, this method returns D3DRMERR_PENDING.
Retrieves the minimum and maximum face count available in the progressive mesh.
HRESULT GetFaceDetailRange(
LPDWORD lpdwMinFaces,
LPDWORD lpdwMaxFaces
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
If the face count is not available, this method returns D3DRMERR_PENDING.
Allows the application to inquire about the current status of the load.
HRESULT GetLoadStatus(
LPD3DRMPMESHLOADSTATUS lpStatus
)
typedef struct _D3DRMPMESHLOADSTATUS
{
DWORD dwSize; // Size of this structure
DWORD dwPMeshSize; // Total size (bytes)
DWORD dwBaseMeshSize; // Size of base mesh (bytes)
DWORD dwBytesLoaded; // Total number of bytes loaded
DWORD dwVerticesLoaded; // Number of vertices loaded
DWORD dwFacesLoaded; // Number of faces loaded
DWORD dwFlags;
}
D3DRMPMESHLOADSTATUS;
typedef D3DRMPMESHLOADSTATUS *LPD3DRMPMESHLOADSTATUS;
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
If the mesh is renderable (the base mesh has been downloaded and the data is not corrupt) then the dwFlags member contains D3DRMPMESHSTATUS_RENDERABLE. If the download was interrupted, the dwFlags member will contain D3DRMPMESHSTATUS_INTERRUPTED.
Retrieves a member of the D3DRMRENDERQUALITY enumerated type that specifies the rendering quality of the progressive mesh.
HRESULT GetQuality(
LPD3DRMRENDERQUALITY lpQuality
);
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_BADOBJECT The progressive mesh is invalid. |
| D3DRMERR_BADVALUE The pointer to the D3DRMRENDERQUALITY member is invalid. |
IDirect3DRMProgressiveMesh::SetQuality
Retrieves the number of vertices in the progressive mesh.
HRESULT GetVertexDetail(
LPDWORD lpdwCount
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
If the number of vertices is not available, this method returns D3DRMERR_PENDING.
Retrieves the minimum and maximum vertex count available in the progressive mesh.
HRESULT GetVertexDetailRange(
LPDWORD lpdwMinVertices,
LPDWORD lpdwMaxVertices
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
If the vertex count information is not available, this method returns D3DRMERR_PENDING.
Loads the progressive mesh object from memory, a file, a resource, or an URL. Loading can be done synchronously or asynchronously.
HRESULT Load(
LPVOID lpSource,
LPVOID lpObjID,
D3DRMLOADOPTIONS dloLoadflags,
D3DRMLOADTEXTURECALLBACK lpCallback,
LPVOID lpArg
)
| The following values determine which object in the DirectX file is loaded:
| |
| D3DRMLOAD_BYNAME | The lpObjID parameter is interpreted as a string. |
| D3DRMLOAD_BYGUID | The lpObjID parameter is interpreted as a UUID. |
| D3DRMLOAD_FIRST | The first progressive mesh found is loaded. |
| The following flags determine the source of the DirectX file: | |
| D3DRMLOAD_FROMFILE | The lpSource parameter is interpreted as a string representing a local file name. |
| D3DRMLOAD_FROMRESOURCE | The lpSource parameter is interpreted as a pointer to a D3DRMLOADRESOURCE structure. |
| D3DRMLOAD_FROMMEMORY | The lpSource parameter is interpreted as a pointer to a D3DRMLOADMEMORY structure. |
| D3DRMLOAD_FROMURL | The lpSource parameter is interpreted as a URL. |
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_BADPMDATA |
| D3DRMERR_BADFILE |
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
The progressive mesh is not useful unless it has been initialized. If asynchronous download is specified, the API returns immediately, and a separate thread is spawned to perform the download.
This method, IDirect3DRMProgressiveMesh::Clone, and IDirect3DRMProgressiveMesh::Duplicate all initialize a progressive mesh. You can only initialize an object once. Therefore, you cannot clone or duplicate a progressive mesh and then try to load into the cloned or duplicated mesh, nor can you load into a previously loaded mesh.
Allows the application to register events with the progressive mesh object that will be signaled when the appropriate conditions are met.
HRESULT RegisterEvents(
HANDLE hEvent,
DWORD dwFlags,
DWORD dwReserved
)
| D3DRMPMESHEVENT_BASEMESH | The event is signaled when the base mesh has been downloaded. |
| D3DRMPMESHEVENT_COMPLETE | The event is signaled when all data has been downloaded. |
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
This method can be used to monitor the progress of loads. Events will also be signaled if an error occurs, so your application should always use the IDirect3DRMProgressiveMesh::GetLoadStatus method after being signaled.
Sets a requested level of detail normalized between 0.0 and 1.0.
HRESULT SetDetail(
D3DVALUE dvVal
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_BADPMDATA |
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
If not enough detail has been downloaded yet (but will be available), the request is acknowledged and D3DRMERR_PENDING is returned. This error is informational and indicates that the requested level will be set as soon as enough detail is available.
The normalized value 0.0 represents the minimum number of vertices (the number of vertices in the base mesh), and the normalized value 1.0 represents the maximum number of vertices.
Sets the requested level of face detail.
HRESULT SetFaceDetail(
DWORD dwCount
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_BADPMDATA |
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
| D3DRMERR_REQUESTTOOLARGE |
Sometimes it is not possible to set the progressive mesh to the number of faces requested, though it will always be within 1 of the requested value. This is because a vertex split can add 1 or 2 faces. For example, if you use SetFaceDetail(20), the progressive mesh may only be able to set the face detail to 19 or 21. You can always get the actual number of faces in the progressive mesh by using the IDirect3DRMProgressiveMesh::GetFaceDetail method.
If not enough detail has been downloaded yet (but will be available), the request is be acknowledged and D3DRMERR_PENDING is returned. This error is informational and indicates that the requested level will be set as soon as enough detail is available. If the detail requested is greater that the detail available in the progressive mesh, D3DRMERR_REQUESTTOOLARGE is returned.
IDirect3DRMProgressiveMesh::GetFaceDetail
Sets the minimum level of detail that will be rendered during a load from 0.0 (minimum detail) to 1.0 (maximum detail). Normally, the progressive mesh will be rendered once the base mesh is available (and the mesh is in the scene graph).
HRESULT SetMinRenderDetail(
D3DVALUE dvCount
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
| D3DRMERR_REQUESTTOOLARGE |
| D3DRMERR_REQUESTTOOSMALL |
This API sets the minimum number of faces/vertices that will be rendered during the load (larger than the base mesh).
Any subsequent IDirect3DRMProgressiveMesh::SetDetail, IDirect3DRMProgressiveMesh::SetFaceDetail, or IDirect3DRMProgressiveMesh::SetVertexDetail calls will override this.
Sets the rendering quality of a Direct3DRMProgressiveMesh object.
HRESULT SetQuality(
D3DRMRENDERQUALITY quality
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
An object's quality has three components: shade mode (flat or Gouraud, Phong is not yet implemented and will default to Gouraud shading), lighting type (on or off), and fill mode (point, wire-frame or solid).
You can set the quality of a device with IDirect3DRMDevice::SetQuality. By default it is D3DRMRENDER_FLAT (flat shading, lights on, and solid fill).
You can set the quality of a Direct3DRMProgressiveMesh object with the SetQuality method. By default, a Direct3DRMProgressiveMesh object's quality is D3DRMRENDER_GOURAUD (Gouraud shading, lights on, and solid fill).
Direct3D Retained Mode renders an object at the lowest quality setting based on the device and object's current setting for each individual component. For example, if the object's current quality setting is D3DRMRENDER_GOURAUD, and the device is D3DRMRENDER_FLAT, the object will be rendered with flat shading, solid fill and lights on.
If the object's current quality setting is D3DRMSHADE_GOURAUD|D3DRMLIGHT_OFF|D3DRMFILL_WIREFRAME and the device's quality setting is D3DRMSHADE_FLAT|D3DRMLIGHT_ON|D3DRMFILL_POINT, the object will be rendered with flat shading, lights off, and point fill mode.
These rules apply to Direct3DRMMeshBuilder objects, Direct3DRMMeshBuilder2 objects, and Direct3DRMProgressiveMesh objects. However, Direct3DRMMesh objects do not follow these rules. Mesh objects ignore the device's quality settings and use the group quality setting (which defaults to D3DRMRENDER_GOURAUD).
IDirect3DRMProgressiveMesh::GetQuality
Sets the requested level of vertex detail.
HRESULT SetVertexDetail(
DWORD dwCount
)
Returns D3DRM_OK if successful, or one of the following errors:
| D3DRMERR_BADPMDATA |
| D3DRMERR_CONNECTIONLOST |
| D3DRMERR_INVALIDDATA |
| D3DRMERR_INVALIDOBJECT |
| D3DRMERR_INVALIDPARAMS |
| D3DRMERR_PENDING |
| D3DRMERR_REQUESTTOOLARGE |
If not enough detail has been downloaded yet (but will be available), the request will be acknowledged and D3DRMERR_PENDING is returned. This error is informational and indicates that the requested level will be set as soon as enough detail is available. If the detail requested is greater than the detail available in the progressive mesh, D3DRMERR_REQUESTTOOLARGE is returned.
IDirect3DRMProgressiveMesh::GetVertexDetail
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.