Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acgl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACGL
acgl
Commits
ec856073
Commit
ec856073
authored
13 years ago
by
Robert Menzel
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
file:///data/git-repository/acgl/libraries/acgl
parents
d3706471
419c57e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/ACGL/Scene/Camera.hh
+96
-43
96 additions, 43 deletions
include/ACGL/Scene/Camera.hh
src/ACGL/Scene/Camera.cc
+3
-8
3 additions, 8 deletions
src/ACGL/Scene/Camera.cc
with
99 additions
and
51 deletions
include/ACGL/Scene/Camera.hh
+
96
−
43
View file @
ec856073
...
...
@@ -38,26 +38,26 @@ public:
updateOrientationByLocalCoordinateSystem
();
}
Camera
(
int_t
width
,
int_t
height
,
float
fov
,
float
near
,
float
far
,
const
glm
::
vec3
&
position
,
const
glm
::
vec3
&
target
)
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
),
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
)
mPosition
(
_
position
),
mTarget
(
_
target
)
{
updateLocalCoordinateSystemByTarget
();
updateOrientationByLocalCoordinateSystem
();
...
...
@@ -80,32 +80,76 @@ public:
}
~
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
float
getAspectRatio
(
void
)
const
{
return
(
float
)
mWidth
/
(
float
)
mHeight
;
}
inline
const
glm
::
vec3
&
getUpDirection
(
void
)
const
{
return
mUp
;
}
inline
const
glm
::
vec3
&
getRightDirection
(
void
)
const
{
return
mRight
;
}
inline
const
glm
::
vec3
&
getForwardDirection
(
void
)
const
{
return
mForward
;
}
inline
int_t
getWidth
(
void
)
const
{
return
mWidth
;
}
inline
int_t
getHeight
(
void
)
const
{
return
mHeight
;
}
inline
float
getFOV
(
void
)
const
{
return
mFOV
;
}
inline
float
getNear
(
void
)
const
{
return
mNear
;
}
inline
float
getFar
(
void
)
const
{
return
mFar
;
}
inline
float
getPitch
(
void
)
const
{
return
mPitch
;
}
inline
float
getYaw
(
void
)
const
{
return
mYaw
;
}
inline
float
getRoll
(
void
)
const
{
return
mRoll
;
}
inline
const
glm
::
vec3
&
getPosition
(
void
)
const
{
return
mPosition
;
}
inline
const
glm
::
vec3
&
getTarget
(
void
)
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
setPosition
(
const
glm
::
vec3
&
_position
,
bool
_moveTarget
=
true
)
{
if
(
_moveTarget
)
mTarget
+=
_position
-
mPosition
;
mPosition
=
_position
;
if
(
!
_moveTarget
)
updateLocalCoordinateSystemByTarget
(
mUp
);
}
inline
void
setPosition
(
const
glm
::
vec3
&
_position
,
const
glm
::
vec3
&
_up
,
bool
_moveTarget
=
true
)
{
if
(
_moveTarget
)
mTarget
+=
_position
-
mPosition
;
mPosition
=
_position
;
updateLocalCoordinateSystemByTarget
(
_up
);
}
inline
void
setTarget
(
const
glm
::
vec3
&
_target
,
bool
_movePosition
=
true
)
{
if
(
_movePosition
)
mPosition
+=
_target
-
mTarget
;
mTarget
=
_target
;
if
(
!
_movePosition
)
updateLocalCoordinateSystemByTarget
(
mUp
);
}
inline
void
setPitch
(
float
_pitch
)
{
mPitch
=
_pitch
;
updateLocalCoordinateSystemByOrientation
();
mTarget
=
mPosition
+
glm
::
length
(
mTarget
-
mPosition
)
*
mForward
;
}
inline
void
setYaw
(
float
_yaw
)
{
mYaw
=
_yaw
;
updateLocalCoordinateSystemByOrientation
();
mTarget
=
mPosition
+
glm
::
length
(
mTarget
-
mPosition
)
*
mForward
;
}
inline
void
setRoll
(
float
_roll
)
{
mRoll
=
_roll
;
}
inline
void
setPitchAroundTarget
(
float
pitch
)
{
...
...
@@ -120,15 +164,24 @@ public:
mPosition
=
mTarget
-
glm
::
length
(
mTarget
-
mPosition
)
*
mForward
;
}
inline
void
setOrientation
(
float
_pitch
,
float
_yaw
,
float
_roll
)
{
mPitch
=
_pitch
;
mYaw
=
_yaw
;
mRoll
=
_roll
;
updateLocalCoordinateSystemByOrientation
();
}
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
:
void
updateLocalCoordinateSystemByTarget
(
const
glm
::
vec3
&
_up
=
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
));
void
updateLocalCoordinateSystemByOrientation
(
void
);
void
updateOrientationByLocalCoordinateSystem
(
void
);
glm
::
vec3
mRight
;
glm
::
vec3
mUp
;
glm
::
vec3
mForward
;
...
...
This diff is collapsed.
Click to expand it.
src/ACGL/Scene/Camera.cc
+
3
−
8
View file @
ec856073
...
...
@@ -50,15 +50,15 @@ glm::mat4 Camera::getInverseViewMatrix(void) const
return
mView
;
}
void
Camera
::
updateLocalCoordinateSystemByTarget
(
const
glm
::
vec3
&
up
)
void
Camera
::
updateLocalCoordinateSystemByTarget
(
const
glm
::
vec3
&
_
up
)
{
mForward
=
glm
::
normalize
(
mTarget
-
mPosition
);
mRight
=
glm
::
normalize
(
glm
::
cross
(
mForward
,
up
)
);
mRight
=
glm
::
normalize
(
glm
::
cross
(
mForward
,
_
up
)
);
mUp
=
glm
::
normalize
(
glm
::
cross
(
mRight
,
mForward
)
);
}
void
Camera
::
updateLocalCoordinateSystemByOrientation
(
bool
moveTarget
)
void
Camera
::
updateLocalCoordinateSystemByOrientation
(
void
)
{
//Calculate the full rotation in the right order:
//rot => 1. mYaw (y) -> 2. mPitch (x) -> 3. mRoll (z)
...
...
@@ -71,11 +71,6 @@ void Camera::updateLocalCoordinateSystemByOrientation(bool moveTarget)
mRight
=
rotation
*
glm
::
vec3
(
1.0
f
,
0.0
f
,
0.0
f
);
mUp
=
rotation
*
glm
::
vec3
(
0.0
f
,
1.0
f
,
0.0
f
);
mForward
=
rotation
*
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
);
if
(
moveTarget
)
{
mTarget
=
mPosition
+
(
rotation
*
(
mTarget
-
mPosition
));
}
}
void
Camera
::
updateOrientationByLocalCoordinateSystem
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment