[ Pobierz całość w formacie PDF ]
.The second parameter is filled with apointer to the IDirect3DRMDevice interface.However, you cannot cast this parameter to adifferent version of the interface.For example, if the pointer you want is to IDirect3DRMDevice3,you must use QueryInterface() to obtain it.The function returns D3DRM_OK if it succeeds, or anerror otherwise. Creating Meshes and FacesIn Chapter 15 you created a mesh using the meshbuilder object.On that occasion the meshbuilderloaded a mesh file, in DirectX format.Then you created a child frame within the scene, and addedthe mesh into the child frame.Most retained mode applications use meshes developed in animage editing program.These meshes are stored in files and loaded into the scene as needed.Alternatively, although rarely in retained mode, an application can create the individual faces of apolygon mesh using the methods in the IDirect3DRMFace2 interface.In this case the face isconstructed using the AddVertex() and AddVertextAndNormalIndex() functions.Code canread the vertices using the GetVertex() and GetVertices() functions, or set the color,texture, and material of the face by using SetColor(), SetColorRGB(), SetTexture(), andSetMaterial().Table 16-3 lists the methods in the IDirect3DRMFace2 interface.Table 16-3: Functions in the IDirect3DRMFace2 InterfaceFunction DescriptionColor manipulationsGetColor()Retrieves the face colorSetColor()Sets color and alpha componentSetColorRGB()Sets color in RGB formatMaterialsGetMaterial()Retrieves the material propertySetMaterial()Sets the material propertyTexturesGetTexture()Retrieves the applied textureGetTextureCoordinateIndex()Retrieves the index of the texturecoordinate vertex GetTextureCoordinates()Retrieves the texture coordinates ofa vertexSetTexture()Sets the face textureSetTextureCoordinates()Sets the texture coordinates of avertexSetTextureTopology()Sets the texture topology of a faceVertices and normalsAddVertex()Adds a vertex to a faceAddVertexAndNormalIndexed()Uses the index for the vertex andthe normal to add a vertex and anormal to a faceGetNormal()Retrieves the normal vector of afaceGetVertex()Retrieves the position and thenormal of a vertex in a faceGetVertexCount()Retrieves the number of verticesGetVertexIndex()Retrieves the index of the vertex in afaceGetVertices()Retrieves the position and thenormal vector of each vertex in afaceBecause building meshes out of primitive components is not a common operation in retained modeprogramming, we do not discuss the mesh primitive functions at this point.A progressive mesh is defined as a set of discrete steps that go from the coarsest to the mostrefined representation of the object.Progressive meshes were introduced to Direct3D in DirectX 5.In addition to rendering an image in a series of progressively refined steps, they also allow theprogressive download of a mesh from a remote source.One of the methods of IDirect3DRM is CreateProgressiveMesh().This function creates a progressive mesh object.Its general form is as follows:HRESULT CreateProgressiveMesh(LPDIRECT3DRMPROGRESSIVEMESH *lplpD3DRMProgressiveMesh // 1);The only parameter is the address that will be filled with a pointer to anIDirect3DRMProgressiveMesh interface if the call succeeds.The function returns D3DRM_OKif it succeeds, or an error otherwise.After the progressive mesh object is created, it can be used to access any of the functions inIDirect3DRMProgressiveMesh.Table 16-4 lists the functions in this interface.Table 16-4: Functions in the IDirect3DRMProgressiveMesh InterfaceFunction DescriptionCreating and Copying MeshesClone()Creates a copy of the current mesh object.CreateMesh()Builds a mesh using the current level of detail.Duplicate()Creates a copy of theDirect3DprogressiveMesh object.Thelevel of detail for the duplicate object can be setindependently.GetBox()Retrieves the object's bounding box.LoadingAbort()Terminates the current download.GetLoadStatus()Returns the current status of the load.Load()Loads a progressive mesh from a file, aresource, or a URL. Mesh QualitySetQuality()Sets the rendering quality of the progressivemesh.GetQuality()Retrieves the D3DRMRENDERQUALITYenumerated constant that specified therendering quality of a progressive mesh.Level of DetailGetDetail()Returns the current level of detail (range is 0.0to 1.0).GetFaceDetail()Retrieves the number of faces in a progressivemesh.GetFaceDetailRange()Retrieves the minimum and maximum facecount.GetVertexDetail()Retrieves the number of vertices in aprogressive mesh.GetVertexDetailRange()Retrieves the minimum and maximum vertexcount.SetDetail()Sets the current level of detail (range is 0.0 to1.0).SetFaceDetail()Sets the level of detail for a face.SetMinRenderDetail()Sets the minimum level of detail, larger than thebase mesh, that will be rendered during a load.SetVertexDetail()Sets the level of detail for a vertex.Events HandlingRegisterEvents()Registers an event that will be signaled when apredefined condition is met. Programming operations using progressive meshes is discussed in the context of Direct3Danimation. Creating Materials, Shadows, Textures, and WrapsMaterials, textures, shadows, and wraps are fundamental mesh attributes in Direct3Dprogramming.An object's rendering quality depends largely on our abilities in manipulating thesefour attributes.In this chapter we consider the creation of these attributes and provide an overviewof the interfaces that are used in their manipulation.The programming details are describedbeginning in Chapter 18.MaterialsIn the 3DRM InWin Demo1 program presented in Chapter 15 you created a material using theCreateMaterial() function of IDirect3DRM.Notice that a material object can also be createdin immediate mode using the CreateMaterial() function of IDirect3D3.Immediate modeprovides a much finer degree of control over material properties than retained mode.The call to CreateMaterial() of the IDirect3DRM3 interface returns a pointer to theIDirect3DRMMaterial2 interface if the call succeeds.This interface upgrade toIDirect3DRMMaterial became available in DirectX 6.The interface provides the methodslisted in Table 16-5 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl