Created
April 15, 2015 14:56
-
-
Save moccos/6942800ece83fb9ca3e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include "DxOpenNIMouse.h" | |
bool DxOpenNIMouse::Init(HWND hWnd, bool EngFlag, LPDIRECT3DDEVICE9 lpDevice, WCHAR *f_path) { | |
int i; | |
for (i = 0; i < 15; i++) { | |
BP_Vector[i].x = 0; | |
BP_Vector[i].y = DxOpenNIBase::LostVertexY; | |
BP_Vector[i].z = 0; | |
} | |
GetCursorPos(&BasePos); | |
virtualDepth = 0.0f; | |
speedX = speedY = 1.5f; | |
speedZ = 45.0f; | |
DxOpenNIBase::CreateDepthTexture(lpDevice, 10, 10); | |
// test | |
/* | |
D3DLOCKED_RECT LPdest; | |
DepthTex->LockRect(0,&LPdest,NULL, 0); | |
DWORD *pDestImage = (DWORD*)LPdest.pBits; | |
for(i = 0; i < texHeight * texWidth; i++) { | |
*pDestImage++ = 0xffff0000; | |
} | |
DepthTex->UnlockRect(0); | |
*/ | |
return true; | |
} | |
void DxOpenNIMouse::Clean(void) { | |
DxOpenNIBase::ReleaseDepthTexture(); | |
} | |
void DxOpenNIMouse::GetSkeltonJointPosition(int num, D3DXVECTOR3 *vec) { | |
#define SPEEDSTEP 0.1f | |
POINT now; | |
if (num == 0) { | |
GetCursorPos(&now); | |
if ((GetKeyState(VK_LBUTTON) < 0) && (GetKeyState(VK_RBUTTON) < 0)) { | |
BasePos = now; | |
virtualDepth = 0; | |
} | |
// Depth control | |
if (GetKeyState('1') < 0) { | |
virtualDepth += speedZ; | |
} | |
if (GetKeyState('2') < 0) { | |
virtualDepth -= speedZ; | |
} | |
// Speed Control | |
if (GetKeyState(VK_SHIFT) < 0) { | |
if (GetKeyState(VK_F1) < 0) { | |
speedX -= SPEEDSTEP; | |
} | |
if (GetKeyState(VK_F2) < 0) { | |
speedY -= SPEEDSTEP; | |
} | |
if (GetKeyState(VK_F3) < 0) { | |
speedZ -= SPEEDSTEP * 15; | |
} | |
} else { | |
if (GetKeyState(VK_F1) < 0) { | |
speedX += SPEEDSTEP; | |
} | |
if (GetKeyState(VK_F2) < 0) { | |
speedY += SPEEDSTEP; | |
} | |
if (GetKeyState(VK_F3) < 0) { | |
speedZ += SPEEDSTEP * 15; | |
} | |
} | |
BP_Vector[0].x = (now.x - BasePos.x) * speedX; | |
BP_Vector[0].y = (BasePos.y - now.y) * speedY; | |
BP_Vector[0].z = virtualDepth; | |
} | |
*vec = BP_Vector[num]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment