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
6cba67dc
Commit
6cba67dc
authored
Jan 31, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed splines
parent
87d9d8f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
21 deletions
+38
-21
mainwindow.cpp
A5/Animation/mainwindow.cpp
+1
-1
mesh.cpp
A5/Animation/mesh.cpp
+36
-19
mesh.h
A5/Animation/mesh.h
+1
-1
No files found.
A5/Animation/mainwindow.cpp
View file @
6cba67dc
...
@@ -13,7 +13,7 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -13,7 +13,7 @@ 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
(
"
Interpolation
"
,
this
);
switchInterpolation
=
new
QAction
(
"
Lin Interpol
"
,
this
);
switchInterpolation
->
setCheckable
(
true
);
switchInterpolation
->
setCheckable
(
true
);
switchInterpolation
->
setChecked
(
false
);
switchInterpolation
->
setChecked
(
false
);
connect
(
switchInterpolation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setInterpolation
(
bool
)));
connect
(
switchInterpolation
,
SIGNAL
(
triggered
(
bool
)),
m_centralWidget
,
SLOT
(
setInterpolation
(
bool
)));
...
...
A5/Animation/mesh.cpp
View file @
6cba67dc
...
@@ -523,10 +523,7 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
...
@@ -523,10 +523,7 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
QVector3D
start
=
convert
(
keys
[
index
].
mValue
);
QVector3D
start
=
convert
(
keys
[
index
].
mValue
);
QVector3D
end
=
convert
(
keys
[
index
+
1
].
mValue
);
QVector3D
end
=
convert
(
keys
[
index
+
1
].
mValue
);
if
(
linear
)
if
(
start
.
distanceToPoint
(
end
)
<
0.00001
){
// same keyframe
return
linInterpolate
(
start
,
end
,
Factor
);
if
(
start
.
distanceToPoint
(
end
)
==
0
){
// same keyframse not interpolation
return
start
;
return
start
;
}
}
...
@@ -540,14 +537,29 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
...
@@ -540,14 +537,29 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
case
aiAnimBehaviour_LINEAR
:
// linear interpolate
case
aiAnimBehaviour_LINEAR
:
// linear interpolate
return
linInterpolate
(
start
,
end
,
Factor
);
return
linInterpolate
(
start
,
end
,
Factor
);
case
aiAnimBehaviour_DEFAULT
:
// take default node transformation
case
aiAnimBehaviour_DEFAULT
:
// take default node transformation
//TODO
default
:
default
:
return
linInterpolate
(
start
,
end
,
Factor
);
//TODO
return
linInterpolate
(
start
,
end
,
Factor
);
}
}
}
else
if
((
index
+
2
)
==
numberOfKeys
){
}
else
if
((
index
+
2
)
==
numberOfKeys
){
//end
switch
(
nodeAnimation
->
mPostState
)
{
return
linInterpolate
(
start
,
end
,
Factor
);
case
aiAnimBehaviour_CONSTANT
:
// nearest Key
return
Factor
<
0.5
f
?
start
:
end
;
break
;
case
aiAnimBehaviour_REPEAT
:
// use start or end
//TODO
case
aiAnimBehaviour_LINEAR
:
// linear interpolate
return
linInterpolate
(
start
,
end
,
Factor
);
case
aiAnimBehaviour_DEFAULT
:
// take default node transformation
//TODO
default
:
return
linInterpolate
(
start
,
end
,
Factor
);
}
}
else
{
}
else
{
if
(
linear
)
return
linInterpolate
(
start
,
end
,
Factor
);
QVector3D
before
=
convert
(
keys
[
index
-
1
].
mValue
);
QVector3D
before
=
convert
(
keys
[
index
-
1
].
mValue
);
QVector3D
after
=
convert
(
keys
[
index
+
2
].
mValue
);
QVector3D
after
=
convert
(
keys
[
index
+
2
].
mValue
);
...
@@ -564,18 +576,19 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
...
@@ -564,18 +576,19 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
}
}
QVector3D
Mesh
::
Catmul
(
QVector3D
before
,
QVector3D
start
,
QVector3D
end
,
QVector3D
after
,
float
Factor
){
QVector3D
Mesh
::
Catmul
(
QVector3D
P0
,
QVector3D
P1
,
QVector3D
P2
,
QVector3D
P3
,
float
Factor
){
float
t0
=
0
;
double
t0
=
0
;
float
t1
=
timeCatmul
(
before
,
start
,
t0
);
double
t1
=
timeCatmul
(
P0
,
P1
,
t0
);
float
t2
=
timeCatmul
(
start
,
end
,
t1
);
double
t2
=
timeCatmul
(
P1
,
P2
,
t1
);
float
t3
=
timeCatmul
(
end
,
after
,
t2
);
double
t3
=
timeCatmul
(
P2
,
P3
,
t2
);
float
t
=
Factor
;
//(1-Factor)*t1+Factor*t2;
double
t
=
Factor
;
t
=
(
1
-
Factor
)
*
t1
+
Factor
*
t2
;
//qDebug()<<before<<start<<end<<after;
//qDebug()<<before<<start<<end<<after;
//qDebug()<<t0<<t1<<t2<<t3<<t;
//qDebug()<<t0<<t1<<t2<<t3<<t;
QVector3D
A1
=
(
t1
-
t
)
/
(
t1
-
t0
)
*
before
+
(
t
-
t0
)
/
(
t1
-
t0
)
*
start
;
QVector3D
A1
=
(
t1
-
t
)
/
(
t1
-
t0
)
*
P0
+
(
t
-
t0
)
/
(
t1
-
t0
)
*
P1
;
QVector3D
A2
=
(
t2
-
t
)
/
(
t2
-
t1
)
*
start
+
(
t
-
t1
)
/
(
t2
-
t1
)
*
end
;
QVector3D
A2
=
(
t2
-
t
)
/
(
t2
-
t1
)
*
P1
+
(
t
-
t1
)
/
(
t2
-
t1
)
*
P2
;
QVector3D
A3
=
(
t3
-
t
)
/
(
t3
-
t2
)
*
end
+
(
t
-
t2
)
/
(
t3
-
t2
)
*
after
;
QVector3D
A3
=
(
t3
-
t
)
/
(
t3
-
t2
)
*
P2
+
(
t
-
t2
)
/
(
t3
-
t2
)
*
P3
;
QVector3D
B1
=
(
t2
-
t
)
/
(
t2
-
t0
)
*
A1
+
(
t
-
t0
)
/
(
t2
-
t0
)
*
A2
;
QVector3D
B1
=
(
t2
-
t
)
/
(
t2
-
t0
)
*
A1
+
(
t
-
t0
)
/
(
t2
-
t0
)
*
A2
;
QVector3D
B2
=
(
t3
-
t
)
/
(
t3
-
t1
)
*
A2
+
(
t
-
t1
)
/
(
t3
-
t1
)
*
A3
;
QVector3D
B2
=
(
t3
-
t
)
/
(
t3
-
t1
)
*
A2
+
(
t
-
t1
)
/
(
t3
-
t1
)
*
A3
;
...
@@ -585,9 +598,13 @@ QVector3D Mesh::Catmul(QVector3D before, QVector3D start, QVector3D end, QVector
...
@@ -585,9 +598,13 @@ QVector3D Mesh::Catmul(QVector3D before, QVector3D start, QVector3D end, QVector
}
}
float
Mesh
::
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
float
t_1
){
double
Mesh
::
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
double
t_1
){
float
dist
=
p1
.
distanceToPoint
(
p2
);
double
dist
=
p1
.
distanceToPoint
(
p2
);
float
t
=
powf
(
dist
,
0.5
)
+
t_1
;
double
alpha
=
0.0
;
//uniform
alpha
=
0.5
;
//centripetal
//float alpha = 1.0; //chordal
double
t
=
qPow
(
dist
,
alpha
)
+
t_1
;
// qDebug()<<dist<<t;
// qDebug()<<dist<<t;
return
t
;
return
t
;
}
}
...
...
A5/Animation/mesh.h
View file @
6cba67dc
...
@@ -149,7 +149,7 @@ private:
...
@@ -149,7 +149,7 @@ private:
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
);
QVector3D
Catmul
(
QVector3D
before
,
QVector3D
start
,
QVector3D
end
,
QVector3D
after
,
float
Factor
);
float
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
float
t_1
);
double
timeCatmul
(
QVector3D
p1
,
QVector3D
p2
,
double
t_1
);
};
};
...
...
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