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

天行健 君子當自強而不息

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>
            宅男噜噜噜66国产日韩在线观看| 国产精品一区二区三区乱码| 韩国自拍一区| 亚洲欧美大片| 久久久久国产一区二区| 国产精品va在线播放| 亚洲一区二区3| 免费亚洲一区| 亚洲深夜福利视频| 国产日韩欧美在线看| 久久青草欧美一区二区三区| 亚洲电影免费在线| 欧美日韩一区二区三区在线看| 亚洲小视频在线观看| 久久免费的精品国产v∧| 91久久久国产精品| 国产精品久久久久av| 久久综合九色欧美综合狠狠| 日韩午夜三级在线| 久久久久国产免费免费| 欧美成人伊人久久综合网| 亚洲免费视频中文字幕| 亚洲大片在线观看| 一本色道精品久久一区二区三区 | 亚洲无线一线二线三线区别av| 国产精品分类| 激情亚洲网站| 国产综合色在线视频区| 国产精品久久久999| 国产专区精品视频| 一本色道久久加勒比精品| 欧美在现视频| 亚洲欧美日韩精品久久久| 玖玖精品视频| 久久成人精品无人区| 99这里只有精品| 久久不射中文字幕| 亚洲国产成人不卡| 美女久久一区| 欧美亚洲午夜视频在线观看| 亚洲另类自拍| 亚洲精品网址在线观看| 久久riav二区三区| 香蕉尹人综合在线观看| 亚洲一区二区动漫| 欧美精品啪啪| 欧美精品一区二区蜜臀亚洲| 欧美一级理论片| 欧美日本一区| 亚洲精品在线观看免费| 亚洲久色影视| 久久一区二区三区国产精品| 久久综合伊人77777蜜臀| 亚洲午夜久久久久久久久电影网| 久久野战av| 免播放器亚洲一区| 国产一区二区三区的电影| 欧美精品九九| 亚洲精品一区二区网址| 亚洲日本成人网| 久久综合狠狠综合久久综合88| 一区二区三区鲁丝不卡| 中国日韩欧美久久久久久久久| 欧美国产欧美综合| 欧美精品免费在线| 日韩亚洲在线观看| 欧美一级电影久久| 欧美成人日韩| 久久躁日日躁aaaaxxxx| 禁久久精品乱码| 免费欧美在线| 欧美激情精品久久久久久蜜臀 | 久久成人综合网| 免费在线看一区| 欧美色图天堂网| 国产综合色在线视频区| 久久精品国产久精国产思思| 欧美国产精品va在线观看| 免费成人av| 夜夜嗨一区二区三区| 一片黄亚洲嫩模| 国产一区二区三区的电影| 狼人天天伊人久久| 欧美大胆成人| 黄网站免费久久| 欧美大尺度在线| 欧美性色综合| 欧美一区国产一区| 久久综合伊人77777麻豆| 亚洲精品美女在线| 99精品国产99久久久久久福利| 久久激情一区| 亚洲日本视频| 午夜精品成人在线| 欧美日韩三级一区二区| 校园春色国产精品| 久久夜色精品亚洲噜噜国产mv| 亚洲精品久久久久| 午夜日韩电影| 99精品国产福利在线观看免费 | 国产亚洲一本大道中文在线| 欧美成人精品在线视频| 一区二区三区精品在线| 韩日欧美一区| 99视频超级精品| 亚洲电影在线播放| 亚洲综合色婷婷| 99国产精品私拍| 亚洲第一在线视频| 亚洲综合成人在线| 亚洲天堂成人在线观看| 狠狠色狠狠色综合系列| 亚洲人成小说网站色在线| 久久精品伊人| 国语自产精品视频在线看一大j8 | 亚洲精品美女| 欧美一区在线看| 亚洲一区二区三区四区五区午夜| 久久久水蜜桃av免费网站| 狠狠久久婷婷| 亚洲影视中文字幕| 日韩一级成人av| 久久久噜噜噜久久久| 久久精品2019中文字幕| 国产精品色网| 久久国产精品72免费观看| 欧美久久久久免费| 欧美高清影院| 影音先锋日韩有码| 亚洲高清视频一区二区| 国内精品免费午夜毛片| 性欧美暴力猛交69hd| 午夜精品一区二区三区在线| 欧美一区二区三区啪啪| 亚洲欧美日韩综合aⅴ视频| 欧美成人日韩| 亚洲高清在线| 亚洲精品日韩在线观看| 欧美激情精品久久久久久黑人| 亚洲高清视频的网址| 亚洲精品久久久久久下一站 | 欧美视频1区| 国产精品99久久久久久人| 亚洲天堂第二页| 国产精品久久久久永久免费观看| 欧美在线观看网站| 国产美女精品在线| 久久久久成人精品免费播放动漫| 久热精品视频在线观看一区| 亚洲高清二区| 欧美精品福利视频| 一本色道久久综合亚洲91| 亚洲欧美制服中文字幕| 国产精品一区二区久久国产| 性感少妇一区| 亚洲电影免费观看高清完整版在线观看| 亚洲高清毛片| 欧美精品一区在线播放| 亚洲午夜高清视频| 久久久最新网址| 亚洲精品一区二| 欧美视频在线观看一区二区| 欧美亚洲三区| 亚洲国产女人aaa毛片在线| 狠狠久久五月精品中文字幕| 久久精品中文字幕一区二区三区 | 午夜精品福利在线观看| 久久久久久综合| 亚洲伦伦在线| 国产一区日韩一区| 欧美福利一区| 欧美国产高清| 久久不射网站| 亚洲免费观看高清在线观看 | 欧美国产日本| 国内精品视频久久| 久久综合国产精品| 亚洲一区二区免费看| 免费成人黄色| 欧美一二三区在线观看| 亚洲人线精品午夜| 国产欧美日韩激情| 亚洲精品国产精品乱码不99按摩| 亚洲主播在线观看| 好看的日韩视频| 欧美性做爰猛烈叫床潮| 麻豆视频一区二区| 亚洲欧美另类在线| 亚洲精品久久久久久久久久久久 | 国产亚洲欧美另类中文| 欧美激情亚洲综合一区| 欧美中文字幕视频| 日韩午夜av电影| 欧美激情第9页| 久久亚洲精品视频| 久久国产精品99久久久久久老狼| 亚洲视频在线观看一区| 亚洲人妖在线| 亚洲黄色成人| 欧美精品粉嫩高潮一区二区|