#include "stdafx.h"
///*
// SGameFxWeaponPowerup.cpp
// 무기 강화 이펙트 implementations
//
// Created 2006/05, by JiYoung
//*/
//
//
//
//#include "SGameFxWeaponPowerup.h"
//#include "SFxMesh.h"
//
//
//#include "SDebug_Util.h"
//
//
////======================================================
//// Glow FX
////======================================================
//
//SGameFxWeaponPowerup_Glow::SGameFxWeaponPowerup_Glow()
//{
// edgeGlowModel=NULL;
//
///*
// // White glow
// const DWORD color0_mark=0x40202020;
// const DWORD color1_mark=0x80c0c0c0;
//
// const DWORD color0_end=0x00202020;
// const DWORD color1_end=0x00c0c0c0;
//*/
///*
// const DWORD color0_mark=0x40ffc0c0;
// const DWORD color1_mark=0x20ffc0c0;
//
// const DWORD color0_end=0x10202020;
// const DWORD color1_end=0x10202020;
//*/
//
// // Wine red dark haze
// const DWORD color0_mark=0x40e00000;
// const DWORD color1_mark=0x20400000;
//
// const DWORD color0_end=0x00000000;
// const DWORD color1_end=0x004040c0;
//
//
///* // Red to green
// const DWORD color0_mark=0x40e04040;
// const DWORD color1_mark=0x20804040;
//
// const DWORD color0_end=0x00000000;
// const DWORD color1_end=0x00408040;
//*/
// //
// // Set default parameters
// //
// m_nTotalFrameCount = 32; // 전체 애니메이션 프레임 수. 대충 16~32
// m_nAnimationLoopDistance = 6; // 반복될 애니메이션 간의 간격. 대충 4~8
// m_nAnimationDelayTime = 100; // 프레임 애니메이션 속도 (애니메이션 프레임 간의 시간간격)
//
// m_nMarkFrameNumber = 8; // markFrame : 중간의 어떤 적절한 프레임. 애니메이션 경계를 주기 위해 사용
//
// m_fStartEnlargeOffset = 0.01f; // 0번 프레임의 메쉬 확대 크기. 대충 +0.01정도?
// m_dwStartColor0 = 0x00000000;
// m_dwStartColor1 = 0x00000000; // 0번 프레임의 컬러
//
// m_fMarkEnlargeOffset = 0.10f; // (markFrame)번 프레임의 메쉬 크기.
// m_dwMarkColor0 = color0_mark;
// m_dwMarkColor1 = color1_mark; // (markFrame)번 프레임의 컬러
//
// m_fEndEnlargeOffset = 0.6f; // (numFrames-1)번 프레임의 메쉬 크기. 대충 +0.6정도?
// m_dwEndColor0 = color0_end;
// m_dwEndColor1 = color1_end; // (numFrames-1)번 프레임의 컬러
//
//}
//
//SGameFxWeaponPowerup_Glow::~SGameFxWeaponPowerup_Glow()
//{
// close();
//}
//
//
////
//// Inherited
////
//bool SGameFxWeaponPowerup_Glow::init(KMeshPrimitive *source) // 주어진 무기 mesh로부터 FX용 mesh를 초기화
//{
// assert(edgeGlowModel==NULL);
//
// edgeGlowModel=new FxAnimatedEdgeGlow();
// edgeGlowModel->init(
// source // Copy할 index, vertex를 갖고 있는 mesh
//
// , m_nTotalFrameCount // 전체 애니메이션 프레임 수. 대충 16~32
// , m_nAnimationLoopDistance // 반복될 애니메이션 간의 간격. 대충 4~8
// , m_nAnimationDelayTime // 프레임 애니메이션 속도 (애니메이션 프레임 간의 시간간격)
//
// , m_nMarkFrameNumber // markFrame : 중간의 어떤 적절한 프레임. 애니메이션 경계를 주기 위해 사용
//
// , m_dwStartColor0, m_dwStartColor1 // 0번 프레임의 컬러. 24bit ARGB
// , m_dwMarkColor0, m_dwMarkColor1 // (markFrame)번 프레임의 컬러
// , m_dwEndColor0, m_dwEndColor1 // (numFrames-1)번 프레임의 컬러
//
// , m_fStartEnlargeOffset // 0번 프레임의 메쉬 확대 거리. 대충 +0.01정도?
// , m_fMarkEnlargeOffset // (markFrame)번 프레임의 메쉬 크기.
// , m_fEndEnlargeOffset // (numFrames-1)번 프레임의 메쉬 크기. 대충 +0.6정도?
// );
//
//
///*
// // Test : inverse localmat
// K3DMatrix invmat;
// float determinant;
// if (NULL != K3DMatrixInverse( &invmat, &determinant, edgeGlowModel->getLocalMatrix())) {
// edgeGlowModel->setLocalMatrix(&invmat);
// }
//*/
//
//
// // Copy offset matrix
// K3DMatrix mat;
// K3DMatrix *pMat;
//
// pMat=source->getOffsetMatrix();
// mat=pMat[2];
// edgeGlowModel->setLocalMatrix(&mat);
//
//
// return true;
//}
//
//void SGameFxWeaponPowerup_Glow::close() // 초기화된거 날린다
//{
// if (edgeGlowModel!=NULL) {
// delete edgeGlowModel;
// edgeGlowModel=NULL;
// }
//}
//
//
//int SGameFxWeaponPowerup_Glow::Process(DWORD dwTime) // 애니메이션 시킨다
//{
// if (edgeGlowModel==NULL) return 0;
// edgeGlowModel->Process(dwTime);
//
// return 0;
//}
//
//void SGameFxWeaponPowerup_Glow::Render( KViewportObject *viewport, DWORD flag, const K3DMatrix * pAttachMat )
//{
// if (edgeGlowModel==NULL) return;
//
// // Copy parent matrix
// edgeGlowModel->SetParentTransform(m_pMatParent,m_pMatAttach);
// edgeGlowModel->SetTransform(m_matTransform);
//
// edgeGlowModel->Render(viewport, flag, pAttachMat);
//}
//
//
//
//
//
///*
////
//// 이 Define들은 ConsoleHelper.h에 있음
////
//
//// param출력용 define
//#define PRINT_INT(buf, intv) { sprintf(buf, "%d", intv); }
//#define PRINT_FLOAT(buf, floatv) { sprintf(buf, "%f", floatv); }
//#define PRINT_HEX(buf, intv) { sprintf(buf, "0x%x", intv); }
//#define PRINT_COLOR(buf, intv) { sprintf(buf, "0x%08x", intv);}
//
//// param입력용 define
//#define PARAM_FLOAT(n) ((float)atof(argv[n].c_str()))
//#define PARAM_INT(n) (atoi(argv[n].c_str()))
//#define PARAM_HEX(n) (strtoul(argv[0].c_str(), &HEX_P, 16))
//#define PARAM_COLOR(n) (PARAM_HEX(n))
//
//#define MSG(buf, _msg) { sprintf(buf, _msg); }
//#define MSG_OK(buf) { MSG(buf, "OK
"); }
//
//
//// key비교용 define
//#define CMD(cmdA) (0==::_stricmp(key.c_str(), cmdA))
//#define CMD1(cmdA) (0==::_stricmp(key.c_str(), cmdA))
//#define CMD2(cmdA, cmdB) ( (0==::_stricmp(key.c_str(), cmdA)) || (0==::_stricmp(key.c_str(), cmdB)) )
//#define CMD3(cmdA, cmdB, cmdC) ( (0==::_stricmp(key.c_str(), cmdA)) || (0==::_stricmp(key.c_str(), cmdB)) || (0==::_stricmp(key.c_str(), cmdC)) )
//
//#define DEFAULTPARAM(a) { if (argc==0) { {a;} return; } }
//
//#define PROC_INT(v) { DEFAULTPARAM( PRINT_INT(outputBuffer, (v)) ); (v) = PARAM_INT(0); MSG_OK(outputBuffer); }
//#define PROC_FLOAT(v) { DEFAULTPARAM( PRINT_FLOAT(outputBuffer, (v)) ); (v) = PARAM_FLOAT(0); MSG_OK(outputBuffer); }
//#define PROC_HEX(v) { DEFAULTPARAM( PRINT_HEX(outputBuffer, (v)) ); (v) = PARAM_HEX(0); MSG_OK(outputBuffer); }
//#define PROC_COLOR(v) { DEFAULTPARAM( PRINT_COLOR(outputBuffer, (v)) ); (v) = PARAM_COLOR(0); MSG_OK(outputBuffer); }
//*/
//
//extern bool WeaponPowerupProcessConsoleCommand_UPDATE; // 바로 밑에 있지만 귀찮으니 extern
//
//void SGameFxWeaponPowerup_Glow::processConsoleCommand(std::string &key, int argc, std::vector &argv, char *outputBuffer)
// // Game console에서 들어온 파라미터를 redirect한다
// // outputBuffer : 처리 결과를 sprintf()할 텍스트 버퍼. 여기 들어가는 결과가 콘솔 화면에 출력된다
//{
// WeaponPowerupProcessConsoleCommand_UPDATE=true; // WeaponPowerupProcessConsoleCommand()에서 localplayer의 fx mesh를 업데이트할까 말까 하는 flag
//
// const char *defaultFileName="pwParams.txt";
// static char fileName[512]="";
//
// outputBuffer[0]=0;
// if (CMD2("pwprint", "pwp")) { // Print current status
// buildConfigurationText(outputBuffer); // Note : \n대신
이 들어가야 newline되는데 음...
// } else if (CMD("pwTotalFrames")) {
// PROC_INT(m_nTotalFrameCount);
// } else if (CMD("pwLoopGap")) {
// PROC_INT(m_nAnimationLoopDistance);
// } else if (CMD("pwAnimationDelay")) {
// PROC_INT(m_nAnimationDelayTime);
// } else if (CMD("pwMarkFrame")) {
// PROC_INT(m_nMarkFrameNumber);
//
// } else if (CMD("pwStartColor0")) {
// PROC_COLOR(m_dwStartColor0 );
// } else if (CMD("pwStartColor1")) {
// PROC_COLOR(m_dwStartColor1 );
//
// } else if (CMD("pwMarkColor0")) {
// PROC_COLOR(m_dwMarkColor0 );
// } else if (CMD("pwMarkColor1")) {
// PROC_COLOR(m_dwMarkColor1 );
//
// } else if (CMD("pwEndColor0")) {
// PROC_COLOR(m_dwEndColor0 );
// } else if (CMD("pwEndColor1")) {
// PROC_COLOR(m_dwEndColor1 );
//
// } else if (CMD("pwStartSize")) {
// PROC_FLOAT(m_fStartEnlargeOffset);
// } else if (CMD("pwMarkSize")) {
// PROC_FLOAT(m_fMarkEnlargeOffset);
// } else if (CMD("pwEndSize")) {
// PROC_FLOAT(m_fEndEnlargeOffset);
//
// } else if (CMD2("pwSave", "pws")) {
// // Save settings
// const char *filename=defaultFileName;
// if (argc>0) {
// filename=argv[0].c_str();
// }
// if (false==saveToFile(filename)) {
// sprintf(outputBuffer, "Save error");
// return;
// }
// sprintf(outputBuffer, "Saved to %s", filename);
// return;
//
// } else if (CMD2("pwLoad", "pwl")) {
// // Load settings
// const char *filename=defaultFileName;
// if (argc>0) {
// filename=argv[0].c_str();
// }
// if (false==loadFromFile(filename)) {
// sprintf(outputBuffer, "Load error");
// return;
// }
// strcpy(fileName, filename);
//
// sprintf(outputBuffer, "Loaded from %s", filename);
// return;
// } else if (CMD2("pwReload", "pwr")) {
// // Reload settings
// if (false==loadFromFile(fileName)) {
// sprintf(outputBuffer, "Reload error");
// }
// sprintf(outputBuffer, "Reloaded from %s", fileName);
// return;
//
// } else {
// // Invalid command
// MSG(outputBuffer, "Invalid command");
//
// // Disable FX update
// WeaponPowerupProcessConsoleCommand_UPDATE=false;
// }
//}
//
//
//bool SGameFxWeaponPowerup_Glow::buildConfigurationText(char *outputBuffer)
// // Status를 읽어서 config file을 build한다.
// // outputBuffer: config file을 홀드할 '충분히 큰' 버퍼
//{
// const char *commandList[] = { // Config file에 write할 커맨드 목록을 여기 적는다
// "pwTotalFrames"
// , "pwLoopGap"
// , "pwAnimationDelay"
// , "pwMarkFrame"
// , "pwStartColor0"
// , "pwStartColor1"
// , "pwMarkColor0"
// , "pwMarkColor1"
// , "pwEndColor0"
// , "pwEndColor1"
// , "pwStartSize"
// , "pwMarkSize"
// , "pwEndSize"
// , NULL // EOL
// };
//
// return CollectCommandOutput(outputBuffer, commandList); // 여기서 그 결과를 gather해서 outputBuffer에 채운다
//}
//
//
//
////===========================================================
//// Debugging utility
//// 콘솔에서 파라미터 잘 받아서 처리
//// 나중에 지울것 or 막을것!!
////===========================================================
//
//
//#include "SGame.h"
//#include "SGameSystem.h"
//#include "SGameAvatarEx.h"
//
//extern SGameSystem * g_pCurrentGameSystem; // defined in SGameSystem.cpp // localPlayer얻어오는데 사용
//
//static bool WeaponPowerupProcessConsoleCommand_UPDATE=false;
//
//char *WeaponPowerupProcessConsoleCommand(std::string &key, int argc, std::vector &argv)
//{
// static char ConsoleMessage[2048]="";
//
// SGameAvatarEx *localPlayer=g_pCurrentGameSystem->GetLocalPlayer();
// if (localPlayer==NULL) return NULL;
//
// SGameFxWeaponPowerup * fxTemp = localPlayer->getWeaponPowerupFx(MPART_R_WEAPON);
// SGameFxWeaponPowerup_Glow *fx = dynamic_cast(fxTemp);
// if (fx==NULL) {
// // Current FX is not assigned, or, SGameFxWeaponPowerup_Glow
// if (fxTemp==NULL) {
// // Create new FX!
// localPlayer->setWeaponPowerupFx(MPART_R_WEAPON, new SGameFxWeaponPowerup_Glow());
// fxTemp = localPlayer->getWeaponPowerupFx(MPART_R_WEAPON);
// fx = dynamic_cast(fxTemp);
// if (fx==NULL) return NULL;
// } else {
// // Just pass
// return NULL;
// }
// }
//
// WeaponPowerupProcessConsoleCommand_UPDATE=false;
// fx->processConsoleCommand(key, argc, argv, ConsoleMessage);
//
// if (WeaponPowerupProcessConsoleCommand_UPDATE) {
// localPlayer->updateWeaponPowerupMesh(MPART_R_WEAPON, true);
// }
//
// return ConsoleMessage;
//}
//
//
//