VOID CGameInterface::PacketItem_UserItem(tActionItem* pActionItem, int targetServerID, fVector2& fvPos) { //空物品 if(!pActionItem || pActionItem->GetType() != AOT_ITEM) return; CObject_Item* pItem = (CObject_Item*)(((CActionItem_Item*)pActionItem)->GetItemImpl()); if(!pItem) return; //必须是能够使用的物品 if(pItem->GetItemClass()!=ICLASS_COMITEM && pItem->GetItemClass()!=ICLASS_TASKITEM) return; //特殊物品不能在背包中直接使用,例如,宠物技能书 STRING strTemp; if(!CObject_Item::CheckUseInPackage(pItem, strTemp)) { if(!strTemp.empty()) CGameProcedure::s_pEventSystem->PushEvent(GE_NEW_DEBUGMESSAGE, strTemp.c_str()); return; } //组队跟随中... if(CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_TeamFollowFlag()) return; //检查目前选中的目标 CObject* pObj = (CObject*)CObjectManager::GetMe()->FindServerObject(targetServerID); //检查物品是否能够直接使用 int objID; PET_GUID_t petID; bool bCanuseDir = ((CObject_Item_Medicine*)pItem)->IsValidTarget(pObj, fvPos, objID, petID); if(bCanuseDir) { WORLD_POS posTarget(fvPos.x, fvPos.y); //能够直接使用 CGUseItem msg; msg.SetBagIndex( pItem->GetPosIndex() ); msg.SetTargetObjID(objID); msg.SetTargetPetGUID(petID); msg.SetTargetPos(&posTarget); CNetManager::GetMe()->SendPacket( &msg ); return; } //如果已经选中目标,说明目标不合适,如果是用在自己宠物上的物品,说明宠物没有释放 if(pObj || ((CObject_Item_Medicine*)pItem)->IsTargetOne()) { CGameProcedure::s_pEventSystem->PushEvent(GE_NEW_DEBUGMESSAGE, "无效目标"); return; } //需要选中目标,在鼠标上挂上物品 CActionSystem::GetMe()->SetDefaultAction(pActionItem); }
//-------------------------------------------------------------------------------------------------- cv::Mat createChessboardPoseMatrix( const PoseData& poseData ) { cv::Mat poseMtx = cv::Mat::eye( 4, 4, CV_64FC1 ); double angleX = poseData.rotXYZ[ 0 ]; double angleY = poseData.rotXYZ[ 1 ]; double angleZ = poseData.rotXYZ[ 2 ]; cv::Mat rotMtx = createRotationMatrixZ( angleZ ) *createRotationMatrixY( angleY )*createRotationMatrixX( angleX ); cv::Mat rotTarget( poseMtx, cv::Rect( 0, 0, 3, 3 ) ); cv::Mat posTarget( poseMtx, cv::Rect( 3, 0, 1, 3 ) ); rotMtx.copyTo( rotTarget ); cv::Mat( poseData.position ).copyTo( posTarget ); return poseMtx; }
//-------------------------------------------------------------------------------------------------- cv::Mat createCameraWorldMatrix( const cv::Mat& cameraPos, const cv::Mat& cameraRotXYZDeg ) { cv::Mat cameraInAssemblySpaceMtx = cv::Mat::eye( 4, 4, CV_64FC1 ); double angleX = Utilities::degToRad( cameraRotXYZDeg.at<double>( 0, 0 ) ); double angleY = Utilities::degToRad( cameraRotXYZDeg.at<double>( 1, 0 ) ); double angleZ = Utilities::degToRad( cameraRotXYZDeg.at<double>( 2, 0 ) ); cv::Mat rotMtx = createRotationMatrixZ( angleZ ) *createRotationMatrixY( angleY )*createRotationMatrixX( angleX ); cv::Mat rotTarget( cameraInAssemblySpaceMtx, cv::Rect( 0, 0, 3, 3 ) ); cv::Mat posTarget( cameraInAssemblySpaceMtx, cv::Rect( 3, 0, 1, 3 ) ); rotMtx.copyTo( rotTarget ); cameraPos.copyTo( posTarget ); cv::Mat assemblyInWorldSpaceMtx = cv::Mat::eye( 4, 4, CV_64FC1 ); cv::Mat assemblyRotTarget( assemblyInWorldSpaceMtx, cv::Rect( 0, 0, 3, 3 ) ); cv::Mat assemblyRotMtx = createRotationMatrixZ( Utilities::degToRad( 180.0 ) ); assemblyRotMtx.copyTo( assemblyRotTarget ); return assemblyInWorldSpaceMtx*cameraInAssemblySpaceMtx; }