80 likes | 211 Vues
This guide explores the FLTK (Fast, Light Toolkit), a powerful GUI toolkit that simplifies window creation and OpenGL integration. It covers the development of a `MyWindow` class using FLTK, enabling 3D rendering and animation. The implementation involves handling 3D objects defined in OBJ files, such as vertices, normals, and texture coordinates. Additionally, we discuss challenges related to understanding OBJ file structures, loading files, and mapping textures to enhance the visual experience in 3D graphics.
E N D
10/8 ~ 10/24 최순용
FLTK • FLTK는 쉽게 window생성 및 OpenGL을 사용할 수 있게 만들어진 GUI Toolkit • GPL license • MyWindow.h , MyWindow.cpp에서 FLTK라이브러리를 사용해서 window생성, rendering등을 하는 MyWindow class 작성
- MyWindow.h 일부 - … #include <Fl/Fl_Gl_Window.h> #include "Ship.h" class MyWindow : public Fl_Gl_Window { public: float rotation; float rotationIncrement; bool animating; Ship * boat; public: // Constructor and destructor MyWindow(int width, int height, char* title); virtual ~MyWindow(void); // Initialize the GL operation which is set up necessary operation void InitializeGL(void); // Overwrite the draw operation in Fl_Gl_Window virtual void draw(void); // Function to draw a cube void DrawCube(void); virtual int handle(int event); }; …
*.Obj 파일 • 3D 오브젝트의 vertex, normal, texture coordinate정보와 한 face를 이루고 있는 vertex의 집합정보를 가지고 있다. • Obj 파일 내용 v x y z vn x y z vt x y f v/vt/vn v/vt/vn v/vt/vn
- boat.obj 일부 - … v -2.41346 0.274552 5.27829 v -2.36675 -0.012347 5.28305 v -2.3834 0.274552 5.49626 vt 0.685692 0.49269 vt 0.686872 0.507775 vt 0.688578 0.492912 vn -0.978009 -0.171867 0.11815 vn -0.979463 -0.157386 0.126025 vn -0.978327 -0.157058 0.13494 f 1/1/1 2/2/2 3/3/3 …
Load .obj • <fstream> • ifstream::open, good, getline, close
Load .obj • Count number of vertex, normal, texture, face • Allocate array vertex, normal, texture, face. (Size : number of xxx) • Open file .obj -> sscanf(buffer, “format”, array …)
문제점 및 고민 • boat.obj를 가져왔기 때문에 파일 구조에 대해서 완벽하게 파악하기 어려움 • 배 class에 포함될 범주 정하기 • 기타 여러 .obj파일을 모델링하고 생성해야할 것 • 환경 텍스쳐 Mapping 기법 알아보기