3DFunction.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:11k
- #include "stdafx.h"
- #include "XMudClient.h"
- #include "MainScreen.h"
- #include "3DFunction.h"
- #include "D3DRMScreen.h"
- #include "MenuCreateNew.h"
- #include "MapInfo.h"
- #include "NpcInfo.h"
- #include "CommunicateMsg.h"
- #include "CommandCheck.h"
- #include "FacePlate.h"
- extern RECT rc3DMainFace;
- extern CList <CPlayerInfo*,CPlayerInfo*> playerlist;
- extern CList <CMapInfo *, CMapInfo *> maplist;
- extern CMapInfo * lpMapInfo;
- extern CRITICAL_SECTION csAnimation;
- extern CList <animationCallbackArgs *, animationCallbackArgs *> animationlist;
- extern CList<CExitInfo * ,CExitInfo*> exitlist;
- extern CExitInfo *lpExitInfo;
- extern SOCKET hLCltForRSvrSock;
- extern CMainScreen m_MainScreen;
- extern CMesssageWnd m_MessageWnd;
- extern LPDIRECT3DRM3 g_lpD3DRM;
- extern rmfullglobals myglobs;
- extern LPDIRECT3DRMFRAME3 g_lpplayer;
- extern LPDIRECT3DRMFRAME3 g_sFrame;
- extern D3DVECTOR g_PlayAndCameraPos;
- extern int g_playerState;
- extern int g_nGameState;
- extern BOOL g_Redraw2dFace[2];
- extern PathInfo info;
- extern D3DVECTOR g_CameraPosition;
- extern char szSendBuf[];
- BOOL g_bClientNet = TRUE;
- void D3DOnLButtonDown(POINT Pos)
- {
- animationCallbackArgs *cb;
- CPlayerInfo * lpPlayerInfo;
- int fnum;
- D3DVECTOR aimPosite;
- LPDIRECT3DRMVISUAL visual;
- LPDIRECT3DRMPICKED2ARRAY picked;
- D3DRMRAY rmRay;
- LPDIRECT3DRMFRAMEARRAY frames;
- LPDIRECT3DRMFRAME frame;
- LPDIRECT3DRMFRAME3 pFrame3;
- LPDIRECT3DRMFRAME3 roomFrame3;
- if(maplist.IsEmpty())return;
-
- lpPlayerInfo = playerlist.GetHead();
- if(lpPlayerInfo->m_iSTATUS != AOS_none && !(lpPlayerInfo->m_iSTATUS & AOS_act_facesb))
- return;
-
- if(m_MainScreen.bSelectOne)
- {
- m_MainScreen.szSelectOneName[0] = 0;
- m_MainScreen.DrawMsgBar(&m_MainScreen.rcSelectOnePos);
- m_MainScreen.bSelectOne = FALSE;
- if(m_MainScreen.bFaceSomeOne[0]||m_MainScreen.bFaceSomeOne[1])
- {
- m_MainScreen.bFaceSomeOne[0] = FALSE;
- m_MainScreen.bFaceSomeOne[1] = FALSE;
- lpPlayerInfo->m_iSTATUS = AOS_none;
- lpPlayerInfo->m_sPERSONA = _T("");
- }
- }
-
- myglobs.scene->GetChildren(&frames);
- fnum=frames->GetSize(); //0 ~ getsize()-1
- if(fnum<6)
- {
- frames->Release();
- return;
- }
- aimPosite = FindAndSelectVisual(Pos.x, Pos.y);
- if( g_sFrame == NULL){
- frames->Release();
- return;
- }
- frames->GetElement( 1, &frame);
- frame->QueryInterface(IID_IDirect3DRMFrame3, (LPVOID*)&pFrame3);
- if( g_sFrame == pFrame3 ){
- pFrame3->Release();
- frame->Release();
- frames->Release();
- return;
- }
- frame->Release();
- pFrame3->Release();
-
- frames->GetElement( 5, &frame);
- frame->QueryInterface(IID_IDirect3DRMFrame3, (LPVOID*)&pFrame3);
- roomFrame3=pFrame3;
- if( g_sFrame == pFrame3){
- roomFrame3->Release();
- pFrame3->Release();
- frame->Release();
- frames->Release();
- return;
- }
- frame->Release();
- pFrame3->Release();
- if(GetAsyncKeyState(VK_CONTROL)&0x8000){
- cb = animationlist.GetHead();
- cb->pathlist.RemoveAll();
-
- D3DVECTOR playerpos,camerapos;
- g_lpplayer->GetPosition(myglobs.scene, &playerpos);
- myglobs.camera->GetPosition(myglobs.scene, &camerapos);
- g_lpplayer->SetPosition( myglobs.scene,aimPosite.x, aimPosite.y, aimPosite.z);
-
- camerapos.x += aimPosite.x - playerpos.x;
- camerapos.z += aimPosite.z - playerpos.z;
-
- myglobs.camera->SetPosition(myglobs.scene, camerapos.x, camerapos.y, camerapos.z);
- myglobs.camera->LookAt(g_lpplayer, myglobs.scene, D3DRMCONSTRAIN_Z);
- myglobs.camera->GetPosition(myglobs.scene,&g_CameraPosition);
- roomFrame3->Release();
- frames->Release();
- return;
- }
- frames->GetElement( 4, &frame);
- frame->QueryInterface(IID_IDirect3DRMFrame3, (LPVOID*)&pFrame3);
- if( g_sFrame == pFrame3){
- rmRay.dvDir.x = aimPosite.x;
- rmRay.dvDir.y = aimPosite.y;
- rmRay.dvDir.z = aimPosite.z;
-
- rmRay.dvPos.x = aimPosite.x;
- rmRay.dvPos.y = aimPosite.y+10.0f;
- rmRay.dvPos.z = aimPosite.z;
-
- rmRay.dvDir.x -= rmRay.dvPos.x;
- rmRay.dvDir.y -= rmRay.dvPos.y;
- rmRay.dvDir.z -= rmRay.dvPos.z;
-
- myglobs.scene->RayPick(NULL, &rmRay, 0, &picked);
- if (picked){
- if (picked->GetSize()){
- LPDIRECT3DRMFRAMEARRAY sframes;
- LPDIRECT3DRMFRAME sframe;
- LPDIRECT3DRMFRAME3 spFrame3;
-
- picked->GetPick(0, &visual, &sframes, 0);
- sframes->GetElement(sframes->GetSize() - 1, &sframe);
- sframe->QueryInterface(IID_IDirect3DRMFrame3, (LPVOID*)&spFrame3);
- if( g_sFrame == spFrame3){
- spFrame3->Release();
- sframe->Release();
- sframes->Release();
- visual->Release();
- ChangePath(aimPosite,roomFrame3,0);
- }
- else
- {
- spFrame3->Release();
- sframe->Release();
- sframes->Release();
- visual->Release();
- }
- }
- picked->Release();
- }
- roomFrame3->Release();
- frames->Release();
- pFrame3->Release();
- frame->Release();
- return;
- }
-
- ChangePath(aimPosite,roomFrame3,1);
-
- roomFrame3->Release();
- pFrame3->Release();
- frames->Release();
- frame->Release();
- }
- void D3DOnLButtonUp(POINT Pos)
- {
- }
- void D3DOnRButtonDown(POINT Pos)
- {
- animationCallbackArgs *cb,*selfcb;
- CPlayerInfo *lpPlayerInfo;
- int i,j;
- D3DVECTOR aimPosite,tagPos;
- BOOL bFindPerson = FALSE;
- if(maplist.IsEmpty())return;
-
- lpPlayerInfo = playerlist.GetHead();
- if(!(lpPlayerInfo->m_iSTATUS == AOS_none || (lpPlayerInfo->m_iSTATUS & AOS_act_facesb)))
- return;
-
- aimPosite = FindAndSelectVisual(Pos.x, Pos.y);
- if(m_MainScreen.bSelectOne)
- {
- m_MainScreen.DrawMsgBar(&m_MainScreen.rcSelectOnePos);
- m_MainScreen.bSelectOne = FALSE;
- }
- if(m_MainScreen.bFaceSomeOne[0]||m_MainScreen.bFaceSomeOne[1])
- {
- m_MainScreen.bSelectOne = FALSE;
- m_MainScreen.bFaceSomeOne[0] = FALSE;
- m_MainScreen.bFaceSomeOne[1] = FALSE;
- lpPlayerInfo->m_iSTATUS = AOS_none;
- lpPlayerInfo->m_sPERSONA = _T("");
- }
- BOOL bFindSomebody = FALSE;
- j = animationlist.GetCount();
- for(i=1;i<j;i++){
- cb = animationlist.GetAt(animationlist.FindIndex(i));
- if(cb->PlayerState == DEAD) continue;
- cb->frame3obj->GetPosition(myglobs.scene, &tagPos);
- if(fabs(aimPosite.x-tagPos.x) < 0.9 && fabs(aimPosite.z-tagPos.z) < 0.9){
- strcpy(m_MainScreen.szSelectOneName,"