📄 coremodel.cpp
字号:
return -1; } // load a new core animation CalCoreAnimationPtr pCoreAnimation = CalLoader::loadCoreAnimation(strFilename, m_pCoreSkeleton.get()); if(!pCoreAnimation) return -1; // add core animation to this core model return addCoreAnimation(pCoreAnimation.get());} /*****************************************************************************//** Loads a core animation and bind it to a name. * * This function loads a core animation from a file. It is equivalent * to calling addAnimName(strAnimationName, loadCoreAnimation(strFilename)). * If strAnimationName is already associated to a coreAnimationId because * of a previous call to addAnimName, the same coreAnimationId will * be used. * * @param strFilename The file from which the core animation should be loaded * from. * @param strAnimationName A string that is associated with an anim ID number. * * @return One of the following values: * \li the assigned \b ID of the loaded core animation * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::loadCoreAnimation(const std::string& strFilename, const std::string& strAnimationName){ int id = -1; std::map<std::string, int>::iterator it = m_animationName.find(strAnimationName); if (it != m_animationName.end()) { id=(*it).second; // the core skeleton has to be loaded already if(!m_pCoreSkeleton) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } if(m_vectorCoreAnimation[id]) { CalError::setLastError(CalError::INDEX_BUILD_FAILED, __FILE__, __LINE__); return -1; } CalCoreAnimationPtr pCoreAnimation = CalLoader::loadCoreAnimation(strFilename, m_pCoreSkeleton.get()); if(!pCoreAnimation) return -1; pCoreAnimation->setName(strAnimationName); m_vectorCoreAnimation[id] = pCoreAnimation; } else { id = loadCoreAnimation(strFilename); if(id >= 0) addAnimationName(strAnimationName, id); } return id;} /*****************************************************************************//** Delete the resources used by the named core animation. The name must * be associated with a valid core animation Id with the function * getAnimationId. The caller must ensure that the corresponding is not * referenced anywhere otherwise unpredictable results will occur. * * @param name The symbolic name of the core animation to unload. * * @return One of the following values: * \li the core \b ID of the unloaded core animation * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreAnimation(const std::string& name){ int id = getCoreAnimationId(name); if(id >= 0) return unloadCoreAnimation(id); else return -1;} /*****************************************************************************//** Delete the resources used by a core animation. The caller must * ensure that the corresponding is not referenced anywhere otherwise * unpredictable results will occur. * * @param coreAnimationId The ID of the core animation that should be unloaded. * * @return One of the following values: * \li the core \b ID of the unloaded core animation * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreAnimation(int coreAnimationId){ if((coreAnimationId < 0) || (coreAnimationId >= (int)m_vectorCoreAnimation.size())) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } m_vectorCoreAnimation[coreAnimationId] = CalCoreAnimationPtr (0); return coreAnimationId;} /*****************************************************************************//** Loads a core material. * * This function loads a core material from a file. * * @param strFilename The file from which the core material should be loaded * from. * * @return One of the following values: * \li the assigned \b ID of the loaded core material * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::loadCoreMaterial(const std::string& strFilename){ // the core skeleton has to be loaded already if(!m_pCoreSkeleton) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } // load a new core material CalCoreMaterialPtr pCoreMaterial = CalLoader::loadCoreMaterial(strFilename); if(!pCoreMaterial) return -1; // add core material to this core model return addCoreMaterial(pCoreMaterial.get());} /*****************************************************************************//** Loads a core material and bind it to a name. * * This function loads a core material from a file. It is equivalent * to calling addMaterialName(strMaterialName, loadCoreMaterial(strFilename)). * If strMaterialName is already associated to a coreMaterialId because * of a previous call to addMaterialName, the same coreMaterialId will * be used. * * @param strFilename The file from which the core material should be loaded * from. * @param strMaterialName A string that is associated with an anim ID number. * * @return One of the following values: * \li the assigned \b ID of the loaded core material * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::loadCoreMaterial(const std::string& strFilename, const std::string& strMaterialName){ int id = -1; std::map<std::string, int>::iterator it = m_materialName.find(strMaterialName); if (it != m_materialName.end()) { id=(*it).second; // the core skeleton has to be loaded already if(!m_pCoreSkeleton) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } if(m_vectorCoreMaterial[id]) { CalError::setLastError(CalError::INDEX_BUILD_FAILED, __FILE__, __LINE__); return -1; } CalCoreMaterialPtr pCoreMaterial = CalLoader::loadCoreMaterial(strFilename); if(!pCoreMaterial) return -1; pCoreMaterial->setName(strMaterialName); m_vectorCoreMaterial[id] = pCoreMaterial; } else { id = loadCoreMaterial(strFilename); if(id >= 0) addMaterialName(strMaterialName, id); } return id;} /*****************************************************************************//** Delete the resources used by the named core material. The name must * be associated with a valid core material Id with the function * getMaterialId. The caller must ensure that the corresponding is not * referenced anywhere otherwise unpredictable results will occur. * * @param name The symbolic name of the core material to unload. * * @return One of the following values: * \li the core \b ID of the unloaded core material * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreMaterial(const std::string& name){ int id = getCoreMaterialId(name); if(id >= 0) return unloadCoreMaterial(id); else return -1;} /*****************************************************************************//** Delete the resources used by a core material. The caller must * ensure that the corresponding is not referenced anywhere otherwise * unpredictable results will occur. * * @param coreMaterialId The ID of the core material that should be unloaded. * * @return One of the following values: * \li the core \b ID of the unloaded core material * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreMaterial(int coreMaterialId){ if((coreMaterialId < 0) || (coreMaterialId >= (int)m_vectorCoreMaterial.size())) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } m_vectorCoreMaterial[coreMaterialId] = CalCoreMaterialPtr(0); return coreMaterialId;} /*****************************************************************************//** Loads a core mesh. * * This function loads a core mesh from a file. * * @param strFilename The file from which the core mesh should be loaded from. * * @return One of the following values: * \li the assigned \b ID of the loaded core mesh * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::loadCoreMesh(const std::string& strFilename){ // the core skeleton has to be loaded already if(!m_pCoreSkeleton) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } // load a new core mesh CalCoreMeshPtr pCoreMesh = CalLoader::loadCoreMesh(strFilename); if(!pCoreMesh) return -1; // add core mesh to this core model return addCoreMesh(pCoreMesh.get());} /*****************************************************************************//** Loads a core mesh and bind it to a name. * * This function loads a core mesh from a file. It is equivalent * to calling addMeshName(strMeshName, loadCoreMesh(strFilename)). * If strMeshName is already associated to a coreMeshId because * of a previous call to addMeshName, the same coreMeshId will * be used. * * @param strFilename The file from which the core mesh should be loaded * from. * @param strMeshName A string that is associated with an anim ID number. * * @return One of the following values: * \li the assigned \b ID of the loaded core mesh * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::loadCoreMesh(const std::string& strFilename, const std::string& strMeshName){ int id = -1; std::map<std::string, int>::iterator it = m_meshName.find(strMeshName); if (it != m_meshName.end()) { id=(*it).second; // the core skeleton has to be loaded already if(!m_pCoreSkeleton) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } if(m_vectorCoreMesh[id]) { CalError::setLastError(CalError::INDEX_BUILD_FAILED, __FILE__, __LINE__); return -1; } CalCoreMeshPtr pCoreMesh = CalLoader::loadCoreMesh(strFilename); if(!pCoreMesh) return -1; pCoreMesh->setName(strMeshName); m_vectorCoreMesh[id] = pCoreMesh; } else { id = loadCoreMesh(strFilename); if(id >= 0) addMeshName(strMeshName, id); } return id;} /*****************************************************************************//** Delete the resources used by the named core mesh. The name must * be associated with a valid core mesh Id with the function * getMeshId. The caller must ensure that the corresponding is not * referenced anywhere otherwise unpredictable results will occur. * * @param name The symbolic name of the core mesh to unload. * * @return One of the following values: * \li the core \b ID of the unloaded core mesh * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreMesh(const std::string& name){ int id = getCoreMeshId(name); if(id >= 0) return unloadCoreMesh(id); else return -1;} /*****************************************************************************//** Delete the resources used by a core mesh. The caller must * ensure that the corresponding is not referenced anywhere otherwise * unpredictable results will occur. * * @param coreMeshId The ID of the core mesh that should be unloaded. * * @return One of the following values: * \li the core \b ID of the unloaded core mesh * \li \b -1 if an error happend *****************************************************************************/int CalCoreModel::unloadCoreMesh(int coreMeshId){ if((coreMeshId < 0) || (coreMeshId >= (int)m_vectorCoreMesh.size())) { CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__); return -1; } m_vectorCoreMesh[coreMeshId] = CalCoreMeshPtr(0); return coreMeshId;} /*****************************************************************************//** Loads the core skeleton. * * This function loads the core skeleton from a file. * * @param strFilename The file from which the core skeleton should be loaded * from. * * @return One of the following values: * \li \b true if successful * \li \b false if an error happend *****************************************************************************/bool CalCoreModel::loadCoreSkeleton(const std::string& strFilename){ // load a new core skeleton m_pCoreSkeleton = CalLoader::loadCoreSkeleton(strFilename); return bool(m_pCoreSkeleton);} /*****************************************************************************//** Saves a core animation. * * This function saves a core animation to a file. * * @param strFilename The file to which the core animation should be saved to.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -