#include "StdAfx.h"
#include "MyApplication.h"

MyApplication::MyApplication(HWND hWnd) {
	directXFramework = new DirectXFramework(hWnd);
	LPDIRECT3DDEVICE9 pDevice = directXFramework->GetD3DDevice();
	skinMesh = new PmdSkinMesh(TEXT("reimu.pmd"), pDevice);
}

MyApplication::~MyApplication(void) {
	delete skinMesh;
	delete directXFramework;
}

void MyApplication::Run() {
	// ライト
	D3DLIGHT9 light = {D3DLIGHT_DIRECTIONAL, {1, 1, 1, 0}, {1, 1, 1, 0}, {1, 1, 1, 0}};	// 色
	light.Direction = D3DXVECTOR3(-1, -1, -1);		// 方向

	// カメラ
	D3DXVECTOR3 eyePoint = D3DXVECTOR3(0.3f, 1.0f, 2.8f);	// 視点
	D3DXVECTOR3 lookAtPoint = D3DXVECTOR3(0, 1.0f, 0);		// 注視点
	Camera camera(eyePoint, lookAtPoint);

	// 描画
	D3DXVECTOR3 position(0, 0, 0);	// 位置
	D3DXMATRIX rotation;			// 回転
	D3DXMatrixRotationY(&rotation, 0.01f*50 + D3DX_PI);
	skinMesh->AdvanceTime();
	directXFramework->BeginScene(240, 180, 180);// シーン開始
	skinMesh->Draw(&position, &rotation, &light, &camera);
	//skinMesh->DrawBoneObj(&position, &rotation, &light, camera);
	directXFramework->EndScene();	// シーン終了
}