📄 base.cpp
字号:
#include "Base.h"
bool CBase::m_fEnableLogging=FALSE;
CBase::CBase() {}
CBase::~CBase() {}
D3DXVECTOR3 CBase::GetTriangleNormal(D3DXVECTOR3 *vVertex1,
D3DXVECTOR3 *vVertex2,
D3DXVECTOR3 *vVertex3)
{
D3DXVECTOR3 vNormal;
D3DXVECTOR3 v1;
D3DXVECTOR3 v2;
D3DXVec3Subtract(&v1,vVertex2,vVertex1);
D3DXVec3Subtract(&v2,vVertex3,vVertex1);
D3DXVec3Cross(&vNormal,&v1,&v2);
D3DXVec3Normalize(&vNormal,&vNormal);
return vNormal;
}
void CBase::StartLogging()
{
FILE* pFile=NULL;
//Opens an empty file for writing.If the given file exists, its contents are destroyed.
pFile=fopen("Log.htm","w");
if(pFile!=NULL)
{
fprintf(pFile,"<html><head><title>Log File</title></head><body>\n");
fprintf(pFile,"<font face=\"Arial\" size=\"4\" color=\"#000000\"><b><u>Log File</u></b></font><br>\n");
fclose(pFile);
m_fEnableLogging=TRUE;
}
}
void CBase::StopLogging()
{
if(m_fEnableLogging)
{
FILE *pFile=NULL;
//Opens for reading and appending
pFile=fopen("Log.htm","a+");
if(pFile!=NULL)
{
fprintf(pFile,"</body></html>");
fclose(pFile);
}
m_fEnableLogging=FALSE;
}
}
void CBase::LogError(char *lpszText,...)
{
if(m_fEnableLogging)
{
va_list argList;
FILE *pFile=NULL;
//Initialize variable argument list
va_start(argList,lpszText);
//Open the log file for appending
pFile=fopen("Log.htm","a+");
if(pFile!=NULL)
{
//Write the error to the log file
fprintf(pFile,"<font face=\"Arial\" size=\"2\" color=\"#FF0000\"><b>");
vfprintf(pFile,lpszText,argList);
fprintf(pFile,"</b></font><br>\n");
fclose(pFile);
}
va_end(argList);
}
}
void CBase::LogInfo(char *lpszText,...)
{
if(m_fEnableLogging)
{
va_list argList;
FILE *pFile=NULL;
//Initialize variable argument list
va_start(argList,lpszText);
//Open the log file for appending
pFile=fopen("Log.htm","a+");
if(pFile!=NULL)
{
//Write the Info to the log file
fprintf(pFile,"<font face=\"Arial\" size=\"2\" color=\"#000000\">");
vfprintf(pFile,lpszText,argList);
fprintf(pFile,"</font><br>\n");
fclose(pFile);
}
va_end(argList);
}
}
void CBase::LogWarning(char *lpszText, ...)
{
if(m_fEnableLogging)
{
va_list argList;
FILE *pFile = NULL;
//Initialize variable argument list
va_start(argList, lpszText);
//Open the log file for appending
pFile = fopen("Log.htm", "a+");
if(pFile != NULL)
{
//Write the warning to the log file
fprintf(pFile,"<font face=\"Arial\" size=\"2\" color=\"#E7651A\"><b>");
vfprintf(pFile,lpszText,argList);
fprintf(pFile,"</b></font><br>\n");
//Close the file
fclose(pFile);
}
va_end(argList);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -