Programming/openGL2011. 10. 2. 23:31
수식을 보고 초기값을 찾으려고 하지만.. 영 보이지 않고
Description

gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector.

The matrix maps the reference point to the negative z axis and the eye point to the origin. When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport. Similarly, the direction described by the UP vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport. The UP vector must not be parallel to the line of sight from the eye point to the reference point.

Let

F = ( centerX - eyeX centerY - eyeY centerZ - eyeZ )
Let UP be the vector ( upX upY upZ ) .

Then normalize as follows:

f = F | | F | |
UP ' = UP | | UP | |
Finally, let s = f × UP ' , and u = s × f .

M is then constructed as follows:

M = ( s [ 0 ] s [ 1 ] s [ 2 ] 0 u [ 0 ] u [ 1 ] u [ 2 ] 0 -f [ 0 ] -f [ 1 ] -f [ 2 ] 0 0 0 0 1 )
and gluLookAt is equivalent to glMultMatrixf(M); glTranslated (-eyex, -eyey, -eyez);
 
[링크 : http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.html]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml]  

If gluLookAt() was not called, the camera has a default position and orientation. By default, the camera is situated at the origin, points down the negative z-axis, and has an up-vector of (0, 1, 0). So in Example 3-1, the overall effect is that gluLookAt() moves the camera 5 units along the z-axis. (See "Viewing and Modeling Transformations" for more information about viewing transformations.)

[링크 : http://glprogramming.com/red/chapter03.html

테스트를 통해서 값을 구해보니
gluLookAt(0.0, 0.0, 0.0,
               0.0, 0.0, -n,
               0.0, 1.0, 0.0) ;
으로 설정을 하면 어떤 n 값(negative z-axis) 이던 동일하게 행렬값이 나온다.

'Programming > openGL' 카테고리의 다른 글

openGL Line 관련설정  (0) 2011.10.06
glutTimerFunc()  (0) 2011.10.05
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
Posted by 구차니
Programming/openGL2011. 10. 2. 21:12
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y));
void glutSpecialFunc(void (*func)(int key, int x, int y));

int x, int y 에는 윈도우의 마우스 좌표가 출력되며
glutSpecialFunc는 F1~F12 / 화살표 / PgUp / PgDn / Home / End / Insert 에 대한 입력을 받고
glutKeyboardFunc 는 그 외에 모든 키보드 입력을 받는다.

glutSpecialFunc 관련해서는 아래의 파일에 정의가 되어있고, 샘플용 콜백함수도 같이 투척!
$ vi /usr/include/GL/freeglut_std.h
124  * GLUT API macro definitions -- the special key codes:
125  */
126 #define  GLUT_KEY_F1                        0x0001
127 #define  GLUT_KEY_F2                        0x0002
128 #define  GLUT_KEY_F3                        0x0003
129 #define  GLUT_KEY_F4                        0x0004
130 #define  GLUT_KEY_F5                        0x0005
131 #define  GLUT_KEY_F6                        0x0006
132 #define  GLUT_KEY_F7                        0x0007
133 #define  GLUT_KEY_F8                        0x0008
134 #define  GLUT_KEY_F9                        0x0009
135 #define  GLUT_KEY_F10                       0x000A
136 #define  GLUT_KEY_F11                       0x000B
137 #define  GLUT_KEY_F12                       0x000C
138 #define  GLUT_KEY_LEFT                      0x0064
139 #define  GLUT_KEY_UP                        0x0065
140 #define  GLUT_KEY_RIGHT                     0x0066
141 #define  GLUT_KEY_DOWN                      0x0067
142 #define  GLUT_KEY_PAGE_UP                   0x0068
143 #define  GLUT_KEY_PAGE_DOWN                 0x0069
144 #define  GLUT_KEY_HOME                      0x006A
145 #define  GLUT_KEY_END                       0x006B
146 #define  GLUT_KEY_INSERT                    0x006C 

void keyboard_spe(int key, int x, int y)
{
    switch (key)
    {
        case GLUT_KEY_F1:
        case GLUT_KEY_F2:
        case GLUT_KEY_F3:
        case GLUT_KEY_F4:
        case GLUT_KEY_F5:
        case GLUT_KEY_F6:
        case GLUT_KEY_F7:
        case GLUT_KEY_F8:
        case GLUT_KEY_F9:
        case GLUT_KEY_F10:
        case GLUT_KEY_F11:
        case GLUT_KEY_F12:
            break;
        case GLUT_KEY_LEFT:
        case GLUT_KEY_RIGHT:
        case GLUT_KEY_UP:
        case GLUT_KEY_DOWN:
            break;
        case GLUT_KEY_PAGE_UP:
        case GLUT_KEY_PAGE_DOWN:
            break;
        case GLUT_KEY_HOME:
        case GLUT_KEY_END:
        case GLUT_KEY_INSERT:
            break;

        default:
           break;
    }
}

void keyboard(unsigned char key, int x, int y)
{
    switch (key)
    {
      default:
          break;
    }
}

void main()
{
  // ...
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(keyboard_spe);
  // ...
}

연유는 모르겠으나,
glutSpecialFunc()와 glutKeyboardFunc() 의 key는 char와 int 형으로 크기가 다르게 정의되어 있으니 주의요망!

2011/09/27 - [Programming/openGL] - GLUT keyboard callback function
2011/03/28 - [Programming/openGL] - openGL callback function - GLUT 키보드 / 마우스 입력

'Programming > openGL' 카테고리의 다른 글

glutTimerFunc()  (0) 2011.10.05
gluLookAt() 의 기본값  (0) 2011.10.02
GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
Posted by 구차니
개소리 왈왈/블로그2011. 10. 1. 20:57
내가 목표로 삼고있는 것은 "하루 하나 이상의 글을 블로그에 작성한다" 인데..
이 목표 자체가 어떻게 보면 블로그의 문제점과 한계라고 생각을 한다.

사용자들을 끌어들이기 위해서는 키워드를 남발하고 광고를 해야하지만
그렇게 글들이 많아진다는 것은 중복된 글을 쓸수도 있는 등의
"관리"적인 문제가 발생할 소지가 많아진다는 것이다.

그리고 하루하나에 집착을 하다보니 글의 품질이나 문제점수정 보다는
어떻게든 하나라도 글을 쓰는 문제가 발생을 한다.
이런 이유로 하루하나의 글쓰기를 포기할까? 바꿀까?도 생각을 해보지만
최초의 목표이기도 했으니 쉽게 포기도 못하고..

아무튼 개인적으로는 블로그에 위키를 추가하여
특정 주제에 대해서 글을 더욱심도있게 쓸수있게 되면 좋겠다는 생각이 든다.
위키에서 글갯수만큼의 숫자로 글을 쓰는 방법도 있겠지만 흐음...
아무튼 블로그와 위키 두개를 운영을 해볼까? 라는 생각도 들기시작한다

블로그를 쓰게된 결과론적 이유중에 하나가
기록을통해 나중에 정리할 자료를 남기고 ebook 형식이나 종이책으로
출판할 내용을 갖춘다였기 때문인데.. 이를 어떻게 조율하는게 좋으려나?
Posted by 구차니
Programming/openGL2011. 9. 30. 13:55
GLUI는 C++ 기반의(으악!) GLUT로 만든 User Interface 라이브러이다.
C++이라니 웬지 거부감이.. 들지만 OTL
openGL/GLUT와 마찬가지로 멀티플랫폼을 지원하는 2차원 인터페이스를 작성하는데에는 꽤 괜찮은 선택이라고 보여진다.


[링크 : http://glui.sourceforge.net/]

ubuntu에서는 libglui-dev 로 설치하면 끝!
[링크 : http://packages.debian.org/lenny/libglui-dev]

'Programming > openGL' 카테고리의 다른 글

gluLookAt() 의 기본값  (0) 2011.10.02
GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
Posted by 구차니
Programming/openGL2011. 9. 30. 12:32
void glEnablei(GLenum cap, GLuint index);
void glDisablei(GLenum cap, GLuint index);

glGet()에서 빼올수 있다는건 다른데서 설정을 하기 때문인데
이러한 설정들은 glEnable() / glDisable()을 통해 이루어진다. 


[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glEnable.xml]
2011/09/30 - [Programming/openGL] - glGet() 

'Programming > openGL' 카테고리의 다른 글

GLUT 키보드 콜백 함수 총정....리?  (2) 2011.10.02
GLUI  (0) 2011.09.30
glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
GLUT keyboard callback function  (0) 2011.09.27
Posted by 구차니
Programming/openGL2011. 9. 30. 12:08
void glGetBooleanv( GLenum   pname, GLboolean *   params);
void glGetDoublev( GLenum   pname, GLdouble *   params);
void glGetFloatv( GLenum   pname, GLfloat *    params);
void glGetIntegerv( GLenum   pname, GLint *   params);

glGet()의 인자들만 추려내보니 엄청 많다는걸 새삼 깨닫는중
아래의 인자들은 /usr/include/GL/gl.h 에 포함되어 있다.

시간되면 형(type)이랑 리턴되는 변수 갯수에 따라서 정리 해야할듯.
 

'Programming > openGL' 카테고리의 다른 글

GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
GLUT keyboard callback function  (0) 2011.09.27
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
Posted by 구차니
난 이 글을 쓰고 있지 못했겠지...

어제 데이트 하고 들어가는데
길동사거리에서 버스가 신호를 기다리고 있었는데
"펑" 혹은 "쾅" 소리가 났는데
건물에서 먼지가 자욱하게 나고 있길래 읭? 건물이 붕괴된건가? 생각

버스가 사거리를 지나가고
그제서야 암사행 길을 보니 하얀색 차가 뒤집어져있고 먼지인지 연기인지가 폴폴폴..
운전자는 괜찮을까? 보다는 도대체 어떻게 사고가 난거지? 라는게 더 궁금한 케이스였는데
오늘 생각이 나서 검색을 해보니
결국에는 운전자는 사망이고, 처음에 났던 먼지(혹은 연기)는 신호등 쳐박은거였다.

아무튼 만약 그 차가 우회전 하다가 신호등을 쳐박은게 아니라 직진하다가 쳐박고
반대편 차선으로 날아왔더라면.. 그 차가 내가 타고 있던 버스로 날아왔더라면
어떻게 되었을까 라는 생각에 문득 섬칫해지는 아침....

[링크 : http://mbn.mk.co.kr/pages/news/newsView.php?category=mbn00009&news_seq_no=1110888]
[링크 : http://www.ytn.co.kr/_ln/0103_201109300635385512

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

오늘 업어온 LW25 Advanced  (0) 2011.10.25
이건머...  (2) 2011.10.13
월차내고 치료하러 갑니다~  (0) 2011.09.28
안나온 사람 손들어 보세요~  (0) 2011.09.26
한사토이 - 실감나는 인형  (0) 2011.09.21
Posted by 구차니
Linux API/network2011. 9. 29. 18:05
/usr/include/netinet/in.h

176 /* Address to accept any incoming messages.  */
177 #define INADDR_ANY      ((in_addr_t) 0x00000000)
178 /* Address to send to all hosts.  */
179 #define INADDR_BROADCAST    ((in_addr_t) 0xffffffff)
180 /* Address indicating an error return.  */
181 #define INADDR_NONE     ((in_addr_t) 0xffffffff) 

hton() 과 같은 변환없이 사용해도 되는 매크로인데
255.255.255.255(BROADCAST/NONE) 혹은 0.0.0.0(ANY) 으로 치환이 된다.

'Linux API > network' 카테고리의 다른 글

멀티캐스트 되는지 여부 확인  (0) 2014.11.21
net tools 소스코드  (0) 2011.11.07
hton(), ntoh()  (0) 2011.09.26
netstat 에서 0.0.0.0의 의미  (2) 2009.12.07
ioctl을 이용한 정보수집  (0) 2009.11.30
Posted by 구차니
Programming/openGL2011. 9. 28. 22:45
glGet() 함수 사용법을 익힐겸 해보니 흐음..
일단 아무런 설정없이 openGL 에서 생성해서 해보니 다음과 같은 행렬을 뽑아내준다.


GL_MODELVIEW_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 0.000000 1.000000 
GL_PROJECTION_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 0.000000 1.000000  

주석을 풀고 변경된 크기로 보면은 다음과 같이 나온다.

 
GL_MODELVIEW_MATRIX
1.000000 0.000000 0.000000 0.000000 
0.000000 1.000000 0.000000 0.000000 
0.000000 0.000000 1.000000 0.000000 
0.000000 0.000000 -5.000000 1.000000 
GL_PROJECTION_MATRIX
1.732051 0.000000 0.000000 0.000000 
0.000000 1.732051 0.000000 0.000000 
0.000000 0.000000 -1.105263 -1.000000 
0.000000 0.000000 -2.105263 0.000000 

gluLookat()에 의해서 MODELVIEW_MATRIX에서 -5가 추가된듯 하고
PROJECTION은 이해불가 ㅋㅋㅋ
void reshape(int w, int h)
{
	GLdouble mat[16];
	int i=0;

	glViewport(0, 0, (GLsizei) w, (GLsizei) h); 
/*
	glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

	glMatrixMode(GL_MODELVIEW); //GL_PROJECTION
		glLoadIdentity();
		gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
*/
	printf("GL_MODELVIEW_MATRIX\n");
	glGetDoublev(GL_MODELVIEW_MATRIX,mat);
	for(i=0; i<16;i++)
	{
		printf("%f ",mat[i]);
		if(i % 4 == 3) printf("\n");
	}

	printf("GL_PROJECTION_MATRIX\n");
	glGetDoublev(GL_PROJECTION_MATRIX,mat);
	for(i=0; i<16;i++)
	{
		printf("%f ",mat[i]);
		if(i % 4 == 3) printf("\n");
	}
}

[링크 : http://www.morrowland.com/apron/tutorials/gl/gl_matrix.php]
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml]

[링크 : http://www.songho.ca/opengl/gl_transform.html
[링크 : http://www.cprogramming.com/tutorial/3d/rotationMatrices.html

'Programming > openGL' 카테고리의 다른 글

glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
GLUT keyboard callback function  (0) 2011.09.27
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
webGL  (0) 2011.09.24
Posted by 구차니
시술이던 수술이던 무서운건 매한가지인데 -_-
아무튼 코 세우러 갑니다~! /ㅁ/ 
Posted by 구차니