⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corebone.cpp

📁 Cal3D实现虚拟角色 Cal3D实现虚拟角色
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//****************************************************************************//// corebone.cpp                                                               //// Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger                       ////****************************************************************************//// This library is free software; you can redistribute it and/or modify it    //// under the terms of the GNU Lesser General Public License as published by   //// the Free Software Foundation; either version 2.1 of the License, or (at    //// your option) any later version.                                            ////****************************************************************************//#ifdef HAVE_CONFIG_H#include "config.h"#endif//****************************************************************************//// Includes                                                                   ////****************************************************************************//#include "cal3d/error.h"#include "cal3d/corebone.h"#include "cal3d/coreskeleton.h"#include "cal3d/coremodel.h"#include "cal3d/coremesh.h"#include "cal3d/coresubmesh.h" /*****************************************************************************//** Constructs the core bone instance.  *  * This function is the default constructor of the core bone instance.  *****************************************************************************/CalCoreBone::CalCoreBone(const std::string& name)  : m_strName(name)  , m_pCoreSkeleton(0)  , m_parentId(-1)  , m_userData(0)  , m_boundingBoxPrecomputed(false){} /*****************************************************************************//** Adds a child ID.  *  * This function adds a core bone ID to the child ID list of the core bone  * instance.  *  * @param childId The ID of the core bone ID that shoud be added to the child  *                ID list.  *  * @return One of the following values:  *         \li \b true if successful  *         \li \b false if an error happend  *****************************************************************************/bool CalCoreBone::addChildId(int childId){  m_listChildId.push_back(childId);  return true;} /*****************************************************************************//** Calculates the current state.  *  * This function calculates the current state (absolute translation and  * rotation) of the core bone instance and all its children.  *****************************************************************************/void CalCoreBone::calculateState(){  if(m_parentId == -1)  {    // no parent, this means absolute state == relative state    m_translationAbsolute = m_translation;    m_rotationAbsolute = m_rotation;  }  else  {    // get the parent bone    CalCoreBone *pParent;    pParent = m_pCoreSkeleton->getCoreBone(m_parentId);    // transform relative state with the absolute state of the parent    m_translationAbsolute = m_translation;    m_translationAbsolute *= pParent->getRotationAbsolute();    m_translationAbsolute += pParent->getTranslationAbsolute();	m_rotationAbsolute = m_rotation;	m_rotationAbsolute *= pParent->getRotationAbsolute();  }  // calculate all child bones  std::list<int>::iterator iteratorChildId;  for(iteratorChildId = m_listChildId.begin(); iteratorChildId != m_listChildId.end(); ++iteratorChildId)  {    m_pCoreSkeleton->getCoreBone(*iteratorChildId)->calculateState();  }} /*****************************************************************************//** Returns the child ID list.  *  * This function returns the list that contains all child IDs of the core bone  * instance.  *  * @return A reference to the child ID list.  *****************************************************************************/std::list<int>& CalCoreBone::getListChildId(){  return m_listChildId;} /*****************************************************************************//** Returns the name.  *  * This function returns the name of the core bone instance.  *  * @return The name as string.  *****************************************************************************/const std::string& CalCoreBone::getName(){  return m_strName;} /*****************************************************************************//** Returns the parent ID.  *  * This function returns the parent ID of the core bone instance.  *  * @return One of the following values:  *         \li the \b ID of the parent  *         \li \b -1 if the core bone instance is a root core bone  *****************************************************************************/int CalCoreBone::getParentId(){  return m_parentId;} /*****************************************************************************//** Returns the rotation.  *  * This function returns the relative rotation of the core bone instance.  *  * @return The relative rotation to the parent as quaternion.  *****************************************************************************/const CalQuaternion& CalCoreBone::getRotation(){  return m_rotation;} /*****************************************************************************//** Returns the absolute rotation.  *  * This function returns the absolute rotation of the core bone instance.  *  * @return The absolute rotation to the parent as quaternion.  *****************************************************************************/const CalQuaternion& CalCoreBone::getRotationAbsolute(){  return m_rotationAbsolute;} /*****************************************************************************//** Returns the bone space rotation.  *  * This function returns the rotation to bring a point into the core bone  * instance space.  *  * @return The rotation to bring a point into bone space.  *****************************************************************************/const CalQuaternion& CalCoreBone::getRotationBoneSpace(){  return m_rotationBoneSpace;} /*****************************************************************************//** Returns the translation.  *  * This function returns the relative translation of the core bone instance.  *  * @return The relative translation to the parent as quaternion.  *****************************************************************************/const CalVector& CalCoreBone::getTranslation(){  return m_translation;} /*****************************************************************************//** Returns the absolute translation.  *  * This function returns the absolute translation of the core bone instance.  *  * @return The absolute translation to the parent as quaternion.  *****************************************************************************/const CalVector& CalCoreBone::getTranslationAbsolute(){  return m_translationAbsolute;} /*****************************************************************************//** Returns the bone space translation.  *  * This function returns the translation to bring a point into the core bone  * instance space.  *  * @return The translation to bring a point into bone space.  *****************************************************************************/const CalVector& CalCoreBone::getTranslationBoneSpace(){  return m_translationBoneSpace;} /*****************************************************************************//** Provides access to the user data.  *  * This function returns the user data stored in the core bone instance.  *  * @return The user data stored in the core bone instance.  *****************************************************************************/Cal::UserData CalCoreBone::getUserData(){  return m_userData;} /*****************************************************************************//** Sets the core skeleton.  *  * This function sets the core skeleton to which the core bone instance is  * attached to.  *  * @param pCoreSkeleton The core skeleton to which the core bone instance  *                      should be attached to.  *****************************************************************************/void CalCoreBone::setCoreSkeleton(CalCoreSkeleton *pCoreSkeleton)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -