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

天行健 君子當自強而不息

Using the .X File Format(7)

Retrieving Data from a Data Object

Remember that data objects are containers for data, and if you're going to the trouble to enumerate data objects, it's a safe bet that you're after the data in each one. Once you've got a valid IDirectXFileData object that points at an enumerated data object, you can retrieve the object's instance name, template GUID, and data using a trio of functions. The first function, IDirectXFileData::GetName, retrieves the name of the data object instance.

HRESULT IDirectXFileData::GetName(
  LPSTR pstrNameBuf, // Name buffer
  LPDWORD pdwBufLen); // Size of name buffer

The GetName function takes two parameters−a pointer to a buffer that contains the name and a pointer to a variable that contains the name buffer's size (in bytes). Before you obtain a name from the GetName function, you first have to obtain the name's data size by specifying a NULL value for pstrNameBuf and supplying a value DWORD pointer for pdwBufLen.

// pData = pre−loaded IDirectXFileData object
// Get size of name, in bytes
DWORD Size;
pData−>GetName(NULL, &Size);

Once you've got the size of the name buffer, you can allocate an appropriate buffer and read in the name.

// Allocate name buffer and get name
char *Name = new char[Size];
pData−>GetName(Name, &Size);

While having the data object's instance name helps, you really need the GUID of the object's template to distinguish which template an object uses. To retrieve the GUID of the object's template, you use the IDirectXFileData::GetType function.

HRESULT IDirectXFileData::GetType(const GUID ** ppguid);

With only one parameter to use−a pointer to a const GUID pointer−you can call the GetType function using the following code:

const GUID *TemplateGUID = NULL;
pData−>GetType(&TemplateGUID);

Now that you have the GUID, you can compare it to a list of internal GUIDs (such as those from the standard templates or from your custom templates) and process the data appropriately. For instance, to check whether a data object's type matches that of the MeshNormals standard template, you can use the following code:

// TemplateGUID = template's GUID to check
if(*TemplateGUID == TID_D3DRMMeshNormals) {
  // Process MeshNormals template
}

Of course, knowing the object's template GUID can only get you so far. The real trick is to get at the data object's data. No problem! With one more simple function call at your disposal, your .X file parsing abilities will be nearly complete! The last function you use to access an object's data is GetData.

Retrieves the data for one of the object's members or the data for all members. Deprecated.

HRESULT GetData(
LPCSTR szMember,
DWORD * pcbSize,
void ** ppvData
);

Parameters

szMember
[in] Pointer to the name of the member for which to retrieve data. Specify NULL to retrieve all required members' data.
pcbSize
[out] Pointer to receive the ppvData buffer size, in bytes.
ppvData
[out] Address of a pointer to the buffer to receive the data associated with szMember. If szMember is NULL, ppvData is set to point to a buffer containing all required members' data in a contiguous block of memory.

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_BADARRAYSIZE, DXFILEERR_BADDataReference, DXFILEERR_BADVALUE.

Remarks

This method retrieves the data for required members of a data object but no data for optional (child) members. Use IDirectXFileData::GetNextObject to retrieve child objects.

To use the GetData function, you need to provide a pointer to access the data object's data buffer and a DWORD variable to contain the buffer's size (in bytes). Here's a snippet of code that shows how you can use GetData to obtain a pointer to the object's data and its size.

char *DataPtr;
DWORD DataSize;
pData−>GetData(NULL, &DataSize, (void**)&DataPtr);

The pointer to the data buffer now points to a block of contiguous memory that is structured just like the data object's template definition. You can access the data as a large buffer or, if you want to be crafty, you can create a structure to match the template's definition for easier access. For example, suppose you have enumerated the ColorRGBA standard template, which is defined as follows:

template ColorRGBA {
  <35FF44E0−6C7C−11cf−8F52−0040333594A3>
  FLOAT red;
  FLOAT green;
  FLOAT blue;
  FLOAT alpha;
}

To access the red, green, blue, and alpha values, you can grab the data pointer and cast it to a float data type.

DWORD DataSize;
float *DataPtr;

pData−>GetData(NULL, &DataSize, (void**)&DataPtr);

float red = *DataPtr++;
float green = *DataPtr++;
float blue = *DataPtr++;
float alpha = *DataPtr++;

While this approach is fine and dandy, you can process the object's data much easier by using a matching C structure.

typedef struct {
  float red, green, blue, alpha;
} sColorRGBA;

sColorRGBA *Color;
DWORD DataSize;
pData−>GetData(NULL, &DataSize, (void**)&Color);

Note Notice that the template's GUID or class name is not part of the data retrieved using IDirectXFileData: :GetData.
Once it is complete, the preceding code gives you the ability to access the colors using the structure instance.

float red = Color−>red;
float blue = Color−>blue;
float green = Color−>green;
float alpha = Color−>alpha;

Accessing single variables is easy, but what about strings and arrays? Arrays, being the easier of the two, are stored contiguously in memory, meaning that you can just increase the memory pointer that contains the object's data. For example, the following code shows you how to access the array of float values stored in a data object of the template type FloatKeys.

// Get the object's data size & pointer
DWORD DataSize;
DWORD *DataPtr;
pData−>GetData(NULL, &DataSize, (void**)&DataPtr);

// The FloatKeys template has a DWORD value 1st that defines how many float values are in the array
DWORD NumKeys = *DataPtr++;

// Next, an array of float values follows
for(DWORD i=0;i<NumKeys;i++) {
  float fValue = *(FLOAT*)DataPtr++;

Accessing arrays wasn't too difficult, so how about accessing strings? Again, it's an easy chore because strings are stored as pointers to a text buffer, which you can access much like I do in the following code. (I'm using the TextureFilename template as an example; it stores the name of a file to use for a texture.)

// Get the data pointer & size
DWORD DataSize;
DWORD *DataPtr;
pData−>GetData(NULL, &DataSize, (void**)&DataPtr);

// Now, access the filename text buffer
char *StringPtr = (char*)*DataPtr;
MessageBox(NULL, StringPtr, "Texture Filename", MB_OK);

With a simple cast to a char pointer, you were able to display the file name contained in the TextureFilename template. Now I know you've got to be banging your forehead and yelling, "Why didn't I see how easy this was before?" Whoa, down boy! I didn't immediately realize just how easy it was to work with .X files either. Now that the secret is out, nothing can stop you from using .X files almost exclusively in your own projects. All you need is a way to wrap up all of this .X parser functionality into a class, making it even easier to work with .X.


posted on 2008-04-17 19:15 lovedday 閱讀(438) 評論(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>
            久久亚洲午夜电影| 99精品国产热久久91蜜凸| 伊人久久综合97精品| 国产日韩精品一区二区| 国产一二精品视频| 亚洲国语精品自产拍在线观看| 91久久久精品| 亚洲一区免费观看| 欧美在线观看一区二区| 久久亚洲一区二区三区四区| 免播放器亚洲一区| 亚洲日本va在线观看| 亚洲黄一区二区三区| 一本色道久久加勒比精品| 亚洲一区二区三区高清| 久久亚洲国产成人| 国产精品进线69影院| 娇妻被交换粗又大又硬视频欧美| 亚洲国语精品自产拍在线观看| 中文在线不卡| 免费成人高清视频| 亚洲午夜精品久久| 开心色5月久久精品| 欧美特黄一级| 久久久综合免费视频| 国产精品magnet| 国产综合久久久久影院| 亚洲精品网站在线播放gif| 羞羞答答国产精品www一本| 久久婷婷国产麻豆91天堂| 亚洲激情在线| 欧美一区二区三区在| 欧美日韩 国产精品| 在线看片第一页欧美| 欧美影院在线| 一区二区三区不卡视频在线观看| 久久综合色播五月| 国产日韩专区| 欧美一区二区三区日韩视频| 亚洲麻豆一区| 欧美成人国产一区二区| 亚洲第一精品夜夜躁人人躁| 久久精品国产99国产精品| 在线一区二区日韩| 欧美人与性禽动交情品| 亚洲国产精品一区二区久| 久久一区二区三区四区| 亚洲一区二区在线观看视频| 欧美日韩精品综合| 一区二区三区四区五区精品| 欧美激情按摩| 美玉足脚交一区二区三区图片| 合欧美一区二区三区| 久久精品国产精品 | 亚洲大胆女人| 久久九九精品| 性8sex亚洲区入口| 国产一区在线免费观看| 久久精品二区亚洲w码| 亚洲欧美日韩国产中文在线| 国产精品国产三级国产aⅴ浪潮| 亚洲深夜福利网站| 一本色道久久综合亚洲精品按摩 | 午夜精品国产精品大乳美女| 国产精品一区二区三区四区五区 | 亚洲精品社区| 欧美精品免费视频| 在线视频精品一| 野花国产精品入口| 国产精品欧美日韩一区二区| 欧美一区三区三区高中清蜜桃| 亚洲女同精品视频| 国产一区91| 欧美成年人在线观看| 欧美本精品男人aⅴ天堂| 久久久久久久久岛国免费| 性做久久久久久久免费看| 亚洲综合不卡| 国产一区二区成人| 免费短视频成人日韩| 欧美黄色片免费观看| 中日韩男男gay无套| 亚洲一区二区精品视频| 国产日韩欧美在线播放不卡| 蜜臀99久久精品久久久久久软件| 欧美成人一区在线| 亚洲一区视频| 久久精品人人做人人爽| 99精品国产热久久91蜜凸| 亚洲私人影院在线观看| 狠狠色狠色综合曰曰| 亚洲激情视频网| 国产日韩一区在线| 日韩视频中午一区| 精品电影在线观看| 亚洲欧洲日本在线| 国产日韩欧美中文在线播放| 欧美国产三区| 国产午夜精品全部视频播放| 亚洲第一网站| 国产视频不卡| 亚洲伦理在线| 亚洲国产视频一区| 欧美一区高清| 亚洲欧美日韩一区在线| 欧美黑人多人双交| 久久亚洲一区二区| 国产精品―色哟哟| 亚洲乱码国产乱码精品精| 韩曰欧美视频免费观看| 一区二区免费在线视频| 亚洲国产日韩精品| 性久久久久久久久| 亚洲欧美日韩在线| 欧美日韩免费区域视频在线观看| 久久久无码精品亚洲日韩按摩| 欧美视频中文字幕在线| 亚洲国产成人久久| 曰韩精品一区二区| 性久久久久久久久久久久| 亚洲伊人色欲综合网| 欧美福利在线观看| 欧美www在线| 在线精品国产成人综合| 久久精品中文| 久久午夜视频| 国产综合色在线| 欧美一区视频| 久久亚洲精品伦理| 极品尤物av久久免费看| 久久国产黑丝| 久久久久久久久久久久久久一区 | 欧美日韩精品一区二区| 亚洲国产日韩欧美在线99| 在线观看国产成人av片| 久久亚洲欧美| 老鸭窝毛片一区二区三区| 香蕉成人久久| 国产亚洲综合性久久久影院| 亚洲天堂成人在线观看| 亚洲天堂第二页| 欧美色综合网| 亚洲综合成人婷婷小说| 欧美专区在线| 激情文学一区| 欧美大片在线看免费观看| 亚洲精品乱码久久久久久按摩观| 日韩一级在线| 国产精品videossex久久发布| 亚洲欧美国产77777| 久久乐国产精品| 亚洲国产成人午夜在线一区 | 国产精品在线看| 午夜精品在线看| 免费看的黄色欧美网站| 日韩视频不卡中文| 欧美日韩中文字幕日韩欧美| 亚洲欧美久久久久一区二区三区| 欧美一区二区高清在线观看| 国产一区二区日韩| 麻豆国产精品777777在线| 亚洲精品美女久久久久| 羞羞答答国产精品www一本| 亚洲电影免费观看高清完整版在线观看 | 亚洲精品乱码久久久久久日本蜜臀 | 欧美女同视频| 亚洲一区二区三区中文字幕| 久久久久久一区| 91久久久一线二线三线品牌| 欧美日韩国产成人在线91| 亚洲综合99| 亚洲国产日韩一级| 久久av免费一区| 亚洲国产日韩在线一区模特| 国产精品日韩在线播放| 欧美极品色图| 欧美在线91| 日韩视频二区| 久久午夜影视| 亚洲已满18点击进入久久| 伊人精品久久久久7777| 国产精品成人在线观看| 久久久久在线| 一区二区三区国产在线| 亚洲国产成人tv| 久久久久久伊人| 亚洲色图综合久久| 亚洲福利视频一区| 国产中文一区二区| 国产精品都在这里| 久久综合九色综合欧美就去吻| 欧美日韩亚洲91| 老司机久久99久久精品播放免费| 亚洲精品五月天| 在线国产精品播放| 欧美日韩免费看| 免费在线亚洲欧美| 午夜精品三级视频福利| 亚洲清纯自拍| 欧美承认网站|