HRESULT SceneGraphEditor::Initialize(__in ISceneGraph *pSceneGraph, __in ISceneObjectCamera *pCamera, const bool &bDrawGrid) { if (!pSceneGraph || !pCamera) return E_INVALIDARG; HRESULT hr = CreateGroup(L"SceneGraphEditor", &m_spContent); IF_FAILED_RETURN(hr); SmartPtr<ISceneObjectGroup> spRoot; hr = pSceneGraph->GetSceneRoot(&spRoot); IF_FAILED_RETURN(hr); m_spSceneGraph = pSceneGraph; hr = spRoot->AddObject(m_spContent.CastTo<ISceneObject>()); IF_FAILED_RETURN(hr); m_DrawGrid = bDrawGrid; m_spCamera = pCamera; if (bDrawGrid) { hr = CreateSceneGrid(); } return hr; }
HRESULT SceneGraphEditor::AddToGroup(__in ISceneObject *pObject, __in UINT depth) { // Invalid depth if (m_PendingGroups.Length() != depth) { return E_INVALIDARG; } HRESULT hr; if (m_PendingGroups.Length() == 0) { hr = m_spContent->AddObject(pObject); } else { SmartPtr<ISceneObjectGroup> spGroup = m_PendingGroups.GetLast(); hr = spGroup->AddObject(pObject); } return m_spSceneGraph->Validate(); }