青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Using the .X File Format(6)

Enumerating Data Objects

At this point, you have opened your .X file and registered the templates you'll be using (such as the DirectX standard templates). The enumeration object has been created, and you are now ready to pull data from the .X file.

In its current state, the IDirectXFileEnumObject object you created points to the first data object in the file, which is typically the Header object. All top−level data objects are siblings of the Header object (or the first object in the file). Each data object you read might contain embedded objects (child objects) or references to other data objects; you can query for both of these.

The enumerator object itself doesn't handle a data object's data. Rather, you need to obtain a data object interface, called IDirectXFileData, to access the data.

Applications use the methods of the IDirectXFileData interface to build or to access the immediate hierarchy of the data object. Template restrictions determine the hierarchy. Data types allowed by the template are called optional members. The optional members are not required, but an object might miss important information without them. These optional members are saved as children of the data object. The children can be another data object, a reference to an earlier data object, or a binary object. Deprecated.

IDirectXFileData Members

Method Description
IDirectXFileData::AddBinaryObject Creates a binary object and adds it as a child object. Deprecated.
IDirectXFileData::AddDataObject Adds a data object as a child object. Deprecated.
IDirectXFileData::AddDataReference Creates and adds a data reference object as a child object. Deprecated.
IDirectXFileData::GetData Retrieves the data for one of the object's members or the data for all members. Deprecated.
IDirectXFileData::GetNextObject Retrieves the next child data object, data reference object, or binary object in the DirectX file. Deprecated.
IDirectXFileData::GetType Retrieves the GUID of the object's template. Deprecated.

Remarks

The GUID for the IDirectXFileData interface is IID_IDirectXFileData.

The LPDIRECTXFILEDATA type is defined as a pointer to this interface.

typedef interface IDirectXFileData *LPDIRECTXFILEDATA;

To obtain an IDirectXFileData interface, you need to call the IDirectXFileEnumObject::GetNextDataObject function.

Retrieves the next top-level object in the DirectX file. Deprecated.

HRESULT GetNextDataObject(
LPDIRECTXFILEDATA * ppDataObj
);

Parameters

ppDataObj
[out] Address of a pointer to an IDirectXFileData interface, representing the returned file data object.

Return Values

If the method succeeds, the return value is DXFILE_OK. If the method fails, the return value can be one of the following values: DXFILEERR_BADVALUE, DXFILEERR_NOMOREOBJECTS

Remarks

Top-level objects are always data objects. Data reference objects and binary objects can only be children of data objects.

With only one parameter, the GetNextDataObject is a breeze to use. You just need to instance an IDirectXFileData object and use it in your call to GetNextDataObject.

IDirectXFileData *pData;
HRESULT hr = pEnum−>GetNextDataObject(&pData);

Notice how I'm saving the return value of the GetNextDataObject call? If the return code is an error(which you can check by using the FAILED macro), it signifies that the enumeration is complete. If the call to GetNextDataObject is successful, then you have yourself a spiffy new interface for accessing the data object's data!

Before you get into working with the object's data, let's finish the discussion on enumeration. So far, you've been able to enumerate the first data object in a file and retrieve its data interface. What do you do when you want to go to the next data object in the .X file or query for embedded data objects?

Once you're finished with a data interface, you need to free it to go to the next data object. Simply calling IDirectXFileData::Release will free the data interface, and repeating the call to IDirectXFileEnumObject::GetNextDataObject will get the next enumerated sibling (top−level) data object for you. You can wrap the entire enumeration of siblings (grabbing their respective data interfaces)
into a code bite such as this one:

while(SUCCEEDED(pEnum−>GetNextDataObject(&pData))) {
  // Do something with pData data object
  // Free the data interface in order to continue
  pData−>Release();
}

All that's left is to add the ability to query for child (lower−level) data objects, and to allow those child objects to be enumerated and accessed. To query for a child data object, you use the IDirectXFileData::GetNextObject function to first see whether a data object contains any embedded objects.

Retrieves the next child data object, data reference object, or binary object in the DirectX file. Deprecated.

HRESULT GetNextObject(
LPDIRECTXFILEOBJECT * ppChildObj
);

Parameters

ppChildObj
[out, retval] Address of a pointer to an IDirectXFileObject interface, representing the returned child object's file object interface.

Return Values

If the method succeeds, the return value is DXFILE_OK. If the method fails, the return value can be one of the following values: DXFILEERR_BADVALUE, DXFILEERR_NOMOREOBJECTS.

Remarks

To determine the type of object retrieved, use QueryInterface to query the retrieved object for support of IDirectXFileData, IDirectXFileDataReference, or IDirectXFileBinary interfaces. The interface supported indicates the type of object (data, data reference, or binary).

This is another simple function with only one parameter−the pointer to an IDirectXFileObject interface. If the call to GetNextObject is successful, then you need to process the child data object. Once you've done that, you can free it (by calling Release) and continue calling GetNextObject until it returns an error code, which signifies that no more child objects remain.

You can wrap the continuous calling of GetNextObject into a small loop, as I have done here.

IDirectXFileObject *pObject;

while(SUCCEEDED(pData−>GetNextObject(&pObject))) {
  // A child data object exists, need to query for it
  // Free file object interface
  pObject−>Release();
}

Once you have a valid IDirectFileObject interface (after the call to GetNextObject), you can quickly determine which child data object it is currently enumerating (using the techniques coming up in the next section). There's a slight snag, however. A data object can either be referenced or instanced, and the way you access the object varies a bit depending on which type it is.

For instanced objects (those defined normally in an .X file), you can query the IDirectXFileObject for an IDirectXFileData interface.

IDirectXFileData *pSubData;

// Check if child object is instanced (fails if not)
if(SUCCEEDED(pObject−>QueryInterface( IID_IDirectXFileData, (void**)&pSubData))) {
  // Child data object exists, do something with it.
  // Free data object
  pSubData−>Release();
}

Using what you've just learned, you can query a child data object's IDirectXFileData object for its own embedded child objects.

As for referenced data objects, you need to first query for the IDirectXFileDataReference object and resolve the reference into an IDirectXFileData object.

Applications use the methods of the IDirectXFileDataReference interface to support data reference objects. A data reference object refers to a data object that is defined earlier in the file. This enables you to use the same object multiple times without repeating it in the file. Deprecated.

IDirectXFileDataReference Members

Method Description
IDirectXFileDataReference::Resolve Resolves data references. Deprecated.

Remarks

After you have determined that an object is a data reference object, use the IDirectXFileDataReference::Resolve method to retrieve the referenced object defined earlier in the file. For information about how to identify a data reference object, see the IDirectXFileData interface.

The GUID for the IDirectXFileDataReference interface is IID_IDirectXFileDataReference.

The LPDIRECTXFILEDataReference type is defined as a pointer to this interface.

typedef interface IDirectXFileDataReference *LPDIRECTXFILEDATAREFERENCE;

IDirectXFileDataReference::Resolve

Resolves data references. Deprecated.

HRESULT Resolve(
LPDIRECTXFILEDATA * ppDataObj
);

Parameters

ppDataObj
[out, retval] Address of a pointer to an IDirectXFileData interface, representing the returned file data object.

Return Values

If the method succeeds, the return value is DXFILE_OK. If the method fails, the return value can be one of the following values: DXFILEERR_BADVALUE, DXFILEERR_NOTFOUND.

The following code will query and resolve the referenced data object for you.

Tip If an instanced data object does not exist when you query for it, the call to QueryInterface will fail. This is a quick way to tell the type of the data object. The same goes for referenced objects−the query will fail, meaning the object is not referenced.

IDirectXFileDataReference *pRef;
IDirectXFileData *pSubData;

// Check if the data object is referenced (fails if not)
if(SUCCEEDED(pSubObj−>QueryInterface(IID_IDirectXFileDataReference, (void**)&pRef))) {
  // A data object reference exists. Resolve the reference
  pRef−>Resolve(&pSubData);

  // Do something with data object
  // Release the interfaces used
  pRef−>Release();
  pSubData−>Release();
}

Would you believe me if I told you that the hardest part is over? Enumerating the data objects and child objects is simple, and if that's as hard as it gets, then you're in for an easy ride! To make your programming job much easier, I suggest wrapping up the entire enumeration of data objects into two simple functions.

The first function (called Parse) will open an .X file, create the enumeration object, and enumerate all top−level data objects. The function will then take each enumerated object and pass it to the second function (ParseObject), which will process the data object data based on its template type and scan for embedded child data objects. The ParseObject function will call itself using any child objects it finds, thus processing a child's embedded objects.

The code for the Parse function follows.

// Need to include rmxftmpl.h and rmxfguid.h
BOOL Parse(char *Filename)
{
IDirectXFile *pFile = NULL;
IDirectXFileEnumObject *pEnum = NULL;
IDirectXFileData *pData = NULL;
	// Create the enumeration object, return on error
if(FAILED(DirectXFileCreate(&pFile)))
return FALSE;
	// Register the standard templates, return on error
if(FAILED(pFile−>RegisterTemplates((LPVOID)D3DRM_XTEMPLATES, D3DRM_XTEMPLATE_BYTES)))
return FALSE;
	// Create the enumeration object, return on error
if(FAILED(pDXFile−>CreateEnumObject((LPVOID)Filename, DXFILELOAD_FROMFILE, &pEnum))) {
pFile−>Release();
return FALSE;
}
	// Loop through all top−level data objects
while(SUCCEEDED(pEnum−>GetNextDataObject(&pData))) {
// Parse the data object by calling ParseObject
ParseObject(pData);
		// Release the data object
pData−>Release();
}
	// Release used COM objects
pEnum−>Release();
pFile−>Release();
return TRUE;
}

The Parse function doesn't hold back any punches, and it certainly isn't overly complicated. I have already explained everything in the function, so there's no need to recap here. Instead, move on to the ParseObject function, which takes a data object and queries it for child objects.

void ParseObject(IDirectXFileData *pData)
{
IDirectXFileObject *pObject = NULL;
IDirectXFileData *pSubData = NULL;
IDirectXFileDataReference *pRef = NULL;
	// Scan for embedded objects
while(SUCCEEDED(pData−>GetNextObject(&pObject))) {
// Look for referenced objects
if(SUCCEEDED(pObject−>QueryInterface(IID_IDirectXFileDataReference, (void**)&pRef))) {
// Resolve the data object
pRef−>Resolve(&pSubData);
			// Parse the object by calling ParseObject
ParseObject(pSubData);
			// Free interfaces
pSubData−>Release();
pRef−>Release();
}
		// Look for instanced objects
if(SUCCEEDED(pObject−>QueryInterface(IID_IDirectXFileData, (void**)&pSubData))) {
// Parse the object by calling ParseObject
ParseObject(pSubData);
// Free the object interface
pSubData−>Release();
}
		// Free the interface for next object to use
pObject−>Release();
}
}

Again, the ParseObject function doesn't contain anything new. The one thing you'll notice about Parse and ParseObject is that they don't really do anything except enumerate every data object in an .X file. When it comes time to work with an object's data, what do you do?


posted on 2008-04-17 18:44 lovedday 閱讀(687) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            日韩网站在线看片你懂的| 亚洲国产精品尤物yw在线观看| 在线视频精品一区| 亚洲激情视频在线| 欧美激情精品久久久久久黑人| 日韩一级欧洲| 亚洲视频在线观看一区| 国产精品久久久久婷婷| 午夜欧美大尺度福利影院在线看 | 国产欧美精品一区| 欧美在线免费播放| 久久成人精品电影| 亚洲人成人一区二区在线观看| 亚洲国产一区二区a毛片| 欧美精品v日韩精品v韩国精品v| 一区二区欧美在线| 中日韩男男gay无套| 国产三区精品| 欧美激情黄色片| 欧美日韩亚洲一区| 久久久99国产精品免费| 噜噜噜91成人网| 亚洲私人黄色宅男| 亚洲欧美日韩在线不卡| 亚洲福利一区| 一区二区三区四区五区精品| 国产欧美日本一区二区三区| 欧美国产视频在线| 国产精品乱码妇女bbbb| 蜜桃伊人久久| 国产精品日韩精品| 亚洲大片在线观看| 国产乱肥老妇国产一区二| 欧美高清一区| 国产欧美日本| 亚洲精品1区2区| 好吊色欧美一区二区三区四区| 亚洲国产成人精品视频| 国产三级欧美三级日产三级99| 亚洲福利视频一区二区| 国产日韩欧美在线播放| 亚洲免费av网站| 在线日韩视频| 午夜精品成人在线| 亚洲视频在线视频| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美一区二区啪啪| 欧美日韩一区二区在线观看| 欧美1区2区视频| 国产亚洲欧洲| 亚洲男人的天堂在线观看| 一本久道久久综合中文字幕| 蜜桃av噜噜一区| 免费亚洲网站| 激情一区二区三区| 午夜精品久久久久久久99樱桃| 亚洲午夜在线| 欧美日韩精品一区二区天天拍小说| 免费成人av| 国内精品视频在线观看| 亚洲一区在线观看免费观看电影高清| 亚洲日韩欧美视频一区| 久久综合久久综合这里只有精品| 久久久九九九九| 国产日韩欧美在线| 午夜精品久久久久久99热| 先锋影音久久久| 国产精品视频久久久| 中文成人激情娱乐网| 午夜激情综合网| 国产精品久久久久免费a∨大胸| 一本久道久久综合中文字幕| 一区二区三区视频免费在线观看| 欧美精品久久久久a| 亚洲欧洲一二三| 一区二区欧美在线观看| 欧美午夜精品久久久| 一区二区三区高清在线观看| 亚洲欧美成人一区二区在线电影 | 国产精品免费看久久久香蕉| 亚洲私人影院在线观看| 午夜在线视频一区二区区别| 国产美女一区二区| 欧美一级成年大片在线观看| 久久久久久国产精品一区| 国精品一区二区| 蜜桃精品一区二区三区| 亚洲三级性片| 亚洲欧洲av一区二区| 国产亚洲人成a一在线v站| 久久香蕉精品| 亚洲精品久久| 久久aⅴ国产欧美74aaa| 亚洲黄色尤物视频| 欧美精品在线观看| 亚洲一区二区三区在线看| 久久婷婷国产麻豆91天堂| 最新69国产成人精品视频免费| 欧美另类女人| 先锋亚洲精品| 亚洲国产欧美在线| 午夜精品一区二区三区在线视 | 在线欧美日韩| 欧美三级午夜理伦三级中视频| 亚洲永久免费视频| 欧美成人午夜免费视在线看片 | 91久久黄色| 欧美午夜精品理论片a级按摩| 先锋影音久久久| 亚洲人成小说网站色在线| 香蕉久久夜色| 日韩一级视频免费观看在线| 国产一区二区三区网站| 欧美日韩黄色一区二区| 久久另类ts人妖一区二区| 在线视频一区二区| 欧美黄色影院| 久久精品一区四区| 亚洲一区成人| 亚洲人成免费| 极品尤物一区二区三区| 国产精品亚洲成人| 欧美精品一区二区视频| 久久久亚洲欧洲日产国码αv | 亚洲一级免费视频| 亚洲国产另类久久精品| 久久人体大胆视频| 午夜在线观看免费一区| 中国女人久久久| 亚洲激情视频网站| 黄色在线一区| 国产三级欧美三级| 国产精品久久久久久久午夜片| 欧美激情综合五月色丁香| 久久成人免费电影| 欧美一区二区三区另类| 亚洲视频在线观看视频| 99视频超级精品| 亚洲国产另类 国产精品国产免费| 麻豆国产va免费精品高清在线| 午夜在线视频观看日韩17c| 亚洲午夜久久久久久久久电影网| 亚洲免费av片| 99国产精品国产精品久久 | 欧美性生交xxxxx久久久| 欧美激情亚洲国产| 欧美大胆a视频| 久久尤物视频| 欧美成人日韩| 欧美激情在线狂野欧美精品| 欧美成年人网| 欧美精品一区二区三区久久久竹菊| 另类亚洲自拍| 欧美成人精品三级在线观看| 免费91麻豆精品国产自产在线观看| 久久午夜激情| 欧美激情片在线观看| 欧美黑人在线播放| 欧美日韩精品高清| 欧美性色综合| 国产欧美日韩专区发布| 国产自产v一区二区三区c| 国产一区二区三区视频在线观看| 韩日精品在线| 亚洲破处大片| 亚洲伊人伊色伊影伊综合网| 欧美一区二区私人影院日本| 久久久久国产精品麻豆ai换脸| 久久久91精品国产一区二区三区 | 亚洲国产精品久久久| 日韩视频在线免费| 亚洲在线免费视频| 久久精品卡一| 欧美激情一区二区三区成人| 国产精品高潮呻吟久久av无限| 国产视频在线观看一区 | 国产嫩草影院久久久久| 在线成人亚洲| 正在播放欧美视频| 久久精品91久久久久久再现| 久久综合久久美利坚合众国| 亚洲欧洲精品一区二区三区| 亚洲一区二区精品视频| 久久久久久久久久久久久女国产乱| 欧美精品一区二| 国产曰批免费观看久久久| 日韩视频三区| 久久久亚洲精品一区二区三区| 亚洲日韩成人| 欧美综合77777色婷婷| 欧美精品在线一区| 国产在线精品成人一区二区三区| 99国产成+人+综合+亚洲欧美| 久久久精彩视频| 亚洲乱码精品一二三四区日韩在线 | 久久久久久久久岛国免费| 亚洲激情自拍| 久久女同精品一区二区| 国产精品久久久91| 亚洲精品在线观看视频|