Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
acgl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACGL
acgl
Commits
0ddcc4d3
Commit
0ddcc4d3
authored
Jul 27, 2011
by
Robert Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit
parents
Changes
67
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
4973 additions
and
0 deletions
+4973
-0
CMakeLists.txt
CMakeLists.txt
+86
-0
include/ACGL/ACGL.hh
include/ACGL/ACGL.hh
+28
-0
include/ACGL/Base/CompileTimeSettings.hh
include/ACGL/Base/CompileTimeSettings.hh
+74
-0
include/ACGL/Base/Settings.hh
include/ACGL/Base/Settings.hh
+66
-0
include/ACGL/Base/Singleton.hh
include/ACGL/Base/Singleton.hh
+43
-0
include/ACGL/GL.hh
include/ACGL/GL.hh
+131
-0
include/ACGL/GLUtils/Camera.hh
include/ACGL/GLUtils/Camera.hh
+145
-0
include/ACGL/GLUtils/CoordinateSystem.hh
include/ACGL/GLUtils/CoordinateSystem.hh
+62
-0
include/ACGL/GLUtils/MatrixStack.hh
include/ACGL/GLUtils/MatrixStack.hh
+110
-0
include/ACGL/GLUtils/Tools.hh
include/ACGL/GLUtils/Tools.hh
+114
-0
include/ACGL/Math/Constants.hh
include/ACGL/Math/Constants.hh
+70
-0
include/ACGL/Math/Functions.hh
include/ACGL/Math/Functions.hh
+121
-0
include/ACGL/Math/Math.hh
include/ACGL/Math/Math.hh
+22
-0
include/ACGL/Resource/ArrayBuffer.hh
include/ACGL/Resource/ArrayBuffer.hh
+181
-0
include/ACGL/Resource/ArrayBufferControl.hh
include/ACGL/Resource/ArrayBufferControl.hh
+90
-0
include/ACGL/Resource/BasicController.hh
include/ACGL/Resource/BasicController.hh
+34
-0
include/ACGL/Resource/ElementArrayBuffer.hh
include/ACGL/Resource/ElementArrayBuffer.hh
+119
-0
include/ACGL/Resource/ElementArrayBufferControl.hh
include/ACGL/Resource/ElementArrayBufferControl.hh
+80
-0
include/ACGL/Resource/FileController.hh
include/ACGL/Resource/FileController.hh
+58
-0
include/ACGL/Resource/FileManager.hh
include/ACGL/Resource/FileManager.hh
+146
-0
include/ACGL/Resource/FrameBuffer.hh
include/ACGL/Resource/FrameBuffer.hh
+206
-0
include/ACGL/Resource/FrameBufferControl.hh
include/ACGL/Resource/FrameBufferControl.hh
+75
-0
include/ACGL/Resource/NameManager.hh
include/ACGL/Resource/NameManager.hh
+116
-0
include/ACGL/Resource/RenderBuffer.hh
include/ACGL/Resource/RenderBuffer.hh
+63
-0
include/ACGL/Resource/RenderBufferControl.hh
include/ACGL/Resource/RenderBufferControl.hh
+61
-0
include/ACGL/Resource/Resource.hh
include/ACGL/Resource/Resource.hh
+39
-0
include/ACGL/Resource/ResourceTypes.hh
include/ACGL/Resource/ResourceTypes.hh
+59
-0
include/ACGL/Resource/Shader.hh
include/ACGL/Resource/Shader.hh
+78
-0
include/ACGL/Resource/ShaderControlFile.hh
include/ACGL/Resource/ShaderControlFile.hh
+53
-0
include/ACGL/Resource/ShaderProgram.hh
include/ACGL/Resource/ShaderProgram.hh
+118
-0
include/ACGL/Resource/ShaderProgramControlAutoFiles.hh
include/ACGL/Resource/ShaderProgramControlAutoFiles.hh
+40
-0
include/ACGL/Resource/Texture.hh
include/ACGL/Resource/Texture.hh
+241
-0
include/ACGL/Resource/TextureControl.hh
include/ACGL/Resource/TextureControl.hh
+92
-0
include/ACGL/Resource/TextureControlFileJPG.hh
include/ACGL/Resource/TextureControlFileJPG.hh
+59
-0
include/ACGL/Resource/Uniform.hh
include/ACGL/Resource/Uniform.hh
+91
-0
include/ACGL/Resource/VertexBuffer.hh
include/ACGL/Resource/VertexBuffer.hh
+136
-0
include/ACGL/Resource/VertexBufferControl.hh
include/ACGL/Resource/VertexBufferControl.hh
+87
-0
include/ACGL/Resource/VertexBufferControlFileOBJ.hh
include/ACGL/Resource/VertexBufferControlFileOBJ.hh
+43
-0
include/ACGL/Types.hh
include/ACGL/Types.hh
+31
-0
include/ACGL/Utils/FileHelpers.hh
include/ACGL/Utils/FileHelpers.hh
+67
-0
include/ACGL/Utils/FileHelpersiOS.h
include/ACGL/Utils/FileHelpersiOS.h
+9
-0
include/ACGL/Utils/FileOperations.hh
include/ACGL/Utils/FileOperations.hh
+18
-0
include/ACGL/Utils/Log.hh
include/ACGL/Utils/Log.hh
+125
-0
include/ACGL/Utils/StringOperations.hh
include/ACGL/Utils/StringOperations.hh
+46
-0
src/ACGL/ACGL.cc
src/ACGL/ACGL.cc
+18
-0
src/ACGL/GLUtils/Camera.cc
src/ACGL/GLUtils/Camera.cc
+101
-0
src/ACGL/GLUtils/CoordinateSystem.cc
src/ACGL/GLUtils/CoordinateSystem.cc
+120
-0
src/ACGL/GLUtils/Tools.cc
src/ACGL/GLUtils/Tools.cc
+55
-0
src/ACGL/Resource/ArrayBuffer.cc
src/ACGL/Resource/ArrayBuffer.cc
+31
-0
src/ACGL/Resource/ArrayBufferControl.cc
src/ACGL/Resource/ArrayBufferControl.cc
+29
-0
src/ACGL/Resource/FrameBuffer.cc
src/ACGL/Resource/FrameBuffer.cc
+18
-0
src/ACGL/Resource/FrameBufferControl.cc
src/ACGL/Resource/FrameBufferControl.cc
+27
-0
src/ACGL/Resource/Shader.cc
src/ACGL/Resource/Shader.cc
+79
-0
src/ACGL/Resource/ShaderControlFile.cc
src/ACGL/Resource/ShaderControlFile.cc
+47
-0
src/ACGL/Resource/ShaderProgram.cc
src/ACGL/Resource/ShaderProgram.cc
+46
-0
src/ACGL/Resource/ShaderProgramControlAutoFiles.cc
src/ACGL/Resource/ShaderProgramControlAutoFiles.cc
+34
-0
src/ACGL/Resource/Texture.cc
src/ACGL/Resource/Texture.cc
+10
-0
src/ACGL/Resource/TextureControlFileJPG.cc
src/ACGL/Resource/TextureControlFileJPG.cc
+40
-0
src/ACGL/Resource/TextureControlFileJPG_QImage.cc
src/ACGL/Resource/TextureControlFileJPG_QImage.cc
+30
-0
src/ACGL/Resource/VertexBuffer.cc
src/ACGL/Resource/VertexBuffer.cc
+53
-0
src/ACGL/Resource/VertexBufferControl.cc
src/ACGL/Resource/VertexBufferControl.cc
+45
-0
src/ACGL/Resource/VertexBufferControlFileOBJ.cc
src/ACGL/Resource/VertexBufferControlFileOBJ.cc
+325
-0
src/ACGL/Utils/FileHelpers.cc
src/ACGL/Utils/FileHelpers.cc
+110
-0
src/ACGL/Utils/FileHelpersiOS.mm
src/ACGL/Utils/FileHelpersiOS.mm
+22
-0
src/ACGL/Utils/FileOperations.cc
src/ACGL/Utils/FileOperations.cc
+0
-0
src/ACGL/Utils/Log.cc
src/ACGL/Utils/Log.cc
+0
-0
src/ACGL/Utils/StringOperations.cc
src/ACGL/Utils/StringOperations.cc
+0
-0
No files found.
CMakeLists.txt
0 → 100644
View file @
0ddcc4d3
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
################################################################################
# Global Settings
################################################################################
# Name of the Project
PROJECT
(
ACGL
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/CompileOptions.txt
)
# Specify dependencies
SET
(
NEED_ACGL_GLOBAL_EXTERN_DIR TRUE
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/cmake/GlobalAndLocalExternACGL.txt
)
# OpenGL Support
IF
(
NOT DEFINED OPENGL_SUPPORT
)
IF
(
NOT DEFINED OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_CORE_4_0 FALSE CACHE BOOL
""
)
ENDIF
()
IF
(
NOT DEFINED OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_ES_2_1 FALSE CACHE BOOL
""
)
ENDIF
()
IF
(
OPENGL_SUPPORT_CORE_4_0
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_CORE_4_0
)
ENDIF
()
IF
(
OPENGL_SUPPORT_ES_2_1
)
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT_LIST
}
GL_ES_2_1
)
ENDIF
()
ELSE
()
SET
(
OPENGL_SUPPORT_LIST
${
OPENGL_SUPPORT
}
)
ENDIF
()
FOREACH
(
OPENGL_SUPPORT
${
OPENGL_SUPPORT_LIST
}
)
################################################################################
# Basic Configuration
################################################################################
# Name of the Project
PROJECT
(
AC
${
OPENGL_SUPPORT
}
)
# Where to find the cmake finders?
SET
(
CMAKE_MODULE_PATH
"
${
CMAKE_SOURCE_DIR
}
/cmake"
${
CMAKE_MODULE_PATH
}
)
# Target directory
SET
(
LIBRARY_OUTPUT_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/lib"
)
################################################################################
# Project Files
################################################################################
# Find all used files of certain file-types
FILE
(
GLOB_RECURSE SOURCE_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/*.cc"
)
# Add ACGL to the include path
INCLUDE_DIRECTORIES
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
################################################################################
# External Libraries
################################################################################
# Qt
SET
(
QT_USE_QTOPENGL TRUE
)
FIND_PACKAGE
(
Qt4 REQUIRED
)
INCLUDE
(
${
QT_USE_FILE
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
QT_LIBRARIES
}
)
# GLM
FIND_PACKAGE
(
GLM REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLM_INCLUDE_DIR
}
)
# GLEW
FIND_PACKAGE
(
GLEW REQUIRED
)
INCLUDE_DIRECTORIES
(
${
GLEW_INCLUDE_DIR
}
)
SET
(
LIBRARIES
${
LIBRARIES
}
${
GLEW_LIBRARIES
}
)
################################################################################
# Final Definition
################################################################################
# Define the Project, add all required sources and dependencies to it
ADD_LIBRARY
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
STATIC
${
SOURCE_FILES
}
)
TARGET_LINK_LIBRARIES
(
AC
${
OPENGL_SUPPORT
}${
COMPILE_POSTFIX
}
${
LIBRARIES
}
)
ENDFOREACH
()
include/ACGL/ACGL.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_HH
#define ACGL_HH
/*
* Include this in all ACGL (header)-files. It will include stuff that is used in
* almost every file:
* the used datatypes
* macros and defines used at compile-time
* logging
*/
#include <ACGL/Base/CompileTimeSettings.hh>
#include <ACGL/Types.hh>
#include <ACGL/Utils/Log.hh>
namespace
ACGL
{
void
init
(
void
);
};
#endif // ACGL_HH
include/ACGL/Base/CompileTimeSettings.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef COMPILETIMESETTINGS_HH
#define COMPILETIMESETTINGS_HH
/*
* OpenGL error checking
*
* By default, only critical errors will get checked in release build
* and critical&common in debug build.
*
* This can get overwritten with a compile flag define:
* -DACGL_CHECK_NO_GL_ERRORS
* No error checking at all
* -DACGL_CHECK_CRITICAL_GL_ERRORS
* Places will get checked where errors like out of memory can occur.
* This will detect runtime errors which can happen even if the program
* is bug free.
* Switching this on shouldn't be a performance hit.
* -DACGL_CHECK_COMMON_GL_ERRORS
* Problems that happen more often while developing like typos in uniform
* names. All placed where strings are used to call OpenGL objects etc.
* -DACGL_CHECK_RARE_GL_ERRORS
* Most likely bugs in ACGL itself or wrong usage. If there are strange errors
* switch this on to find the reason more quickly. Even normal development
* should work without this. Results in a lot of glGetError!
*
* Note that all error levels also include the higher ones (COMMON also adds CRITICAL).
*/
#ifndef ACGL_CHECK_NO_GL_ERRORS
# ifndef ACGL_CHECK_CRITICAL_GL_ERRORS
# ifndef ACGL_CHECK_COMMON_GL_ERRORS
# ifndef ACGL_CHECK_RARE_GL_ERRORS
// if nothing is defined, use defaults:
# ifdef DEBUG
# define ACGL_CHECK_COMMON_GL_ERRORS
# else
# define ACGL_CHECK_CRITICAL_GL_ERRORS
# endif
# endif
# endif
# endif
#endif
// if rare is set, set also common:
#ifdef ACGL_CHECK_RARE_GL_ERRORS
# ifndef ACGL_CHECK_COMMON_GL_ERRORS
# define ACGL_CHECK_COMMON_GL_ERRORS
# endif
#endif
// if common is set, set also critical:
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
# ifndef ACGL_CHECK_CRITICAL_GL_ERRORS
# define ACGL_CHECK_CRITICAL_GL_ERRORS
# endif
#endif
// if critical is set, NO must not be set:
#ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
# ifdef ACGL_CHECK_NO_GL_ERRORS
# undef ACGL_CHECK_NO_GL_ERRORS
# endif
#endif
#endif // COMPILETIMESETTINGS_HH
include/ACGL/Base/Settings.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_BASE_FRAMEWORKSETTINGS_HH
#define ACGL_BASE_FRAMEWORKSETTINGS_HH
#include <ACGL/Base/Singleton.hh>
#include <string>
namespace
ACGL
{
namespace
Base
{
class
Settings
:
public
Singleton
<
Settings
>
{
friend
class
Singleton
<
Settings
>
;
// ==================================================================================================== \/
// ========================================================================= Constructors / Destructors \/
// ==================================================================================================== \/
protected:
//! Constructor is protected => singleton.
Settings
()
:
mResourcePath
(
""
),
mTexturePath
(
"Texture/"
),
mGeometryPath
(
"Geometry/"
),
mShaderPath
(
"Shader/"
)
{}
public:
~
Settings
(){}
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
public:
inline
void
setResourcePath
(
const
std
::
string
&
_path
)
{
mResourcePath
=
_path
;
}
inline
void
setTexturePath
(
const
std
::
string
&
_path
)
{
mTexturePath
=
_path
;
}
inline
void
setGeometryPath
(
const
std
::
string
&
_path
)
{
mGeometryPath
=
_path
;
}
inline
void
setShaderPath
(
const
std
::
string
&
_path
)
{
mShaderPath
=
_path
;
}
inline
const
std
::
string
&
getResourcePath
()
const
{
return
mResourcePath
;
}
inline
const
std
::
string
&
getTexturePath
()
const
{
return
mTexturePath
;
}
inline
const
std
::
string
&
getGeometryPath
()
const
{
return
mGeometryPath
;
}
inline
const
std
::
string
&
getShaderPath
()
const
{
return
mShaderPath
;
}
inline
const
std
::
string
getFullTexturePath
()
const
{
return
mResourcePath
+
mTexturePath
;
}
inline
const
std
::
string
getFullGeometryPath
()
const
{
return
mResourcePath
+
mGeometryPath
;
}
inline
const
std
::
string
getFullShaderPath
()
const
{
return
mResourcePath
+
mShaderPath
;
}
// ==================================================================================================== \/
// ============================================================================================= FIELDS \/
// ==================================================================================================== \/
private:
std
::
string
mResourcePath
;
std
::
string
mTexturePath
;
std
::
string
mGeometryPath
;
std
::
string
mShaderPath
;
};
}
// Base
}
// ACGL
#endif // FRAMEWORKSETTINGS_HH
include/ACGL/Base/Singleton.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef SINGLETON_HH
#define SINGLETON_HH
#include <tr1/memory>
namespace
ACGL
{
namespace
Base
{
template
<
typename
CLASS
>
class
Singleton
{
public:
virtual
~
Singleton
(
void
)
{}
static
std
::
tr1
::
shared_ptr
<
CLASS
>
the
(
void
)
{
if
(
!
spInstance
)
spInstance
.
reset
(
new
CLASS
());
return
(
spInstance
);
}
protected:
Singleton
(
void
){}
private:
Singleton
(
const
Singleton
&
){}
private:
static
std
::
tr1
::
shared_ptr
<
CLASS
>
spInstance
;
};
template
<
typename
CLASS
>
std
::
tr1
::
shared_ptr
<
CLASS
>
Singleton
<
CLASS
>::
spInstance
=
std
::
tr1
::
shared_ptr
<
CLASS
>
();
}
// Base
}
// ACGL
#endif
include/ACGL/GL.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_GL_HH
#define ACGL_GL_HH
/*
* This simple OpenGL wrapper is used to include OpenGL, GLU, GLUT and GLEW
* on different platforms.
*
* While these includes are located in a subdirectory of GL/ on most systems,
* Apple hides them on different locations.
*
* Robert Menzel
*/
/*
* defines, what we need.
* Change this if you like.
* You don't have to include GL extra, if you need GLUT etc...
*
* QT also includes Glu!
*
* USE_GLEW and USE_GLEW_LOCAL are mutual exclusive, define only one
* change GLEW_LOCAL_PATH if you use USE_GLEW_LOCAL!
*
*/
#define USE_GL
//#define USE_GLU
//#define USE_GLUT
#define USE_QT
#define USE_GLEW
//#define USE_GLEW_LOCAL
//#define GLEW_LOCAL_PATH <GL/glew.h>
// We can try to build against OpenGL core profile or compatibility (core means automatically
// 3.2 or higher). On MacOS X 10.7 Lion we can choose between 2.1 or 3.2 core, but 3.2
// compatibility is not an option.
//#define USE_OPENGL_CORE_PROFILE
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
#if (TARGET_OS_IPHONE == 1)
#define PLATFORM_IOS
#define OPENGL_ES
#ifdef USE_QT
#undef USE_QT
#endif
#ifdef USE_GLEW
#undef USE_GLEW
#endif
#ifdef USE_GLEW_LOCAL
#undef USE_GLEW_LOCAL
#endif
#endif
#endif
/*
* No editing needed from here on!
*/
#ifdef USE_GLEW
#ifdef USE_GLEW_LOCAL
#error "OpenGLWrapper.hh: Don't include glew from your OS AND a local glew version..."
#endif
#endif
// we have allways to include glew first!
#ifdef USE_GLEW
#if defined(__APPLE__) || defined(MACOSX)
#include <OpenGL/glew.h>
#else
#include <GL/glew.h>
#endif
#endif // USE_GLEW
#ifdef USE_GLEW_LOCAL
#include GLEW_LOCAL_PATH
#endif // USE_GLEW_LOCAL
#ifdef USE_GL
#if defined(__APPLE__) || defined(MACOSX)
#ifdef OPENGL_ES
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#else
#ifdef USE_OPENGL_CORE_PROFILE
#include <GL3/gl3.h>
#else
#include <OpenGL/gl.h>
#endif
#endif
#else
#ifdef USE_OPENGL_CORE_PROFILE
#include <GL3/gl3.h>
#else
#include <GL/gl.h>
#endif
#endif
#endif // USE_GL
#ifdef USE_GLU
#if defined(__APPLE__) || defined(MACOSX)
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif
#endif // USE_GLU
#ifdef USE_GLUT
#if defined(__APPLE__) || defined(MACOSX)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#endif // USE_GLUT
#ifdef USE_QT
#include <QtOpenGL/qgl.h>
#endif // USE_QT
#endif // ACGL_GL_HH
include/ACGL/GLUtils/Camera.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_GLUTILS_CAMERA_HH
#define ACGL_GLUTILS_CAMERA_HH
#include <ACGL/Math/Math.hh>
namespace
ACGL
{
namespace
GLUtils
{
class
Camera
{
public:
Camera
(
void
)
:
mRight
(),
mUp
(),
mForward
(),
mWidth
(
800
),
mHeight
(
600
),
mFOV
(
75.0
f
),
mNear
(
0.1
f
),
mFar
(
10000.0
f
),
mPitch
(
0.0
f
),
mYaw
(
0.0
f
),
mRoll
(
0.0
f
),
mPosition
(
3.0
f
,
2.0
f
,
3.0
f
),
mTarget
(
0.0
f
,
0.0
f
,
0.0
f
)
{
updateLocalCoordinateSystemByTarget
();
updateOrientationByLocalCoordinateSystem
();
}
Camera
(
int_t
width
,
int_t
height
,
float
fov
,
float
near
,
float
far
,
const
glm
::
vec3
&
position
,
const
glm
::
vec3
&
target
)
:
mRight
(),
mUp
(),
mForward
(),
mWidth
(
width
),
mHeight
(
height
),
mFOV
(
fov
),
mNear
(
near
),
mFar
(
far
),
mPitch
(
0.0
f
),
mYaw
(
0.0
f
),
mRoll
(
0.0
f
),
mPosition
(
position
),
mTarget
(
target
)
{
updateLocalCoordinateSystemByTarget
();
updateOrientationByLocalCoordinateSystem
();
}
Camera
(
const
Camera
&
other
)
:
mRight
(
other
.
mRight
),
mUp
(
other
.
mUp
),
mForward
(
other
.
mForward
),
mWidth
(
other
.
mWidth
),
mHeight
(
other
.
mHeight
),
mFOV
(
other
.
mFOV
),
mNear
(
other
.
mNear
),
mFar
(
other
.
mFar
),
mPitch
(
other
.
mPitch
),
mYaw
(
other
.
mYaw
),
mRoll
(
other
.
mRoll
),
mPosition
(
other
.
mPosition
),
mTarget
(
other
.
mTarget
)
{
}
~
Camera
(
void
)
{}
inline
float
getAspectRatio
()
const
{
return
(
float
)
mWidth
/
(
float
)
mHeight
;
}
inline
const
glm
::
vec3
&
getUpDirection
()
const
{
return
mUp
;
}
inline
const
glm
::
vec3
&
getRightDirection
()
const
{
return
mRight
;
}
inline
const
glm
::
vec3
&
getForwardDirection
()
const
{
return
mForward
;
}
inline
int_t
getWidth
()
const
{
return
mWidth
;
}
inline
int_t
getHeight
()
const
{
return
mHeight
;
}
inline
float
getFOV
()
const
{
return
mFOV
;
}
inline
float
getNear
()
const
{
return
mNear
;
}
inline
float
getFar
()
const
{
return
mFar
;
}
inline
float
getPitch
()
const
{
return
mPitch
;
}
inline
float
getYaw
()
const
{
return
mYaw
;
}
inline
float
getRoll
()
const
{
return
mRoll
;
}
inline
const
glm
::
vec3
&
getPosition
()
const
{
return
mPosition
;
}
inline
const
glm
::
vec3
&
getTarget
()
const
{
return
mTarget
;
}
inline
void
setWidth
(
int_t
width
)
{
mWidth
=
width
;
}
inline
void
setHeight
(
int_t
height
)
{
mHeight
=
height
;
}
inline
void
setFOV
(
float
fov
)
{
mFOV
=
fov
;
}
inline
void
setNear
(
float
near
)
{
mNear
=
near
;
}
inline
void
setFar
(
float
far
)
{
mFar
=
far
;
}
inline
void
setPitch
(
float
pitch
)
{
mPitch
=
pitch
;
}
inline
void
setYaw
(
float
yaw
)
{
mYaw
=
yaw
;
}
inline
void
setRoll
(
float
roll
)
{
mRoll
=
roll
;
}
inline
void
setPosition
(
const
glm
::
vec3
&
position
,
bool
moveTarget
=
true
)
{
if
(
moveTarget
)
{
mTarget
+=
position
-
mPosition
;
}
mPosition
=
position
;
}
inline
void
setTarget
(
const
glm
::
vec3
&
target
,
bool
movePosition
=
true
)
{
if
(
movePosition
)
{
mPosition
+=
target
-
mTarget
;
}
mTarget
=
target
;
}
inline
void
setPitchAroundTarget
(
float
pitch
)
{
mPitch
=
pitch
;
updateLocalCoordinateSystemByOrientation
();
mPosition
=
mTarget
-
glm
::
length
(
mTarget
-
mPosition
)
*
mForward
;
}
inline
void
setYawAroundTarget
(
float
yaw
)
{
mYaw
=
yaw
;
updateLocalCoordinateSystemByOrientation
();
mPosition
=
mTarget
-
glm
::
length
(
mTarget
-
mPosition
)
*
mForward
;
}
glm
::
mat4
getProjectionMatrix
()
const
;
glm
::
mat4
getViewMatrix
()
const
;
glm
::
mat4
getInverseViewMatrix
()
const
;
void
updateLocalCoordinateSystemByTarget
(
const
glm
::
vec3
&
up
=
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
void
updateLocalCoordinateSystemByOrientation
(
bool
moveTarget
=
true
);
void
updateOrientationByLocalCoordinateSystem
();
private:
glm
::
vec3
mRight
;
glm
::
vec3
mUp
;
glm
::
vec3
mForward
;
int_t
mWidth
;
int_t
mHeight
;
float
mFOV
;
float
mNear
;
float
mFar
;
float
mPitch
;
float
mYaw
;
float
mRoll
;
glm
::
vec3
mPosition
;
glm
::
vec3
mTarget
;
};
}
// GLUtils
}
// ACGL
#endif // ACGL_GLUTILS_CAMERA_HH
include/ACGL/GLUtils/CoordinateSystem.hh
0 → 100644
View file @
0ddcc4d3
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_GLUTILS_COORDINATESYSTEM_HH
#define ACGL_GLUTILS_COORDINATESYSTEM_HH
#include <ACGL/Math/Math.hh>
#include <ACGL/Types.hh>
#include <vector>
namespace
ACGL
{
namespace
GLUtils
{
class
CoordinateSystem
{
public:
CoordinateSystem
(
int_t
outerLines
=
100
,
int_t
innerRange
=
2
)
:
mOuterLines
(
outerLines
),
mInnerRange
(
innerRange
),
mInnerLines
((
innerRange
*
2
+
1
)
*
10
),
mInterpolC
(
0.0
f
),
mOuterLinesCA
(
mOuterLines
*
2
),
mOuterLinesCB
(
mOuterLines
*
2
),
mInnerLinesCA
(
mInnerLines
*
2
),
mInnerLinesCB
(
mInnerLines
*
2
)
{}
~
CoordinateSystem
()
{}
/*! Adjust the grid concerning the given absolut position */
template
<
int_t
A
,
int_t
B
,
int_t
C
>
void
adjust
(
const
glm
::
vec3
&
pos
,
const
glm
::
vec3
&
forward
);
inline
int_t
getOuterLines
()
const
{
return
mOuterLines
;
}
inline
int_t
getInnerLines
()
const
{
return
mInnerLines
;
}
inline
float
getInterpolC
()
const
{
return
mInterpolC
;
}
inline
const
std
::
vector
<
glm
::
vec3
>&
getOuterLinesCA
()
const
{
return
mOuterLinesCA
;
}
inline
const
std
::
vector
<
glm
::
vec3
>&
getOuterLinesCB
()
const
{
return
mOuterLinesCB
;
}
inline
const
std
::
vector
<
glm
::
vec3
>&
getInnerLinesCA
()
const
{
return
mInnerLinesCA
;
}