Пример #1
0
void CTargetMenu::Show()
{
	CObjCHAR *pObj = (CObjCHAR*)g_pObjMGR->Get_CharOBJ( m_iTargetAvatarID, true );

	if( pObj == NULL )
		return;
	
	///Target이 아바타일경우에만 현재 스크린 좌표에 따라서 윈도우의 위치 조정
	if( pObj->Get_TYPE() == OBJ_AVATAR ) 
	{
		D3DVECTOR   PosSCR;
		POINT		ptNew;
		pObj->GetScreenPOS (PosSCR);	
		ptNew.x = (int)PosSCR.x - GetWidth() / 2;
		ptNew.y = (int)PosSCR.y - ( GetHeight() * 2 / 3 );
		MoveWindow( ptNew );
		CTDialog::Show();
	}
	SetEnableChild( IID_BTN_FRIEND, false );
	SetEnableChild(	IID_BTN_INFORMATION,false );

}
void CObjCHAR_Collision2NPC::CollisionDetectionAvatar2Mob(CObjCHAR * pObjAvater)
{
	m_iObjTYPE = pObjAvater->Get_TYPE();

	if((m_iObjTYPE != OBJ_AVATAR) && (m_iObjTYPE != OBJ_USER) && (m_iObjTYPE != OBJ_CART) && (m_iObjTYPE != OBJ_CGEAR) && (m_iObjTYPE != OBJ_NRIDE))
		return;

	if (pObjAvater->GetPetMode() >= 0) { // if is on the PET, then ignore UpdateHeight
		return;
	}

	CObjCHAR *pObjectChar;
	HNODE hNPCBoneNode;
    	
	float fAvaterPositionXYZ[3];
	float fAvaterFrontPositionXYZ[3];
	float fPreAvaterRotaitonWXYZ[4];
	float fPreAvaterPositionXYZ[3];
	float fPreAvaterFrontPositionXYZ[3];

	float fBoneRotationWXYZ[4];
	float fBonePositionXYZ[3];
	float fPreBoneRotaitonWXYZ[4];
	float fPreBonePositionXYZ[3];

    D3DXVECTOR4 vlocalPos, vWorldPos;
    D3DXMATRIX boneModelM, bonePreModelM, invBonePreModelM;
	D3DXMATRIX boneModelRotationM; 
	
	Initialize(pObjAvater);
	
	::getPosition(m_hNodeModel, fAvaterPositionXYZ);
	fAvaterFrontPositionXYZ[0] = fAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
	fAvaterFrontPositionXYZ[1] = fAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
	fAvaterFrontPositionXYZ[2] = fAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;

	classDLLNODE< int > *pNode;
	pNode = g_pObjMGR->m_CharLIST.GetHeadNode ();
	
	while( pNode ) 
	{
		if ( g_pObjMGR->m_pOBJECTS[ pNode->DATA ] ) 
		{			
			if (g_pObjMGR->m_pOBJECTS[ pNode->DATA ]) {

				if(g_pObjMGR->m_pOBJECTS[ pNode->DATA ]->IsNPC())
				{
					pObjectChar = (CObjCHAR*)g_pObjMGR->m_pOBJECTS[ pNode->DATA ];
					if(pObjectChar->m_bCollisionOnOff)
					{
						hNPCBoneNode = ::getBone(pObjectChar->GetZMODEL(), pObjectChar->m_iCollisionBoneIndex);
						getRotationQuad(hNPCBoneNode, fBoneRotationWXYZ);
						getPosition(hNPCBoneNode, fBonePositionXYZ);
						
						D3DXMatrixRotationQuaternion(&boneModelM, &D3DXQUATERNION(fBoneRotationWXYZ[1], fBoneRotationWXYZ[2], fBoneRotationWXYZ[3], fBoneRotationWXYZ[0]));
						boneModelM._41 = fBonePositionXYZ[0];	boneModelM._42 = fBonePositionXYZ[1];	boneModelM._43 = fBonePositionXYZ[2];

//						::InputSceneOBB2(fBonePositionXYZ, fBoneRotationWXYZ, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2]);
//						::InputSceneSphere(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2], 50.0f);
   										
						if(CollisionPosition2OBBOnOff(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2])))
						{
							::getPrevPosition (hNPCBoneNode, fPreBonePositionXYZ);
							::getPrevRotation (hNPCBoneNode, fPreBoneRotaitonWXYZ);

							::getPrevPosition (m_hNodeModel, fPreAvaterPositionXYZ);
							::getPrevRotation (m_hNodeModel, fPreAvaterRotaitonWXYZ);
							
							fAvaterFrontPositionXYZ[0] = fPreAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
							fAvaterFrontPositionXYZ[1] = fPreAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
							fAvaterFrontPositionXYZ[2] = fPreAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;
							
							
							if(CollisionPosition2OBBOnOff(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2])))
							{
								D3DXVECTOR3 vContactPositon;
								CollisionPosition2OBBResponse(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2]), &vContactPositon);

								fPreAvaterPositionXYZ[0] = vContactPositon.x - m_vLocalCollisionPoint.x;
								fPreAvaterPositionXYZ[1] = vContactPositon.y - m_vLocalCollisionPoint.y;
								fPreAvaterPositionXYZ[2] = vContactPositon.z - m_vLocalCollisionPoint.z;
										
							}
						
							
/*							fPreAvaterFrontPositionXYZ[0] = fPreAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
                            fPreAvaterFrontPositionXYZ[1] = fPreAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
							fPreAvaterFrontPositionXYZ[2] = fPreAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;
			
							
							D3DXMatrixRotationQuaternion(&bonePreModelM, &D3DXQUATERNION(fPreBoneRotaitonWXYZ[1], fPreBoneRotaitonWXYZ[2], fPreBoneRotaitonWXYZ[3], fPreBoneRotaitonWXYZ[0]));
						    bonePreModelM._41 = fPreBonePositionXYZ[0];	bonePreModelM._42 = fPreBonePositionXYZ[1];	bonePreModelM._43 = fPreBonePositionXYZ[2];
							
							::InputSceneSphere(m_vLocalCollisionPoint.x + fPreAvaterPositionXYZ[0], m_vLocalCollisionPoint.y + fPreAvaterPositionXYZ[1], m_vLocalCollisionPoint.z + fPreAvaterPositionXYZ[2], 50.0f);
   							
							D3DXVECTOR3 vContactPoint;							
							if(CollisionPosition2OBBOnOff(&bonePreModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fPreAvaterFrontPositionXYZ[0], fPreAvaterFrontPositionXYZ[1], fPreAvaterFrontPositionXYZ[2])))
							{
								if(ContactRay2OBBIn(&bonePreModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &vContactPoint))
								{
									fPreAvaterPositionXYZ[0] = vContactPoint.x;
									fPreAvaterPositionXYZ[1] = vContactPoint.y;
									fPreAvaterPositionXYZ[2] = vContactPoint.z;
								}
								else
								{
									assert(true);

								}
							}
												
							D3DXMatrixInverse(&invBonePreModelM, NULL, &bonePreModelM);
								
							boneModelRotationM = invBonePreModelM * boneModelM;
                                
							D3DXVec4Transform(&vWorldPos, &D3DXVECTOR4(fPreAvaterPositionXYZ[0], fPreAvaterPositionXYZ[1], fPreAvaterPositionXYZ[2], 1.0f), &boneModelRotationM);
						
							fPreAvaterPositionXYZ[0] = vWorldPos.x - m_vLocalCollisionPoint.x;
							fPreAvaterPositionXYZ[1] = vWorldPos.y - m_vLocalCollisionPoint.y;
							fPreAvaterPositionXYZ[2] = vWorldPos.z - m_vLocalCollisionPoint.z;

*/							
							if(true)
							{
								m_pObjAvater->Set_CurPOS(D3DXVECTOR3(fPreAvaterPositionXYZ[0], fPreAvaterPositionXYZ[1], fPreAvaterPositionXYZ[2]));
							
								if(m_iObjTYPE == OBJ_USER)
									g_pNet->Send_cli_CANTMOVE();
								else
								{
									if(m_iObjTYPE == OBJ_CGEAR||m_iObjTYPE ==OBJ_NRIDE)
									{
										CObjCastleGear* pCgear = (CObjCastleGear*)pObjAvater;
										CObjCHAR* pParent = pCgear->GetParent();
										
										if(pParent)
										{
											if( pParent->Get_TYPE() == OBJ_USER)
												g_pNet->Send_cli_CANTMOVE();
										}
									}
									else if(m_iObjTYPE == OBJ_CART)
									{
										CObjCART* pCart = (CObjCART*)pObjAvater;
										CObjCHAR* pParent = pCart->GetParent();
										if( pParent )
										{
											if( pParent->Get_TYPE() == OBJ_USER)
												g_pNet->Send_cli_CANTMOVE();
										}
									}

								}
								
								m_pObjAvater->SetCMD_STOP();
								setPositionVec3( m_hNodeModel, fPreAvaterPositionXYZ );
							}

							::setRotationQuat(m_hNodeModel, fPreAvaterRotaitonWXYZ); 
							::stopModelRotation(m_hNodeModel);

							if(m_iObjTYPE == OBJ_CGEAR||m_iObjTYPE == OBJ_NRIDE)
							{
								CObjCastleGear* pCgear = (CObjCastleGear*)pObjAvater;
								CObjCHAR* pParent = pCgear->GetParent();
								if( pParent )
								{
									pParent->Set_CurPOS( pObjAvater->Get_CurPOS() );
								}
							}
							else if(m_iObjTYPE == OBJ_CART)
							{
								CObjCART* pCart = (CObjCART*)pObjAvater;
								CObjCHAR* pParent = pCart->GetParent();
								if( pParent )
								{
									pParent->Set_CurPOS( pObjAvater->Get_CurPOS() );
								}

							}


						}
						
					}
                 
				}
			}			
		}

		pNode = g_pObjMGR->m_CharLIST.GetNextNode( pNode );
	} 
}