Skip to content

Commit dceb7fc

Browse files
committed
Initial...
0 parents  commit dceb7fc

File tree

2,297 files changed

+1317716
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,297 files changed

+1317716
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
*user

.ycm_extra_conf.py

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# This file is NOT licensed under the GPLv3, which is the license for the rest
2+
# of YouCompleteMe.
3+
#
4+
# Here's the license text for this file:
5+
#
6+
# This is free and unencumbered software released into the public domain.
7+
#
8+
# Anyone is free to copy, modify, publish, use, compile, sell, or
9+
# distribute this software, either in source code form or as a compiled
10+
# binary, for any purpose, commercial or non-commercial, and by any
11+
# means.
12+
#
13+
# In jurisdictions that recognize copyright laws, the author or authors
14+
# of this software dedicate any and all copyright interest in the
15+
# software to the public domain. We make this dedication for the benefit
16+
# of the public at large and to the detriment of our heirs and
17+
# successors. We intend this dedication to be an overt act of
18+
# relinquishment in perpetuity of all present and future rights to this
19+
# software under copyright law.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25+
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
# OTHER DEALINGS IN THE SOFTWARE.
28+
#
29+
# For more information, please refer to <http://unlicense.org/>
30+
31+
import os
32+
import ycm_core
33+
34+
# These are the compilation flags that will be used in case there's no
35+
# compilation database set (by default, one is not set).
36+
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
37+
flags = [
38+
'-Wall',
39+
'-Wextra',
40+
'-Werror',
41+
'-Wc++98-compat',
42+
'-Wno-long-long',
43+
'-Wno-variadic-macros',
44+
'-fexceptions',
45+
'-DNDEBUG',
46+
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
47+
# source code needs it.
48+
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
49+
# language to use when compiling headers. So it will guess. Badly. So C++
50+
# headers will be compiled as C headers. You don't want that so ALWAYS specify
51+
# a "-std=<something>".
52+
# For a C project, you would set this to something like 'c99' instead of
53+
# 'c++11'.
54+
'-std=c++11',
55+
# ...and the same thing goes for the magic -x option which specifies the
56+
# language that the files to be compiled are written in. This is mostly
57+
# relevant for c++ headers.
58+
# For a C project, you would set this to 'c' instead of 'c++'.
59+
'-x',
60+
'c++11',
61+
'-isystem','/usr/include',
62+
'-isystem','/usr/local/include',
63+
'-isystem', '/home/jjcasmar/SME',
64+
'-isystem', '/home/jjcasmar/usr/local/include/eigen3',
65+
'-isystem', '/home/jjcasmar/SME/external/tinyxml2',
66+
'-isystem', '/home/jjcasmar/Qt/5.5/gcc_64/include/QtCore',
67+
'-isystem', '/home/jjcasmar/Qt/5.5/gcc_64/include/QtGui',
68+
]
69+
70+
71+
# Set this to the absolute path to the folder (NOT the file!) containing the
72+
# compile_commands.json file to use that instead of 'flags'. See here for
73+
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
74+
#
75+
# You can get CMake to generate this file for you by adding:
76+
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
77+
# to your CMakeLists.txt file.
78+
#
79+
# Most projects will NOT need to set this to anything; you can just change the
80+
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
81+
compilation_database_folder = '/home/jjcasmar/SME/build'
82+
83+
84+
if os.path.exists( compilation_database_folder ):
85+
database = ycm_core.CompilationDatabase( compilation_database_folder )
86+
else:
87+
database = None
88+
89+
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
90+
91+
def DirectoryOfThisScript():
92+
return os.path.dirname( os.path.abspath( __file__ ) )
93+
94+
95+
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
96+
if not working_directory:
97+
return list( flags )
98+
new_flags = []
99+
make_next_absolute = False
100+
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
101+
for flag in flags:
102+
new_flag = flag
103+
104+
if make_next_absolute:
105+
make_next_absolute = False
106+
if not flag.startswith( '/' ):
107+
new_flag = os.path.join( working_directory, flag )
108+
109+
for path_flag in path_flags:
110+
if flag == path_flag:
111+
make_next_absolute = True
112+
break
113+
114+
if flag.startswith( path_flag ):
115+
path = flag[ len( path_flag ): ]
116+
new_flag = path_flag + os.path.join( working_directory, path )
117+
break
118+
119+
if new_flag:
120+
new_flags.append( new_flag )
121+
return new_flags
122+
123+
124+
def IsHeaderFile( filename ):
125+
extension = os.path.splitext( filename )[ 1 ]
126+
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
127+
128+
129+
def GetCompilationInfoForFile( filename ):
130+
# The compilation_commands.json file generated by CMake does not have entries
131+
# for header files. So we do our best by asking the db for flags for a
132+
# corresponding source file, if any. If one exists, the flags for that file
133+
# should be good enough.
134+
if IsHeaderFile( filename ):
135+
basename = os.path.splitext( filename )[ 0 ]
136+
for extension in SOURCE_EXTENSIONS:
137+
replacement_file = basename + extension
138+
if os.path.exists( replacement_file ):
139+
compilation_info = database.GetCompilationInfoForFile(
140+
replacement_file )
141+
if compilation_info.compiler_flags_:
142+
return compilation_info
143+
return None
144+
return database.GetCompilationInfoForFile( filename )
145+
146+
147+
def FlagsForFile( filename, **kwargs ):
148+
if database:
149+
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
150+
# python list, but a "list-like" StringVec object
151+
compilation_info = GetCompilationInfoForFile( filename )
152+
if not compilation_info:
153+
return None
154+
155+
final_flags = MakeRelativePathsInFlagsAbsolute(
156+
compilation_info.compiler_flags_,
157+
compilation_info.compiler_working_dir_ )
158+
159+
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
160+
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
161+
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
162+
try:
163+
final_flags.remove( '-stdlib=libc++' )
164+
except ValueError:
165+
pass
166+
else:
167+
relative_to = DirectoryOfThisScript()
168+
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
169+
170+
return {
171+
'flags': final_flags,
172+
'do_cache': True
173+
}

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2+
PROJECT(SME)
3+
4+
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
5+
set(CMAKE_AUTOMOC ON)
6+
add_definitions(-std=c++11 -ldl)
7+
8+
SET(CMAKE_EXPORT_COMPILE_COMMANDS 1)
9+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
10+
11+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
12+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
13+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
14+
15+
#Project dependencies
16+
add_subdirectory(${CMAKE_SOURCE_DIR}/external/tinyxml2)
17+
add_subdirectory(${CMAKE_SOURCE_DIR}/external/assimp-3.0)
18+
19+
#Core
20+
ADD_SUBDIRECTORY(core)
21+
22+
#Plugins
23+
ADD_SUBDIRECTORY(core/corePlugin)
24+
ADD_SUBDIRECTORY(OpenGLRenderer)
25+
ADD_SUBDIRECTORY(Physics)
26+
27+
#Apps
28+
ADD_SUBDIRECTORY(apps)
29+

OpenGLRenderer/.Shader.cpp.swo

12 KB
Binary file not shown.

OpenGLRenderer/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
SET(SOURCES
2+
MeshRenderer.cpp
3+
Camera.cpp
4+
OpenGLRendererSystem.cpp
5+
SMEOpenGLWidget.cpp
6+
initPlugin.cpp
7+
Shader.cpp
8+
)
9+
10+
SET(HEADERS
11+
MeshRenderer.h
12+
Camera.h
13+
OpenGLRendererSystem.h
14+
SMEOpenGLWidget.h
15+
Shader.h
16+
)
17+
18+
FIND_PACKAGE(GLEW REQUIRED)
19+
FIND_PACKAGE(Qt5Widgets REQUIRED)
20+
FIND_PACKAGE(Qt5Gui REQUIRED)
21+
22+
FIND_PACKAGE(Eigen3 REQUIRED)
23+
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS})
24+
25+
add_library(SMEOpenGL SHARED ${SOURCES} ${HEADERS})
26+
target_link_libraries(SMEOpenGL SME ${GLEW_LIBRARIES} Qt5::Gui Qt5::Widgets)
27+

OpenGLRenderer/Camera.cpp

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#include "Camera.h"
2+
3+
#include <math.h>
4+
5+
using namespace SME::ogl;
6+
7+
SME::ogl::Camera::Camera(const std::string &type) :
8+
SME::core::Component(type)
9+
{
10+
_near = 0.1;
11+
_far = 100;
12+
_active = true;
13+
_fov = 60;
14+
_updateNeeded = true;
15+
}
16+
17+
Camera::~Camera()
18+
{
19+
20+
}
21+
22+
bool Camera::active() const
23+
{
24+
return _active;
25+
}
26+
27+
void Camera::setActive(bool active)
28+
{
29+
_active = active;
30+
_updateNeeded = true;
31+
}
32+
33+
float Camera::height() const
34+
{
35+
return _height;
36+
}
37+
38+
void Camera::setHeight(float height)
39+
{
40+
_height = height;
41+
_updateNeeded = true;
42+
}
43+
44+
float Camera::width() const
45+
{
46+
return _width;
47+
}
48+
49+
void Camera::setWidth(float width)
50+
{
51+
_width = width;
52+
_updateNeeded = true;
53+
}
54+
55+
float Camera::far() const
56+
{
57+
return _far;
58+
}
59+
60+
void Camera::setFar(float far)
61+
{
62+
_far = far;
63+
_updateNeeded = true;
64+
}
65+
66+
float Camera::near() const
67+
{
68+
return _near;
69+
}
70+
71+
void Camera::setNear(float near)
72+
{
73+
_near = near;
74+
_updateNeeded = true;
75+
}
76+
77+
float Camera::ar() const
78+
{
79+
return _ar;
80+
}
81+
82+
void Camera::setAr(float ar)
83+
{
84+
_ar = ar;
85+
_updateNeeded = true;
86+
}
87+
88+
float Camera::fov() const
89+
{
90+
return _fov;
91+
}
92+
93+
void Camera::setFov(float fov)
94+
{
95+
_fov = fov;
96+
_updateNeeded = true;
97+
}
98+
99+
Eigen::Matrix4f Camera::projection()
100+
{
101+
if (!_updateNeeded)
102+
return _projection;
103+
104+
float theta = _fov*0.5;
105+
float range = _far - _near;
106+
float invtan = 1./tan(theta);
107+
108+
_projection.setZero();
109+
110+
_projection(0,0) = invtan / _ar;
111+
_projection(1,1) = invtan;
112+
_projection(2,2) = -(_near + _far) / range;
113+
_projection(3,2) = -1;
114+
_projection(2,3) = -2 * _near * _far / range;
115+
_projection(3,3) = 0;
116+
117+
_updateNeeded = false;
118+
return _projection;
119+
}
120+
121+
void Camera::configure(tinyxml2::XMLElement *element)
122+
{
123+
124+
}

0 commit comments

Comments
 (0)