I have a clone function that succesfully clones the vertex and index buffers of a square with a texture. It displays it correctly. The linked list uses nodes with pData of type VOID that is statically cast to a CSprTex. The CSprTexdisplays and updates correctly but the texture is not displayed and I dont know why.
class CNode
{
public:
CNode(void);
~CNode(void);
UINT m_uNodeType; // Leaf or non leaf-(head or end)
VOID* pData; // Can be cast to any class type eg CSprite*
CNode* pNext; // Pointer to the next object
CNode* pPrev; // Pointer to the previous object
private:
};// CNode
CLinked list's Add Node function:
void CLinkedList::AddNode(VOID* pData)
{
g_FileDebug->Write("Add a Node\n");
CNode* pNewNode = new CNode; // Create the Node
pNewNode->pData = pData; // Assign the Sprite data
pNewNode->m_uNodeType = CNODE_NODE;
...// insert behind Node End
m_iNumberOfNodes++; // Keep track of how many nodes there are
g_FileDebug->WriteEx("Number of nodes = ", m_iNumberOfNodes);
}// AddNode
And this is how I draw it. with a loop that accesses the nodes.
CNode* pCurrentNode = m_LLFaces.m_HeadNode.pNext; // Point to first in list
while (pCurrentNode != &m_LLFaces.m_EndNode)
{
CSprTex* pSprCurrent = static_cast<CSprTex*>(pCurrentNode->pData); // Void to CSprite
if (pSprCurrent != NULL)
{
pSprCurrent->Orbit(index, 0.0f, index);
pSprCurrent->Rotate(m_fRotateXClone, m_fRotateY, m_fRotateZ);
pSprCurrent->SetTransformTransByRotXYZ();
pSprCurrent->SelectBuffers();
pSprCurrent->Draw();
}
pCurrentNode = pCurrentNode->pNext; // Go to next in the list
}// end while*>
This is the cloning function:
int CSpriteManager::Clone(CSprTex* pSource, CSprTex* pDest)
{
// vertex and index buffers
pDest->SetVertexBuffer(pSource->GetVertexBuffer());
pDest->SetIndexBuffer(pSource->GetIndexBuffer());
//pDest->m_pVertexBuffer = pSource->m_pVertexBuffer;
//pDest->m_pIndexBuffer = pSource->m_pIndexBuffer;
// number of verticies and indicies and primitive count
pDest->m_iNumOfVertices = pSource->m_iNumOfVertices;
pDest->m_iNumOfIndicies = pSource->m_iNumOfIndicies;
pDest->m_iPrimCount = pSource->m_iPrimCount;
// rotational and translational matricies
pDest->m_matRotateX = pSource->m_matRotateX;
pDest->m_matRotateY = pSource->m_matRotateY;
pDest->m_matRotateZ = pSource->m_matRotateZ;
pDest->m_matTranslate = pSource->m_matTranslate;
return (1);
}// Clone (overloaded)
So why doesn't the texture display? The square does display though and I can move (any number of them) independantly of the master. Cloning an object outside of the Linked list structure displays the texture fine. What am I missing?