Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
GraPa
Commits
63e1d174
Commit
63e1d174
authored
Jan 31, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zwischenstand
parent
10e12c16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
11 deletions
+22
-11
animate.vert
A5/Animation/animate.vert
+11
-5
mainwidget.cpp
A5/Animation/mainwidget.cpp
+6
-5
mesh.cpp
A5/Animation/mesh.cpp
+0
-0
mesh.h
A5/Animation/mesh.h
+4
-1
texture.cpp
A5/Animation/texture.cpp
+1
-0
No files found.
A5/Animation/animate.vert
View file @
63e1d174
...
@@ -24,18 +24,24 @@ void main(void)
...
@@ -24,18 +24,24 @@ void main(void)
debugout
=
Weights
;
debugout
=
Weights
;
//debugout = vec4(1);
//debugout = vec4(1);
mat4x4
BoneTransform
=
Bones
[
BoneIDs
[
0
]]
*
Weights
[
0
];
mat4x4
BoneTransform
=
mat4x4
(
0
.
0
);
BoneTransform
+=
Bones
[
BoneIDs
[
1
]]
*
Weights
[
1
];
BoneTransform
+=
Bones
[
BoneIDs
[
2
]]
*
Weights
[
2
];
for
(
int
i
=
0
;
i
<
4
;
i
++
){
BoneTransform
+=
Bones
[
BoneIDs
[
3
]]
*
Weights
[
3
];
BoneTransform
+=
Bones
[
BoneIDs
[
i
]]
*
Weights
[
i
];
}
if
(
Weights
[
0
]
==
0
.
0
){
BoneTransform
=
mat4x4
(
1
.
0
);
}
vec4
Pos
=
BoneTransform
*
vec4
(
Position
,
1
.
0
);
vec4
Pos
=
BoneTransform
*
vec4
(
Position
,
1
.
0
);
vec4
Nor
=
BoneTransform
*
vec4
(
Normal
,
0
.
0
);
//Pos = vec4(Position,1.0);
//Pos = vec4(Position,1.0);
vCamPosition
=
vec4
(
MV
*
Pos
).
xyz
;
vCamPosition
=
vec4
(
MV
*
Pos
).
xyz
;
vCamNormal
=
N
*
Normal
;
vCamNormal
=
N
*
(
Nor
.
xyz
)
;
vUV
=
UV
;
vUV
=
UV
;
...
...
A5/Animation/mainwidget.cpp
View file @
63e1d174
...
@@ -44,7 +44,7 @@ void MainWidget::initializeGL(){
...
@@ -44,7 +44,7 @@ void MainWidget::initializeGL(){
// Shader
// Shader
animationShader
=
initShader
(
QLatin1String
(
":/animate.frag"
),
QLatin1String
(
":/animate.vert"
));
animationShader
=
initShader
(
QLatin1String
(
":/animate.frag"
),
QLatin1String
(
":/animate.vert"
));
camDistance
=
3
0.0
;
camDistance
=
10
0.0
;
m_view
=
QMatrix4x4
();
m_view
=
QMatrix4x4
();
m_view
.
lookAt
(
QVector3D
(
0.0
,
camDistance
,
camDistance
),
QVector3D
(
0.0
,
0.0
,
0.0
),
QVector3D
(
0.0
,
1.0
,
0.0
));
m_view
.
lookAt
(
QVector3D
(
0.0
,
camDistance
,
camDistance
),
QVector3D
(
0.0
,
0.0
,
0.0
),
QVector3D
(
0.0
,
1.0
,
0.0
));
...
@@ -54,7 +54,7 @@ void MainWidget::initializeGL(){
...
@@ -54,7 +54,7 @@ void MainWidget::initializeGL(){
void
MainWidget
::
loadNewMesh
(){
void
MainWidget
::
loadNewMesh
(){
QString
fn
=
QFileDialog
::
getOpenFileName
(
NULL
,
tr
(
"Open Mesh..."
),
QString
fn
=
QFileDialog
::
getOpenFileName
(
NULL
,
tr
(
"Open Mesh..."
),
QString
(
"D:
\\
Projekte
\\
GraPa
\\
A5
\\
Models"
),
QString
(
"D:
\\
Projekte
\\
GraPa
\\
A5
\\
Models"
),
tr
(
"*.md5mesh *.3ds *.md2 *.obj"
));
tr
(
"*.md5mesh *.3ds *.md2 *.obj
*.dae *.dxf
"
));
if
(
fn
.
isEmpty
())
if
(
fn
.
isEmpty
())
return
;
return
;
...
@@ -98,15 +98,16 @@ void MainWidget::paintGL(){
...
@@ -98,15 +98,16 @@ void MainWidget::paintGL(){
QMatrix4x4
rot
;
QMatrix4x4
rot
;
int
time
=
QTime
::
currentTime
().
second
()
*
1000
+
QTime
::
currentTime
().
msec
();
int
time
=
QTime
::
currentTime
().
second
()
*
1000
+
QTime
::
currentTime
().
msec
();
rot
.
rotate
(
time
/
100.0
*
36
/
5
,
QVector3D
(
0
,
1
,
0
));
//
rot.rotate(time/100.0*36/5,QVector3D(0,1,0));
animationShader
->
bind
();
animationShader
->
bind
();
animationShader
->
setUniformValue
(
"colorTexture"
,
0
);
animationShader
->
setUniformValue
(
"colorTexture"
,
0
);
animationShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
animationShader
->
setUniformValue
(
"LightPos"
,
QVector3D
(
0
,
100
,
100
));
time
=
startTime
.
msecsTo
(
QTime
::
currentTime
())
/
1000.0
;
float
f
time
=
startTime
.
msecsTo
(
QTime
::
currentTime
())
/
1000.0
;
mesh
->
render
(
animationShader
,
m_view
*
rot
,
m_projection
,(
float
)
time
);
mesh
->
render
(
animationShader
,
m_view
*
rot
,
m_projection
,(
float
)
ftime
);
animationShader
->
release
();
animationShader
->
release
();
update
();
update
();
...
...
A5/Animation/mesh.cpp
View file @
63e1d174
This diff is collapsed.
Click to expand it.
A5/Animation/mesh.h
View file @
63e1d174
...
@@ -133,6 +133,7 @@ private:
...
@@ -133,6 +133,7 @@ private:
QVector3D
calcInterpolatedScaling
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QVector3D
calcInterpolatedScaling
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QQuaternion
calcInterpolatedRotation
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QQuaternion
calcInterpolatedRotation
(
float
AnimTime
,
const
aiNodeAnim
*
nodeAnimation
);
QVector3D
calcInterpolatedTranslation
(
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
);
...
@@ -140,8 +141,10 @@ private:
...
@@ -140,8 +141,10 @@ private:
QVector3D
convert
(
aiVector3D
in
){
return
QVector3D
(
in
.
x
,
in
.
y
,
in
.
z
);}
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
);}
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
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
);
float
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
float
t_1
);
};
};
...
...
A5/Animation/texture.cpp
View file @
63e1d174
...
@@ -17,6 +17,7 @@ void Texture::Load(GLenum textureTarget, QString fileName)
...
@@ -17,6 +17,7 @@ void Texture::Load(GLenum textureTarget, QString fileName)
qDebug
()
<<
"No Image to load"
;
qDebug
()
<<
"No Image to load"
;
return
;
return
;
}
}
qDebug
()
<<
"Loading Texture:"
<<
fileName
;
qDebug
()
<<
"Loading Texture:"
<<
fileName
;
QString
suffix
=
QFileInfo
(
fileName
).
completeSuffix
();
QString
suffix
=
QFileInfo
(
fileName
).
completeSuffix
();
...
...
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