Irrlicht Newton GD tutorial: prepare to add some Newtonianity
At this point we have an application with
- 1x Ninja, walking around
- 1x sphere, hanging in the center of the screen
- 1x cube, flying around the sphere
That’s our “game”? Doubtely… So let’s make things move like in real world! Or just like that…
Requirements
First of all, go and get the
Newton GD files. And unpack it… right to the source
directory of our project! That’s right!
I’m not insane and I’m aware you are going to put a lot of files in your project. But have no
fear - you may always add them to .gitignore
and skip them from being tracked in your Git repo:
source/newton-dynamics-master/applications
source/newton-dynamics-master/packages/projects
source/newton-dynamics-master/packages/thirdParty
source/newton-dynamics-master/coreLibrary_300/projects
You are using Git, right?.. Now, you place the Newton GD sources in your project directory and change
your CMakeLists.txt
file to look like this:
cmake_minimum_required(VERSION 3.1)
project(irrlicht_newton_game1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
option("NEWTON_DEMOS_SANDBOX" "Build demos sandbox" OFF)
set(NEWTONGD_PATH source/newton-dynamics-master)
set(NEWTONGD_INCLUDE_DIRS
${NEWTONGD_PATH}/packages/dCustomJoints
${NEWTONGD_PATH}/packages/dContainers
${NEWTONGD_PATH}/packages/dMath
)
set(NEWTON_LIBRARIES Newton dMath)
add_subdirectory(${NEWTONGD_PATH})
find_package(X11)
find_package(OpenGL)
find_package(ZLIB)
if (NOT IRRLICHT_LIBRARY_PATH)
find_library(IRRLICHT_LIBRARY_PATH
NAMES Irrlicht
PATHS ${IRRLICHT_PATH}/lib/
PATH_SUFFIXES Linux MacOSX Win32-gcc Win32-visualstudio Win64-visualstudio)
message(STATUS "Found Irrlicht: ${IRRLICHT_LIBRARY_PATH}")
endif()
include_directories(${IRRLICHT_PATH}/include ${NEWTONGD_INCLUDE_DIRS})
set(SOURCE_FILES source/main.cpp)
set(EXECUTABLE_NAME irrlicht_newton_game1)
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES})
target_link_libraries(${EXECUTABLE_NAME}
${NEWTON_LIBRARIES}
${IRRLICHT_LIBRARY_PATH}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
${ZLIB_LIBRARIES}
${X11_Xxf86vm_LIB})
Try to compile your project - it should be just fine. And observe the power of CMake!