Discussion:
How to implement this save function?
(too old to reply)
Jack
2009-10-27 10:16:55 UTC
Permalink
Dear friends,


[code]
HRESULT AddObjectOffsetTransform
(
SSaveContext *psc,
INode *pNode,
LPDIRECTXFILEDATA pParent,
LPDIRECTXFILEDATA *ppMeshParent
)
{
HRESULT hr = S_OK;
PBYTE pbData = NULL;
PBYTE pbCur;
DWORD cbSize;
LPDIRECTXFILEDATA pDataObject = NULL;
Matrix3 matNodeTM;
Matrix3 matObjTMAfterWSM;
Matrix3 matObjectOffset;
LPDIRECTXFILEDATA pObjectOffset = NULL;

// check to see if the node has an object offset matrix
matNodeTM = pNode->GetNodeTM(0);
matObjTMAfterWSM = pNode->GetObjTMAfterWSM(0);

if( !(matObjTMAfterWSM == matNodeTM) )
{
// the mesh is positioned offset from the node, so add another
// frame (unnamed) to offset the mesh without affecting the node's
children
// and/or animation attached to the node


hr = psc->m_pxofsave->CreateDataObject(TID_D3DRMFrame,
NULL,
NULL,
0,
NULL,
&pObjectOffset
);

matObjectOffset = matObjTMAfterWSM * Inverse(matNodeTM);

cbSize = 16*sizeof(float);

pbCur = pbData = new BYTE[cbSize];
if (pbData == NULL)
{
hr = E_OUTOFMEMORY;
goto e_Exit;
}

WRITE_MATRIX4_FROM_MATRIX3(pbCur, matObjectOffset);

hr = psc->m_pxofsave->CreateDataObject(TID_D3DRMFrameTransformMatrix,
NULL,
NULL,
cbSize,
pbData,
&pDataObject
);
if (FAILED(hr))
goto e_Exit;

//////////////////////////////////////////////
// How to implement this? Adding pDataObject as a child of pObjectOffset?
hr = pObjectOffset->AddDataObject(pDataObject);
if (FAILED(hr))
goto e_Exit;

////////////////////////////////////////////////////////////////////////
// Also, how to implement this? Adding pObjectOffset as a child of pParent
while not affecting pDataObject?
hr = pParent->AddDataObject(pObjectOffset);
if (FAILED(hr))
goto e_Exit;


*ppMeshParent = pObjectOffset;
}
else // identity object offset, mesh should use node as parent
{
*ppMeshParent = pParent;
}


e_Exit:
delete []pbData;
RELEASE(pDataObject);
RELEASE(pObjectOffset);

return hr;
}
[/code]

Could anyone lend me a hand in implementing
the functions above which have parent/child
relationships (found in DX9 SDK) ? I need some source code snippets....

Thanks
Jack
Tim Roberts
2009-10-28 06:59:18 UTC
Permalink
Post by Jack
//////////////////////////////////////////////
// How to implement this? Adding pDataObject as a child of pObjectOffset?
hr = pObjectOffset->AddDataObject(pDataObject);
if (FAILED(hr))
goto e_Exit;
////////////////////////////////////////////////////////////////////////
// Also, how to implement this? Adding pObjectOffset as a child of pParent
while not affecting pDataObject?
hr = pParent->AddDataObject(pObjectOffset);
if (FAILED(hr))
goto e_Exit;
What do you mean by "how to implement this"? Are pParent and pObjectOffset
pointing to objects that you wrote, which happen to implement
IDirectXFileData? If so, then just add a collection to your object (like
STL list or ATL list), and have AddDataObject add the new object to that
collection.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts
2009-10-28 06:59:18 UTC
Permalink
Post by Jack
//////////////////////////////////////////////
// How to implement this? Adding pDataObject as a child of pObjectOffset?
hr = pObjectOffset->AddDataObject(pDataObject);
if (FAILED(hr))
goto e_Exit;
////////////////////////////////////////////////////////////////////////
// Also, how to implement this? Adding pObjectOffset as a child of pParent
while not affecting pDataObject?
hr = pParent->AddDataObject(pObjectOffset);
if (FAILED(hr))
goto e_Exit;
What do you mean by "how to implement this"? Are pParent and pObjectOffset
pointing to objects that you wrote, which happen to implement
IDirectXFileData? If so, then just add a collection to your object (like
STL list or ATL list), and have AddDataObject add the new object to that
collection.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Continue reading on narkive:
Loading...