A mesh is a visual object that is made up of a set of polygonal faces. A mesh defines a set of vertices and a set of faces. See IDirect3DRMMesh for more information about meshes.
A progressive mesh is a mesh that is stored as a base mesh (a coarse version) and a set of vertex split records that are used to increasingly refine the mesh. In other words, it allows for progressive refinement. This allows you to set the level of detail rendered for a mesh and also allows progressive download from remote sources.
The progressive mesh is a visual in Microsoft® Direct3D® Retained Mode and can be used in the standard ways that visuals are used. That is, a progressive mesh can be added to frame hierarchies, instantiated a multiple number of times, and picked.
Using the methods of the IDirect3DRMProgressiveMesh interface, you can set the number of vertices or faces to render and thereby control the render detail. You can also specify a minimum level of detail required for rendering. Normally, a progressive mesh is rendered once the base mesh is available, but with the IDirect3DRMProgressiveMesh::SetMinRenderDetail method you can specify that a greater level of detail is necessary before rendering. You can also build a Direct3DRMMesh object from a particular state of the progressive mesh using the IDirect3DRMProgressiveMesh::CreateMesh method.
You can load a progressive mesh from a file, resource, memory, or URL. Loading can be done synchronously or asynchronously. You can check the status of a download with the IDirect3DRMProgressiveMesh::GetLoadStatus method, and terminate a download with the IDirect3DRMProgressiveMesh::Abort method. If loading is asynchronous, it is up to the application to use events through the IDirect3DRMProgressiveMesh::RegisterEvents and IDirect3DRMProgressiveMesh::GetLoadStatus methods to find out how the load is progressing.
The Direct3DRMProgressiveMesh object is created by using the IDirect3DRM3::CreateProgressiveMesh method. After creation, the object can be added to a hierarchy, but will not render until at least the base mesh is available.
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.
Syntax
HRESULT Abort(
DWORD dwFlags
)
Parameters
- dwFlags
- Must be set to zero.
Return Value
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Remarks
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 IDirect3DRMViewport2::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.
Syntax
HRESULT Clone(
LPDIRECT3DRMPROGRESSIVEMESH *lplpD3DRMPMesh
)
Parameters
- lplpD3DRMPMesh
- Address of a Direct3DRMProgressiveMesh pointer that will be filled in with a pointer to the newly generated Direct3DRMProgressiveMesh object.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_NOTENOUGHDATA
Remarks
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.
See Also
Builds a mesh from the current level of detail.
Syntax
HRESULT CreateMesh(
LPDIRECT3DRMMESH *lplpD3DRMMesh
)
Parameters
- lplpD3DRMMesh
- Address of a Direct3DRMMesh pointer that will be filled in with a pointer to the newly generated Direct3DRMMesh object.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_NOTENOUGHDATA
Remarks
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.
Syntax
HRESULT Duplicate(
LPDIRECT3DRMPROGRESSIVEMESH *lplpD3DRMPMesh
)
Parameters
- lplpD3DRMPMesh
- Address of a Direct3DRMProgressiveMesh pointer that will be filled with a pointer to the newly generated Direct3DRMProgressiveMesh object.
Return Value
Returns DD_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_NOTENOUGHDATA
Remarks
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.
Syntax
HRESULT GetBox(
D3DRMBOX *lpD3DRMBox
);
Parameters
- lpD3DRMBox
- Address of a D3DRMBOX structure that will be filled with the bounding box coordinates.
Return Value
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.
Syntax
HRESULT GetDetail(
LPD3DVALUE lpdvVal
)
Parameters
- lpdvVal
- Address of a D3DVALUE that will be filled with the current detail level of the progressive mesh.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
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.
Syntax
HRESULT GetFaceDetail(
LPDWORD lpdwCount
)
Parameters
- lpdwCount
- Address of a DWORD that will be filled in with the number of faces in the progressive mesh.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
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.
Syntax
HRESULT GetFaceDetailRange(
LPDWORD lpdwMinFaces,
LPDWORD lpdwMaxFaces
)
Parameters
- lpdwMinFaces
- Address of a DWORD that will be filled in with the minimum number of faces.
- lpdwMaxFaces
- Address of a DWORD that will be filled in with the maximum number of faces.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
If the face count is not available, this method returns D3DRMERR_PENDING.
Allows the application to inquire about the current status of the load.
Syntax
HRESULT GetLoadStatus(
LPD3DRMPMESHLOADSTATUS lpStatus
)
Parameters
- lpStatus
- Address of a D3DRMPMESHLOADSTATUS structure that contains the loading status of the progressive mesh.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST
Remarks
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.
Syntax
HRESULT GetQuality(
LPD3DRMRENDERQUALITY lpQuality
);
Parameters
- lpQuality
- Pointer to the D3DRMRENDERQUALITY member if successful that specifies rendering quality.
Return Value
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.
See Also
Retrieves the number of vertices in the progressive mesh.
Syntax
HRESULT GetVertexDetail(
LPDWORD lpdwCount
)
Parameters
- lpdwCount
- Address of a DWORD that will be filled in with the number of vertices in the progressive mesh.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
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.
Syntax
HRESULT GetVertexDetailRange(
LPDWORD lpdwMinVertices,
LPDWORD lpdwMaxVertices
)
Parameters
- lpdwMinVertices
- Address of a DWORD that will be filled in with the minimum number of vertices.
- lpdwMaxVertices
- Address of a DWORD that will be filled in with the maximum number of vertices.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
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 a URL. Loading can be done synchronously or asynchronously.
Syntax
HRESULT Load(
LPVOID lpSource,
LPVOID lpObjID,
D3DRMLOADOPTIONS dloLoadflags,
D3DRMLOADTEXTURECALLBACK lpCallback,
LPVOID lpArg
)
Parameters
- lpSource
- Address of the source for the object to be loaded. This source can be a file, resource, memory block, or stream, depending on the source flags specified in the dloLoadflags parameter.
- lpObjID
- Address of the ID of the DirectX file record that is a progressive mesh. This can either be a string or a UUID (determined by dloLoadflags). If lpObjID is NULL, dloLoadflags must be D3DRMLOAD_FIRST.
- dloLoadflags
- Value of the D3DRMLOADOPTIONS type describing how the load is to be performed. One flag from each of the following two groups must be included.
- To determine which object in the DirectX file is loaded, use:
- 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.
- To determine the source of the DirectX file, use:
- 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.
- In addition, you can specify whether the download is synchronous or asynchronous. By default, loading is synchronous and the Load call will not return until all data has been loaded or an error occurs. To specify asynchronous loading, include the following flag:
- D3DRMLOAD_ASYNCHRONOUS The Load call will return immediately. It is up to the application to use events with IDirect3DRMProgressiveMesh::RegisterEvents and IDirect3DRMProgressiveMesh::GetLoadStatus to find out how the load is progressing.
- lpCallback
- Address of a D3DRMLOADTEXTURECALLBACK callback function that will be used to load any texture encountered. The callback will be used with the texture name as encountered by the loader and the user-defined lpArg parameter. A new thread is not spawned for the callback. If you want the application to download a texture progressively, it must spawn a thread and return with a LPDIRECT3DRMTEXTURE as normal.
- lpArg
- Address of user-defined data passed to the D3DRMLOADTEXTURECALLBACK callback function.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_BADFILE D3DRMERR_CONNECTIONLOST
Remarks
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.
Syntax
HRESULT RegisterEvents(
HANDLE hEvent,
DWORD dwFlags,
DWORD dwReserved
)
Parameters
- hEvent
- Event to be signaled when the required condition is met.
- dwFlags
- Can be one of the following flags:
- 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.
- dwReserved
- Must be zero.
Return Value
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Remarks
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.
Syntax
HRESULT SetDetail(
D3DVALUE dvVal
)
Parameters
- dvVal
- The requested level of detail.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING
Remarks
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.
Syntax
HRESULT SetFaceDetail(
DWORD dwCount
)
Parameters
- dwCount
- The number of faces requested.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING D3DRMERR_REQUESTTOOLARGE
Remarks
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.
See Also
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).
Syntax
HRESULT SetMinRenderDetail(
D3DVALUE dvCount
)
Parameters
- dvCount
- Requested minimum detail.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING D3DRMERR_REQUESTTOOLARGE D3DRMERR_REQUESTTOOSMALL
Remarks
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.
Syntax
HRESULT SetQuality(
D3DRMRENDERQUALITY quality
);
Parameters
- quality
- Member of the D3DRMRENDERQUALITY enumerated type that specifies the new rendering quality to use.
Return Value
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Remarks
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 IDirect3DRMDevice3::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).
Tip: Gouraud shading performs better on progressive mesh objects that change their level of detail often or quickly.
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 Direct3DRMMeshBuilder3 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).
See Also
Sets the requested level of vertex detail.
Syntax
HRESULT SetVertexDetail(
DWORD dwCount
)
Parameters
- dwCount
- The number of vertices requested.
Return Value
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_CONNECTIONLOST D3DRMERR_PENDING D3DRMERR_REQUESTTOOLARGE
Remarks
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.
See Also
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.