It's just like pok
Home
Tag
RSS
Guest
Admin
익명 공용체와 익명 구조체 ( anonymous union / anonymous structure )
2007/08/19 22:57
Leave a Comment
익명의 공용체에 익명 구조체를 쓰는것은 대부분의 C++ 컴파일러가 지원하는 확장이지만 표준은 아니다.
꼴에 표준을 좋아해서 DX에서 쓰이는 아래의 행렬은 새로 작성하고 있는 end 의 행렬객체로는 부적격.
(Language : cpp)
typedef
struct
_D3DMATRIX
{
union
{
struct
{
float
_11, _12, _13, _14;
float
_21, _22, _23, _24;
float
_31, _32, _33, _34;
float
_41, _42, _43, _44;
}
;
float
m
[
4
]
[
4
]
;
}
;
}
D3DMATRIX;
현재는 이런식으로 행렬 클래스를 설계하고 있다.
(Language : cpp)
namespace
end
{
class
Matrix4
{
public
:
enum
ENTRIES
{
_11=
0
, _12, _13, _14,
_21, _22, _23, _24,
_31, _32, _33, _34,
_41, _42, _43, _44
}
;
//////////////////////////////////////////////////////////////////////
// 단위행렬 / 영행렬 ---
//
void
makeIdentity
(
)
;
void
makeZero
(
)
;
//////////////////////////////////////////////////////////////////////
// 주어진 행렬로부터 행렬을 만드는 경우 ---
//
void
makeFromInverse
(
const
Matrix4& _rMatToGetInvers
)
;
void
makeFromMultiply
(
const
Matrix4* _pMat1,
const
Matrix4* _pMat2,
const
Matrix4* _pMat3NullIfNotUse =
0
,
const
Matrix4* _pMat4NullIfNotUse =
0
,
const
Matrix4* _pMat5NullIfNotUse =
0
)
;
//////////////////////////////////////////////////////////////////////
// 변환의 용도로 쓰일 행렬을 만드는 경우 ---
//
void
makeTransform
(
const
Matrix4& _rMat
)
;
void
makeTransformPerspectiveProjectionLH
(
float
_fFieldOfViewRadians = END_PI/
4
.
f
,
float
_fAspectRatio =
4
.
f
/
3
.
f
,
float
_fZNear =
1
.0f,
float
_fZFar =
1000
.0f
)
;
void
makeTransformPerspectiveProjectionRH
(
float
_fFieldOfViewRadians = END_PI/
4
.
f
,
float
_fAspectRatio =
4
.
f
/
3
.
f
,
float
_fZNear =
1
.0f,
float
_fZFar =
1000
.0f
)
;
void
makeTransformOrthogonalProjectionLH
(
float
_fWidth =
800
.0f,
float
_fHeight =
600
.0f,
float
_fZNear =
0
.0f,
float
_fZFar =
1
.0f
)
;
void
makeTransformOrthogonalProjectionRH
(
float
_fWidth =
800
.0f,
float
_fHeight =
600
.0f,
float
_fZNear =
0
.0f,
float
_fZFar =
1
.0f
)
;
void
makeTransformViewLH
(
const
Vector3& _rPosition,
const
Vector3& _rDir,
const
Vector3& _rUp
)
;
void
makeTransformViewRH
(
const
Vector3& _rPosition,
const
Vector3& _rDir,
const
Vector3& _rUp
)
;
void
makeTransformCoordinateSystem
(
const
Vector3& _rOrigin,
const
Vector3& _rX,
const
Vector3& _rY,
const
Vector3& _rZ
)
;
//////////////////////////////////////////////////////////////////////
// 행렬연산 ---
//
void
multiply
(
const
Matrix4& _rMatToMultiply
)
;
void
transformVector3
(
Vector3& _rOutVecToTransform
)
;
void
transformVector4
(
Vector4& _rOutVecToTransform
)
;
/* 00, 01, 02, 03 = 11, 12, 13, 14
04, 05, 06, 07 = 21, 22, 23, 24
08, 09, 10, 11 = 31, 32, 33, 34
12, 13, 14, 15 = 41, 42, 43, 44 */
float
Entries
[
16
]
;
}
;
}
음... 나름 괜찮다고 생각중.. 특히 저 makeFromMultiply는 최적화를 잘해줘서 불필요한 임시객체 생성을 막을수 있을듯.
프로그래밍
게임개발
,
프로그래밍
,
행렬
Leave a Commnet
Leave a Trackback
Trackback Address:
http://poksion.cafe24.com/poklog/trackback/54
이름
(필수)
비밀번호
(필수)
웹 사이트
비밀 답글
◀ PREV
[
1
]
...
[
76
]
[
77
]
[
78
]
[
79
]
[
80
]
[
81
]
[
82
]
[
83
]
[
84
]
...
[
133
]
NEXT ▶
최근 글
Gauss-Seidel Method
Octave in Vista
오렌지색
아래아 한글뷰어 2002를 백업하다
vim modeline 삽질기
최근 답글
pok:
저런 정의들을 연결하여 정말 풀기 힘들..
333:
수학이라는 학문이 참 신기합니다. 다른..
둡:
커피 많이 마시면 칼슘 빠져나간다는게..
최근 트랙백
동차좌표
kz의 생각
글 보관함
2009/10
2009/09
2009/08
2009/07
2009/06
글 분류
전체
(133)
일상 이야기
(40)
여행 이야기
(1)
책 이야기
(5)
문화산업
(4)
수학 이야기
(7)
프로그래밍
(31)
멀티플랫폼
(14)
실행환경
(3)
개발환경
(11)
윈도우
(11)
실행환경
(4)
개발환경
(7)
리눅스
(20)
실행환경
(15)
개발환경
(5)
태그 구름
애니메이션
알고리즘
썬더버드
행렬
돈지랄
python
술
윈도우팁
비주얼스튜디오
독립
프로그래밍
게임개발
저작권
리눅스
수학
Octave
여행
꿈꾸는 공간
서울여행
비
UTC
오일러
실패
커피
D40
학교수업
타입리스트
gcc
시간복잡도
인생
루비
피카사
시험
빌드
MFC
기말고사
선형대수
주저리
C/C++
지름신
방문 통계
Total : 102413
Today : 4
Yesterday : 87