Assimp is an open source library that loads and processes 3D geometric scenes from various 3D model data formats. The library provides a unified interface to load many different data formats, such as Wavefront Object (.obj), 3ds Max 3DS (.3ds), and Stereolithography (.stl). Moreover, this library is written in portable, ISO-compliant C++, and thus, it allows further customization and long-term support. Since the library is cross-platform, we can easily install it in Mac OS X, Linux, as well as Windows with the instructions given in the next section.
To obtain the library source files or binary library for Assimp 3.0, download them directly from Assimp's official website at http://sourceforge.net/projects/assimp/files/assimp-3.0/. Alternatively, for Linux and Mac OS X users, use the command-line interface to simplify the installation steps described next.
In Mac OS X, install Assimp using the MacPort's command-line interface. It automatically resolves all dependencies, so this is recommended:
sudo port install assimp
In Linux, install Assimp using the apt-get
command interface:
sudo apt-get install install libassimp-dev
After the installation, modify the Makefile to ensure the libraries are linked to the source files by appending the following to the LIBS
variable:
`pkg-config --static --libs assimp`
and the INCLUDES
path variable, respectively:
`pkg-config --cflags assimp`
The final Makefile is shown here for your reference:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ CFILES = ../common/shader.cpp ../common/controls.cpp ../common/ObjLoader.cpp main.cpp CFLAGS = -c OPT = -O3 INCLUDES = -I../common -I/usr/include -I/usr/include/SOIL -I. `pkg-config --cflags glfw3` `pkg-config --cflags assimp` LIBS = -lm -L/usr/local/lib -lGLEW `pkg-config --static --libs glfw3` `pkg-config --static --libs assimp` CC = g++ OBJECTS=$(CFILES:.cpp=.o) EXECUTABLE=main all: $(CFILES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(OPT) $(INCLUDES) $(OBJECTS) -o $@ $(LIBS) .cpp.o: $(CC) $(OPT) $(CFLAGS) $(INCLUDES) $< -o $@ clean: rm -v -f *~ ../common/*.o *.o $(EXECUTABLE)
To install Assimp in Windows, first, download the binary library from this link: http://sourceforge.net/projects/assimp/files/assimp-3.0/assimp--3.0.1270-full.zip/download.
Then, we configure the environment with the following steps:
assimp--3.0.1270-full.zip
and save it in C:/Program Files (x86)/
.C:/Program Files (x86)/assimp--3.0.1270-sdk/bin/assimp_release-dll_win32
, to the PATH environment variable.CMakeLists.txt
file to the project:cmake_minimum_required (VERSION 2.8) set(CMAKE_CONFIGURATION_TYPES Debug Release) set(PROGRAM_PATH "C:/Program Files (x86)") set(OpenCV_DIR ${PROGRAM_PATH}/opencv/build) project (code) #modify these path based on your configuration #OpenCV find_package(OpenCV REQUIRED ) INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${PROGRAM_PATH}/glm) INCLUDE_DIRECTORIES(${PROGRAM_PATH}/glew-1.10.0/include) LINK_DIRECTORIES(${PROGRAM_PATH}/glew-1.10.0/lib/Release/Win32) INCLUDE_DIRECTORIES(${PROGRAM_PATH}/glfw-3.0.4/include) LINK_DIRECTORIES(${PROGRAM_PATH}/glfw-3.0.4/lib) INCLUDE_DIRECTORIES(${PROGRAM_PATH}/Simple OpenGL Image Library/src) INCLUDE_DIRECTORIES(${PROGRAM_PATH}/assimp--3.0.1270-sdk/include/assimp) LINK_DIRECTORIES(${PROGRAM_PATH}/assimp--3.0.1270-sdk/lib/assimp_release-dll_win32) add_subdirectory (../common common) add_executable (main main.cpp) target_link_libraries (main LINK_PUBLIC shader controls texture glew32s glfw3 opengl32 assimp ObjLoader)
Finally, generate the build files with the same steps as described in Chapter 4, Rendering 2D Images and Videos with Texture Mapping and Chapter 5, Rendering of Point Cloud Data for 3D Range-sensing Cameras.
In addition to importing 3D model objects, Assimp also supports the exporting of 3D models in .obj
, .stl
, and .ply
formats. By combining this library with the OpenGL graphics rendering engine, we have created a simple yet powerful mechanism to visualize and exchange 3D models collaboratively or remotely. The Assimp library can also handle some postprocessing tasks of 3D scenes after importing the model (for example, splitting large meshes to overcome certain GPU limitations on vertex count). These additional features are documented on the official website and may be of interest to advanced users (http://assimp.sourceforge.net/lib_html/index.html).
18.191.147.190