Index Topic Contents | |||
Previous Topic: IDirect3DRMObject Next Topic: IDirect3DRMShadow |
IDirect3DRMProgressiveMesh
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 IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::AbortTerminates the currently active download.
HRESULT Abort(
DWORD dwFlags
)Parameters
- dwFlags
- Must be set to zero.
Return Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::CloneCreates a copy of the currently loaded Direct3DRMProgressiveMesh object.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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
IDirect3DRMProgressiveMesh::Duplicate
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::CreateMeshBuilds a mesh from the current level of detail.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::DuplicateCreates 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
)Parameters
- lplpD3DRMPMesh
- Address of a Direct3DRMProgressiveMesh pointer that will be filled with a pointer to the newly generated Direct3DRMProgressiveMesh object.
Return Values
Returns DD_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetBoxRetrieves 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
);Parameters
- lpD3DRMBox
- Address of a D3DRMBOX structure that will be filled with the bounding box coordinates.
Return Values
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetDetailReturns the current detail level of the progressive mesh normalized between 0.0 and 1.0.
HRESULT GetDetail(
LPD3DVALUE lpdvVal
)Parameters
- lpdvVal
- Address of a D3DVALUE that will be filled with the current detail level of the progressive mesh.
Return Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetFaceDetailRetrieves the number of faces in the progressive mesh.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_PENDING D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS Remarks
If the number of faces is not available, this method returns D3DRMERR_PENDING.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetFaceDetailRangeRetrieves the minimum and maximum face count available in the progressive mesh.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS D3DRMERR_PENDING Remarks
If the face count is not available, this method returns D3DRMERR_PENDING.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetLoadStatusAllows the application to inquire about the current status of the load.
HRESULT GetLoadStatus(
LPD3DRMPMESHLOADSTATUS lpStatus
)Parameters
- lpStatus
- Address of a D3DRMPMESHLOADSTATUS structure defined as follows:
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;- The dwFlags member can take the following values:
- D3DRMPMESHSTATUS_VALID The progressive mesh object contains valid data.
- D3DRMPMESHSTATUS_INTERRUPTED The download was interrupted either because the application used Abort or because the connection was lost.
- D3DRMPMESHSTATUS_BASEMESH The base mesh has been downloaded.
- D3DRMPMESHSTATUS_COMPLETE All data has been downloaded.
- D3DRMPMESHSTATUS_RENDERABLE It is now possible to render the mesh.
Return Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetQualityRetrieves a member of the D3DRMRENDERQUALITY enumerated type that specifies the rendering quality of the progressive mesh.
HRESULT GetQuality(
LPD3DRMRENDERQUALITY lpQuality
);Parameters
- lpQuality
- Pointer to the D3DRMRENDERQUALITY member if successful that specifies rendering quality.
Return Values
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
IDirect3DRMProgressiveMesh::SetQuality
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetVertexDetailRetrieves the number of vertices in the progressive mesh.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS D3DRMERR_PENDING Remarks
If the number of vertices is not available, this method returns D3DRMERR_PENDING.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::GetVertexDetailRangeRetrieves the minimum and maximum vertex count available in the progressive mesh.
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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS D3DRMERR_PENDING Remarks
If the vertex count information is not available, this method returns D3DRMERR_PENDING.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::LoadLoads 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
)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:
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.
- 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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_BADFILE D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::RegisterEventsAllows 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
)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 Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::SetDetailSets a requested level of detail normalized between 0.0 and 1.0.
HRESULT SetDetail(
D3DVALUE dvVal
)Parameters
- dvVal
- The requested level of detail.
Return Values
Returns D3DRM_OK if successful, or one of the following errors:
D3DRMERR_BADPMDATA D3DRMERR_CONNECTIONLOST D3DRMERR_INVALIDDATA D3DRMERR_INVALIDOBJECT D3DRMERR_INVALIDPARAMS 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::SetFaceDetailSets the requested level of face detail.
HRESULT SetFaceDetail(
DWORD dwCount
)Parameters
- dwCount
- The number of faces requested.
Return Values
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 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
IDirect3DRMProgressiveMesh::GetFaceDetail
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::SetMinRenderDetailSets 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
)Parameters
- dvCount
- Requested minimum detail.
Return Values
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 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.
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::SetQualitySets the rendering quality of a Direct3DRMProgressiveMesh object.
HRESULT SetQuality(
D3DRMRENDERQUALITY quality
);Parameters
- quality
- Member of the D3DRMRENDERQUALITY enumerated type that specifies the new rendering quality to use.
Return Values
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 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).
See Also
IDirect3DRMProgressiveMesh::GetQuality
IDirect3DRMProgressiveMesh
IDirect3DRMProgressiveMesh::SetVertexDetailSets the requested level of vertex detail.
HRESULT SetVertexDetail(
DWORD dwCount
)Parameters
- dwCount
- The number of vertices requested.
Return Values
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 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
IDirect3DRMProgressiveMesh::GetVertexDetail
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.