Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 64 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if(APPLE)
cmake_minimum_required(VERSION 3.9.6)
else()
cmake_minimum_required(VERSION 3.6)
if(APPLE)
cmake_minimum_required(VERSION 3.9.6)
else()
cmake_minimum_required(VERSION 3.6)
endif()

# Name of the project
Expand All @@ -20,22 +20,23 @@ include_directories("ext/glad/include")
# Set the executable.
add_executable(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS} ${GLSL})

# Set the default target for VS and Xcode
if(APPLE)
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
else()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT lab)
endif()

# Set the default target for VS and Xcode
if(APPLE)
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
else()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT lab)
endif()


# Add GLFW
# Get the GLFW environment variable.
# There should be a CMakeLists.txt in the specified directory.
set(GLFW_DIR "$ENV{GLFW_DIR}")
# If there is no environment variable, search locally
if(NOT GLFW_DIR)
set(GLFW_DIR "ext/glfw-3.3-prerelease")
set(GLFW_DIR "$ENV{GLFW_DIR}")
set(FBX_INCLUDE_DIR "$ENV{FBX_INCLUDE_DIR}")
# If there is no environment variable, search locally
if(NOT GLFW_DIR)
set(GLFW_DIR "ext/glfw-3.3-prerelease")
endif()
if(GLFW_DIR)
message(STATUS "GLFW environment variable found")
Expand Down Expand Up @@ -73,10 +74,10 @@ endif()
# Add GLM
# Get the GLM environment variable. Since GLM is a header-only library, we
# just need to add it to the include directory.
set(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
# If there is no environment variable, search locally
if(NOT GLM_INCLUDE_DIR)
set(GLM_INCLUDE_DIR "ext/glm-0.9.8.3")
set(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
# If there is no environment variable, search locally
if(NOT GLM_INCLUDE_DIR)
set(GLM_INCLUDE_DIR "ext/glm-0.9.8.3")
endif()
if(GLM_INCLUDE_DIR)
include_directories(${GLM_INCLUDE_DIR})
Expand All @@ -95,6 +96,30 @@ if(WIN32)
# -Wall produces way too many warnings.
# -pedantic is not supported.
target_link_libraries(${CMAKE_PROJECT_NAME} opengl32.lib)
# Add FBX
# If there is no environment variable, search locally
if(NOT FBX_INCLUDE_DIR)
set(FBX_INCLUDE_DIR "C:/Program\ Files/Autodesk/FBX/FBX\ SDK/2019.0/include")
endif()
set(FBX_LIBRARY_DIR "C:/Program\ Files/Autodesk/FBX/FBX\ SDK/2019.0/lib/vs2015/x86/debug")

if(FBX_INCLUDE_DIR)
include_directories(${FBX_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${FBX_LIBRARY_DIR}/libfbxsdk.lib)
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
else()
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
endif()

set(dllLoc ${FBX_LIBRARY_DIR}/libfbxsdk.dll)
set(dest ${CMAKE_CURRENT_BINARY_DIR}/libfbxsdk.dll)
add_custom_command(
TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dllLoc} ${dest}
DEPENDS ${dest}
COMMENT "copies over dll for fbx sdk to build directory so it can be used during execution"
)

else()
# Enable all pedantic warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic")
Expand All @@ -105,5 +130,25 @@ else()
else()
#Link the Linux OpenGL library
target_link_libraries(${CMAKE_PROJECT_NAME} "GL" "dl")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} Threads::Threads)

# If there is no environment variable, search locally
if(NOT FBX_INCLUDE_DIR)
set(FBX_INCLUDE_DIR "/usr/include/fbxsdk")
endif()
set(FBX_LIBRARY "/usr/lib/gcc4/x64/release/libfbxsdk.a")


if(FBX_INCLUDE_DIR)
include_directories(${FBX_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${FBX_LIBRARY} ${CMAKE_DL_LIBS})
message(STATUS "FBX environment variable found")
else()
# If the FBX_INCLUDE_DIR environment variable is not set, we assume
# the user has installed FBX properly on their system
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
endif()
endif()
endif()
Binary file added resources/test.fbx
Binary file not shown.
1 change: 1 addition & 0 deletions src/Program.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Program.h"
#include <iostream>
#include <vector>
#include <cstring>
#include "GLSL.h"

void Program::setShaderNames(const std::string &v, const std::string &f, const std::string &g) {
Expand Down
28 changes: 28 additions & 0 deletions src/bone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
// value_ptr for glm
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
using namespace glm;
using namespace std;
class bone
{
public:
string name;
vec3 pos;
quat q;
bone *parent = NULL;
vector<bone*> kids;
int index;
mat4 *mat = NULL;
void write_to_VBO(vec3 origin,vector<vec3> &vpos)
{
vpos.push_back(origin);
vec3 endp = origin + pos;
vpos.push_back(endp);
for (int i = 0; i < kids.size(); i++)
kids[i]->write_to_VBO(endp, vpos);

}

};
int readtobone(bone **root);
Loading