Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
9e817f2e
Commit
9e817f2e
authored
Apr 21, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed Animation
parent
17e76809
Pipeline
#72
skipped
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
134 deletions
+15
-134
mainwidget.cpp
QTProject/mainwidget.cpp
+11
-47
mainwidget.h
QTProject/mainwidget.h
+3
-10
mainwindow.cpp
QTProject/mainwindow.cpp
+0
-17
mainwindow.h
QTProject/mainwindow.h
+0
-3
mesh.cpp
QTProject/mesh.cpp
+0
-0
mesh.h
QTProject/mesh.h
+1
-57
No files found.
QTProject/mainwidget.cpp
View file @
9e817f2e
...
@@ -6,10 +6,7 @@ MainWidget::MainWidget(Camera *cam)
...
@@ -6,10 +6,7 @@ MainWidget::MainWidget(Camera *cam)
startTime
=
QTime
::
currentTime
();
startTime
=
QTime
::
currentTime
();
rotTime
=
QTime
::
currentTime
();
rotTime
=
QTime
::
currentTime
();
linear
=
false
;
rotation
=
true
;
rotation
=
true
;
animate
=
true
;
Animation
=
0
;
}
}
QSize
MainWidget
::
minimumSizeHint
()
const
QSize
MainWidget
::
minimumSizeHint
()
const
...
@@ -96,7 +93,7 @@ QVector3D* MainWidget::trackballPoint(int x, int y){
...
@@ -96,7 +93,7 @@ QVector3D* MainWidget::trackballPoint(int x, int y){
void
MainWidget
::
initializeGL
(){
void
MainWidget
::
initializeGL
(){
bool
glFunctionsOK
=
initializeOpenGLFunctions
();
bool
glFunctionsOK
=
initializeOpenGLFunctions
();
//
Q_ASSERT(glFunctionsOK);
Q_ASSERT
(
glFunctionsOK
);
if
(
!
glFunctionsOK
){
if
(
!
glFunctionsOK
){
qDebug
()
<<
"ContextFormat"
<<
this
->
context
()
->
format
();
qDebug
()
<<
"ContextFormat"
<<
this
->
context
()
->
format
();
exit
(
4
);
exit
(
4
);
...
@@ -107,7 +104,7 @@ void MainWidget::initializeGL(){
...
@@ -107,7 +104,7 @@ void MainWidget::initializeGL(){
glDisable
(
GL_CULL_FACE
);
glDisable
(
GL_CULL_FACE
);
// Shader
// Shader
animationShader
=
initShader
(
QLatin1String
(
":/animate.frag"
),
QLatin1String
(
":/animate.vert"
)
);
subdevisionShader
=
initShader
(
);
loadNewMesh
();
loadNewMesh
();
}
}
...
@@ -122,15 +119,6 @@ void MainWidget::loadNewMesh(){
...
@@ -122,15 +119,6 @@ void MainWidget::loadNewMesh(){
qDebug
()
<<
"Opening File:"
<<
fn
;
qDebug
()
<<
"Opening File:"
<<
fn
;
Mesh
*
temp
=
new
Mesh
(
this
,
fn
);
Mesh
*
temp
=
new
Mesh
(
this
,
fn
);
mesh
=
temp
;
mesh
=
temp
;
mesh
->
setAnimation
(
linear
);
}
void
MainWidget
::
setInterpolation
(
bool
linear
){
qDebug
()
<<
"linear"
<<
linear
;
this
->
linear
=
linear
;
if
(
mesh
)
mesh
->
setAnimation
(
linear
);
}
}
void
MainWidget
::
setRotation
(
bool
started
){
void
MainWidget
::
setRotation
(
bool
started
){
...
@@ -141,28 +129,11 @@ void MainWidget::setRotation(bool started){
...
@@ -141,28 +129,11 @@ void MainWidget::setRotation(bool started){
}
}
void
MainWidget
::
setAnimating
(
bool
started
){
QOpenGLShaderProgram
*
MainWidget
::
initShader
(){
qDebug
()
<<
"animating"
<<
started
;
QString
fragSource
=
QLatin1String
(
":/animate.frag"
);
this
->
animate
=
started
;
QString
vertSource
=
QLatin1String
(
":/animate.vert"
);
if
(
started
){
startTime
=
QTime
::
currentTime
();
}
}
void
MainWidget
::
nextAnimation
(){
Animation
++
;
Animation
=
Animation
%
mesh
->
scene
->
mNumAnimations
;
startTime
=
QTime
::
currentTime
();
qDebug
()
<<
"Animation"
<<
Animation
;
}
QOpenGLShader
*
vert
=
new
QOpenGLShader
(
QOpenGLShader
::
Vertex
);
QOpenGLShaderProgram
*
MainWidget
::
initShader
(
QString
fragSource
,
QString
vertSource
){
QOpenGLShader
*
vert
=
new
QOpenGLShader
(
QOpenGLShader
::
Vertex
);
if
(
!
vert
->
compileSourceFile
(
vertSource
)){
if
(
!
vert
->
compileSourceFile
(
vertSource
)){
qCritical
()
<<
"Fragment Shader"
<<
vertSource
<<
"failed"
<<
vert
->
log
();
qCritical
()
<<
"Fragment Shader"
<<
vertSource
<<
"failed"
<<
vert
->
log
();
exit
(
5
);
exit
(
5
);
...
@@ -200,18 +171,13 @@ void MainWidget::paintGL(){
...
@@ -200,18 +171,13 @@ void MainWidget::paintGL(){
rot
.
rotate
(
time
/
100.0
*
36
/
5
,
QVector3D
(
0
,
1
,
0
));
rot
.
rotate
(
time
/
100.0
*
36
/
5
,
QVector3D
(
0
,
1
,
0
));
}
}
animat
ionShader
->
bind
();
subdevis
ionShader
->
bind
();
animat
ionShader
->
setUniformValue
(
"colorTexture"
,
0
);
subdevis
ionShader
->
setUniformValue
(
"colorTexture"
,
0
);
animat
ionShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
subdevis
ionShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
float
ftime
=
startTime
.
msecsTo
(
QTime
::
currentTime
())
/
1000.0
;
mesh
->
render
(
subdevisionShader
,
cam
->
getMatrix
()
*
rot
,
m_projection
);
if
(
!
animate
)
ftime
=
0
;
subdevisionShader
->
release
();
mesh
->
render
(
animationShader
,
cam
->
getMatrix
()
*
rot
,
m_projection
,(
float
)
ftime
,
Animation
);
animationShader
->
release
();
update
();
update
();
}
}
...
@@ -220,7 +186,5 @@ void MainWidget::resizeGL(int width, int height){
...
@@ -220,7 +186,5 @@ void MainWidget::resizeGL(int width, int height){
m_projection
=
QMatrix4x4
();
m_projection
=
QMatrix4x4
();
m_projection
.
perspective
(
45.0
f
,
1.0
*
width
/
height
,
0.01
f
,
1000.0
f
);
m_projection
.
perspective
(
45.0
f
,
1.0
*
width
/
height
,
0.01
f
,
1000.0
f
);
}
}
QTProject/mainwidget.h
View file @
9e817f2e
...
@@ -24,10 +24,8 @@ public:
...
@@ -24,10 +24,8 @@ public:
public
slots
:
public
slots
:
void
loadNewMesh
();
void
loadNewMesh
();
void
setInterpolation
(
bool
linear
);
void
setRotation
(
bool
started
);
void
setRotation
(
bool
started
);
void
setAnimating
(
bool
started
);
void
nextAnimation
();
protected
:
protected
:
...
@@ -46,7 +44,7 @@ private:
...
@@ -46,7 +44,7 @@ private:
Camera
*
cam
;
Camera
*
cam
;
QOpenGLShaderProgram
*
animat
ionShader
;
QOpenGLShaderProgram
*
subdevis
ionShader
;
QMatrix4x4
m_projection
;
QMatrix4x4
m_projection
;
QTime
startTime
;
QTime
startTime
;
QTime
rotTime
;
QTime
rotTime
;
...
@@ -56,16 +54,11 @@ private:
...
@@ -56,16 +54,11 @@ private:
QVector3D
*
lastSpeherePos
;
QVector3D
*
lastSpeherePos
;
QPointF
*
lastScreenPos
;
QPointF
*
lastScreenPos
;
boolean
linear
;
boolean
rotation
;
boolean
rotation
;
boolean
animate
;
int
Animation
;
Mesh
*
mesh
;
Mesh
*
mesh
;
QOpenGLShaderProgram
*
initShader
(
QString
fragSource
,
QString
vertSource
);
QOpenGLShaderProgram
*
initShader
();
};
};
#endif // MAINWIDGET_H
#endif // MAINWIDGET_H
QTProject/mainwindow.cpp
View file @
9e817f2e
...
@@ -16,28 +16,12 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -16,28 +16,12 @@ MainWindow::MainWindow(QWidget *parent) :
connect
(
loadMesh
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
loadNewMesh
()));
connect
(
loadMesh
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
loadNewMesh
()));
toolBar
->
addAction
(
loadMesh
);
toolBar
->
addAction
(
loadMesh
);
switchInterpolation
=
new
QAction
(
"Lin Interpol"
,
this
);
switchInterpolation
->
setCheckable
(
true
);
switchInterpolation
->
setChecked
(
false
);
connect
(
switchInterpolation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setInterpolation
(
bool
)));
toolBar
->
addAction
(
switchInterpolation
);
switchRotation
=
new
QAction
(
"Rotation"
,
this
);
switchRotation
=
new
QAction
(
"Rotation"
,
this
);
switchRotation
->
setCheckable
(
true
);
switchRotation
->
setCheckable
(
true
);
switchRotation
->
setChecked
(
true
);
switchRotation
->
setChecked
(
true
);
connect
(
switchRotation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setRotation
(
bool
)));
connect
(
switchRotation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setRotation
(
bool
)));
toolBar
->
addAction
(
switchRotation
);
toolBar
->
addAction
(
switchRotation
);
stopAnimation
=
new
QAction
(
"Start/Stop"
,
this
);
stopAnimation
->
setCheckable
(
true
);
stopAnimation
->
setChecked
(
true
);
connect
(
stopAnimation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setAnimating
(
bool
)));
toolBar
->
addAction
(
stopAnimation
);
nextAnimation
=
new
QAction
(
"Next"
,
this
);
nextAnimation
->
setCheckable
(
false
);
connect
(
nextAnimation
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
nextAnimation
()));
toolBar
->
addAction
(
nextAnimation
);
CamHome
=
new
QAction
(
"Cam"
,
this
);
CamHome
=
new
QAction
(
"Cam"
,
this
);
CamHome
->
setCheckable
(
false
);
CamHome
->
setCheckable
(
false
);
...
@@ -45,7 +29,6 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -45,7 +29,6 @@ MainWindow::MainWindow(QWidget *parent) :
toolBar
->
addAction
(
CamHome
);
toolBar
->
addAction
(
CamHome
);
this
->
setCentralWidget
(
m_centralWidget
);
this
->
setCentralWidget
(
m_centralWidget
);
// showMaximized();
// showMaximized();
...
...
QTProject/mainwindow.h
View file @
9e817f2e
...
@@ -23,10 +23,7 @@ private:
...
@@ -23,10 +23,7 @@ private:
QToolBar
*
toolBar
;
QToolBar
*
toolBar
;
QAction
*
loadMesh
;
QAction
*
loadMesh
;
QAction
*
switchInterpolation
;
QAction
*
switchRotation
;
QAction
*
switchRotation
;
QAction
*
stopAnimation
;
QAction
*
nextAnimation
;
QAction
*
CamHome
;
QAction
*
CamHome
;
...
...
QTProject/mesh.cpp
View file @
9e817f2e
This diff is collapsed.
Click to expand it.
QTProject/mesh.h
View file @
9e817f2e
...
@@ -11,8 +11,6 @@
...
@@ -11,8 +11,6 @@
#define positionIndex 0
#define positionIndex 0
#define normalIndex 1
#define normalIndex 1
#define uvIndex 2
#define uvIndex 2
#define boneIndex 3
#define boneweightIndex 4
#define EPSILON 0.00001
#define EPSILON 0.00001
...
@@ -21,23 +19,15 @@ struct Vertex
...
@@ -21,23 +19,15 @@ struct Vertex
QVector3D
pos
;
QVector3D
pos
;
QVector3D
normal
;
QVector3D
normal
;
QVector2D
tex
;
QVector2D
tex
;
uint
IDs
[
4
];
float
weights
[
4
];
Vertex
(){}
Vertex
(){}
Vertex
(
const
QVector3D
&
pos
,
const
QVector3D
&
normal
,
const
QVector2D
&
tex
)
Vertex
(
const
QVector3D
&
pos
,
const
QVector3D
&
normal
,
const
QVector2D
&
tex
)
{
{
for
(
int
i
=
0
;
i
<
4
;
i
++
){
IDs
[
i
]
=
0
;
weights
[
i
]
=
0
;
}
this
->
pos
=
pos
;
this
->
pos
=
pos
;
this
->
tex
=
tex
;
this
->
tex
=
tex
;
this
->
normal
=
normal
;
this
->
normal
=
normal
;
}
}
void
AddBoneData
(
uint
BoneID
,
float
Weight
);
};
};
class
Mesh
class
Mesh
...
@@ -46,15 +36,11 @@ public:
...
@@ -46,15 +36,11 @@ public:
Mesh
(
QOpenGLFunctions_4_3_Core
*
f
,
QString
filename
);
Mesh
(
QOpenGLFunctions_4_3_Core
*
f
,
QString
filename
);
~
Mesh
();
~
Mesh
();
void
render
(
QOpenGLShaderProgram
*
shader
,
QMatrix4x4
V
,
QMatrix4x4
P
);
void
render
(
QOpenGLShaderProgram
*
shader
,
QMatrix4x4
V
,
QMatrix4x4
P
,
float
TimeInSeconds
,
int
animation
);
void
setAnimation
(
bool
linear
){
this
->
linear
=
linear
;}
const
aiScene
*
scene
;
const
aiScene
*
scene
;
private
:
private
:
struct
MeshEntry
{
struct
MeshEntry
{
MeshEntry
();
MeshEntry
();
~
MeshEntry
();
~
MeshEntry
();
...
@@ -85,24 +71,6 @@ private:
...
@@ -85,24 +71,6 @@ private:
float
Shininess
;
float
Shininess
;
};
};
struct
LightInfo
{
QVector4D
Position
;
QVector3D
Intensity
;
};
struct
BoneInfo
{
QMatrix4x4
BoneOffset
;
QMatrix4x4
FinalTransformation
;
BoneInfo
()
{
BoneOffset
.
setToIdentity
();
FinalTransformation
.
setToIdentity
();
}
};
struct
Node
struct
Node
{
{
Node
();
Node
();
...
@@ -117,45 +85,21 @@ private:
...
@@ -117,45 +85,21 @@ private:
QMatrix4x4
globalInverseTransform
;
QMatrix4x4
globalInverseTransform
;
QMatrix4x4
screenTransform
;
QMatrix4x4
screenTransform
;
QVector
<
MeshEntry
>
entries
;
QVector
<
MeshEntry
>
entries
;
QVector
<
MaterialInfo
>
materials
;
QVector
<
MaterialInfo
>
materials
;
QVector
<
BoneInfo
>
bones
;
QMap
<
QString
,
int
>
boneMap
;
int
numberOfBones
;
Node
rootNode
;
Node
rootNode
;
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLFunctions_4_3_Core
*
f
;
bool
loaded
;
bool
loaded
;
bool
linear
;
void
initMeshEntry
(
int
i
,
aiMesh
*
entry
);
void
initMeshEntry
(
int
i
,
aiMesh
*
entry
);
void
initMaterial
(
QString
dir
,
unsigned
int
i
,
const
aiMaterial
*
material
);
void
initMaterial
(
QString
dir
,
unsigned
int
i
,
const
aiMaterial
*
material
);
void
initNode
(
const
aiScene
*
scene
,
aiNode
*
node
,
Node
&
newNode
,
QString
debugoffset
);
void
initNode
(
const
aiScene
*
scene
,
aiNode
*
node
,
Node
&
newNode
,
QString
debugoffset
);
void
updateBoneTransform
(
float
TimeInSeconds
,
int
animation
);
void
updateBoneHeirachy
(
float
AnimTime
,
const
aiAnimation
*
animation
,
Node
node
,
QMatrix4x4
parentTransform
);
const
aiNodeAnim
*
findAnimOfNode
(
const
aiAnimation
*
animation
,
QString
NodeName
);
QVector3D
calcInterpolatedScaling
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QQuaternion
calcInterpolatedRotation
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QVector3D
calcInterpolatedTranslation
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QVector3D
calcInterpolatedVectorKey
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
,
const
aiVectorKey
*
keys
,
const
int
numberOfKeys
);
void
renderNode
(
QOpenGLShaderProgram
*
shader
,
Node
&
node
,
QMatrix4x4
V
,
QMatrix4x4
P
,
QMatrix4x4
M
);
void
renderNode
(
QOpenGLShaderProgram
*
shader
,
Node
&
node
,
QMatrix4x4
V
,
QMatrix4x4
P
,
QMatrix4x4
M
);
void
renderMesh
(
QOpenGLShaderProgram
*
shader
,
int
index
);
void
renderMesh
(
QOpenGLShaderProgram
*
shader
,
int
index
);
QVector3D
convert
(
aiVector3D
in
){
return
QVector3D
(
in
.
x
,
in
.
y
,
in
.
z
);}
QQuaternion
convert
(
aiQuaternion
quat
){
return
QQuaternion
(
quat
.
w
,
quat
.
x
,
quat
.
y
,
quat
.
z
);}
QVector3D
linInterpolate
(
QVector3D
start
,
QVector3D
end
,
float
Factor
){
return
(
1
.
0
-
Factor
)
*
start
+
Factor
*
end
;}
QVector3D
Catmul
(
QVector3D
before
,
QVector3D
start
,
QVector3D
end
,
QVector3D
after
,
float
Factor
);
double
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
double
t_1
);
void
findObjectDimension
(
Node
node
,
QMatrix4x4
transform
,
QVector3D
&
min
,
QVector3D
&
max
);
void
findObjectDimension
(
Node
node
,
QMatrix4x4
transform
,
QVector3D
&
min
,
QVector3D
&
max
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment