How can I use D3DXFrameFind() to find multiple frames with the same name?
I want to control the matrix for different frames using the same name, but when I call D3DXFrameFind() once it only get one frame with that name.
Using D3DXFrameFind() to find multiple frame with the same name
Hi.
You will need to loop through all the frames and compare there names
something like this.
[source]
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void GetAllFrameNames(std::vector<std::string> *framenames)
{
if(FrameRoot == NULL)
return;//error empty frames
DWORD numframes = 0;
FrameRoot->Count(&numframes);
UINT currentindex = 0;
Frame *frame = NULL;
for(DWORD ctr = 0; ctr < numframes; ctr++)
{
//get the frames name
currentindex = 0;
frame = FrameRoot->Find(ctr, ¤tindex);
if(frame)
{
framenames->push_back(frame->Name);
}
}//end all frames
}//end GetAllFrameNames
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------
// Function to scan hierarchy for matching frame by index
//----------------------------------------------------------
Frame *Find(UINT index, UINT *Currentindex)
{
Frame *pFrame, *pFramePtr;
if(*Currentindex == index)
return this;
*Currentindex += 1;
// Return this frame instance if name matched
// Scan siblings
if((pFramePtr = (Frame*)pFrameSibling))
{
if((pFrame = pFramePtr->Find(index, Currentindex)))
return pFrame;
}
// Scan children
if((pFramePtr = (Frame*)pFrameFirstChild))
{
if((pFrame = pFramePtr->Find(index, Currentindex)))
return pFrame;
}
// Return none found
return NULL;
}//end Find
//////////////////////////////////////////////////////////////////////////
[/source]
You will need to loop through all the frames and compare there names
something like this.
[source]
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void GetAllFrameNames(std::vector<std::string> *framenames)
{
if(FrameRoot == NULL)
return;//error empty frames
DWORD numframes = 0;
FrameRoot->Count(&numframes);
UINT currentindex = 0;
Frame *frame = NULL;
for(DWORD ctr = 0; ctr < numframes; ctr++)
{
//get the frames name
currentindex = 0;
frame = FrameRoot->Find(ctr, ¤tindex);
if(frame)
{
framenames->push_back(frame->Name);
}
}//end all frames
}//end GetAllFrameNames
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------
// Function to scan hierarchy for matching frame by index
//----------------------------------------------------------
Frame *Find(UINT index, UINT *Currentindex)
{
Frame *pFrame, *pFramePtr;
if(*Currentindex == index)
return this;
*Currentindex += 1;
// Return this frame instance if name matched
// Scan siblings
if((pFramePtr = (Frame*)pFrameSibling))
{
if((pFrame = pFramePtr->Find(index, Currentindex)))
return pFrame;
}
// Scan children
if((pFramePtr = (Frame*)pFrameFirstChild))
{
if((pFrame = pFramePtr->Find(index, Currentindex)))
return pFrame;
}
// Return none found
return NULL;
}//end Find
//////////////////////////////////////////////////////////////////////////
[/source]
@ankhd: I thought about this idea, however I am concerned that it could slow down the rendering since I will be using that on alot of meshes.
Hello.
You may need to find all frames at load time
Then store them in a container ready to be used
At run time.
You may need to find all frames at load time
Then store them in a container ready to be used
At run time.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement