/*
OpenGL 사용할 때 VECTOR 관련 구조체가 없었다. 아무래도 OpenGL은 3D를 만들기 위한 프로그램이 아니고, 3D 제작을 지원하는 유틸리티 관련 툴이라 그런지 Render 부분 외엔 많이 미흡하다. 그 대표적으로 DirtectX에서 흔히 볼 수 있는 VECTOR도 보이지 않는다. 그래서 심심풀이로 하나 만들어 봤다.
*/
struct VECTOR
{
float fPosX, fPosY, fPosZ;
VECTOR() : fPosX( 0.0f ), fPosY( 0.0f ), fPosZ( 0.0f )
{}
VECTOR( const VECTOR& rhsVector )
{
this->fPosX = rhsVector.fPosX;
this->fPosY = rhsVector.fPosY;
this->fPosZ = rhsVector.fPosZ;
}
VECTOR( float x, float y, float z )
{
this->fPosX = x;
this->fPosY = y;
this->fPosZ = z;
}
VECTOR &operator+=( const VECTOR& rhsVector )
{
this->fPosX = this->fPosX +rhsVector.fPosX;
this->fPosY = this->fPosY +rhsVector.fPosY;
this->fPosZ = this->fPosZ +rhsVector.fPosZ;
return *this;
} // >>> END operator+=
VECTOR &operator-=( const VECTOR& rhsVector )
{
this->fPosX = this->fPosX -rhsVector.fPosX;
this->fPosY = this->fPosY -rhsVector.fPosY;
this->fPosZ = this->fPosZ -rhsVector.fPosZ;
return *this;
} // >>> END operator-=
VECTOR &operator*=( const VECTOR& rhsVector )
{
this->fPosX = this->fPosX *rhsVector.fPosX;
this->fPosY = this->fPosY *rhsVector.fPosY;
this->fPosZ = this->fPosZ *rhsVector.fPosZ;
return *this;
} // >>> END operator*=
VECTOR &operator/=( const VECTOR& rhsVector )
{
this->fPosX = this->fPosX /rhsVector.fPosX;
this->fPosY = this->fPosY /rhsVector.fPosY;
this->fPosZ = this->fPosZ /rhsVector.fPosZ;
return *this;
} // >>> END operator/=
VECTOR &operator=( const VECTOR& rhsVector )
{
this->fPosX = rhsVector.fPosX;
this->fPosY = rhsVector.fPosY;
this->fPosZ = rhsVector.fPosZ;
return *this;
} // >>> END operator=
VECTOR operator-( const VECTOR& rhsVector )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX -rhsVector.fPosX;
vTemp.fPosY = this->fPosY -rhsVector.fPosY;
vTemp.fPosZ = this->fPosZ -rhsVector.fPosZ;
return vTemp;
} // >>> END operator-
VECTOR operator+( const VECTOR& rhsVector )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX +rhsVector.fPosX;
vTemp.fPosY = this->fPosY +rhsVector.fPosY;
vTemp.fPosZ = this->fPosZ +rhsVector.fPosZ;
return vTemp;
} // >>> END operator+
VECTOR operator*( const VECTOR& rhsVector )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX *rhsVector.fPosX;
vTemp.fPosY = this->fPosY *rhsVector.fPosY;
vTemp.fPosZ = this->fPosZ *rhsVector.fPosZ;
return vTemp;
} // >>> END operator*
VECTOR operator/( const VECTOR& rhsVector )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX /rhsVector.fPosX;
vTemp.fPosY = this->fPosY /rhsVector.fPosY;
vTemp.fPosZ = this->fPosZ /rhsVector.fPosZ;
return vTemp;
} // >>> END operator/
VECTOR operator-( float fData )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX -fData;
vTemp.fPosY = this->fPosY -fData;
vTemp.fPosZ = this->fPosZ -fData;
return vTemp;
} // >>> END operator-
VECTOR operator+( float fData )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX +fData;
vTemp.fPosY = this->fPosY +fData;
vTemp.fPosZ = this->fPosZ +fData;
return vTemp;
} // >>> END operator+
VECTOR operator*( float fData )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX *fData;
vTemp.fPosY = this->fPosY *fData;
vTemp.fPosZ = this->fPosZ *fData;
return vTemp;
} // >>> END operator*
VECTOR operator/( float fData )
{
VECTOR vTemp;
vTemp.fPosX = this->fPosX /fData;
vTemp.fPosY = this->fPosY /fData;
vTemp.fPosZ = this->fPosZ /fData;
return vTemp;
} // >>> END operator/
};
'[ Programing ] > C++' 카테고리의 다른 글
[ 콘솔 창 설정 ] AllocConsole(); freopen( "CONOUT$", "wt", stdout ); (0) | 2010.01.31 |
---|---|
[ 기초 ] 팁 : 조건문 효율적으로 붙이기 (0) | 2010.01.31 |
[기초] 시간 / 날짜 출력. localtime (0) | 2010.01.31 |
가변인자 (0) | 2010.01.30 |
Console 환경 전용 API 함수 (0) | 2010.01.29 |