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
8e0716df
Commit
8e0716df
authored
Feb 07, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more AABB
parent
491d6a74
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
13 deletions
+11
-13
.gitignore
.gitignore
+2
-0
mainwidget.cpp
A5/Animation/mainwidget.cpp
+2
-2
mesh.cpp
A5/Animation/mesh.cpp
+7
-11
No files found.
.gitignore
View file @
8e0716df
...
...
@@ -3,3 +3,5 @@
*.zip
/assimp-3.1.1-win-binaries
*build-*
/A5/ogldev-source
/A5/DisplayModel
A5/Animation/mainwidget.cpp
View file @
8e0716df
...
...
@@ -120,8 +120,8 @@ void MainWidget::loadNewMesh(){
if
(
fn
.
isEmpty
())
return
;
qDebug
()
<<
"Opening File:"
<<
fn
;
mesh
=
new
Mesh
(
this
,
fn
)
;
Mesh
*
temp
=
new
Mesh
(
this
,
fn
);
mesh
=
temp
;
mesh
->
setAnimation
(
linear
);
}
...
...
A5/Animation/mesh.cpp
View file @
8e0716df
...
...
@@ -21,8 +21,9 @@ Mesh::MeshEntry::MeshEntry()
numIndex
=
0
;
VB
=
0xFFFFFFFF
;
IB
=
0xFFFFFFFF
;
min
=
QVector3D
();
max
=
QVector3D
();
double
amax
=
std
::
numeric_limits
<
float
>::
max
();
min
=
QVector3D
(
amax
,
amax
,
amax
);
max
=
QVector3D
(
-
amax
,
-
amax
,
-
amax
);
}
void
Mesh
::
MeshEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
...
...
@@ -38,10 +39,6 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
numIndex
,
&
Indices
[
0
],
GL_STATIC_DRAW
);
double
amax
=
std
::
numeric_limits
<
float
>::
max
();
min
=
QVector3D
(
amax
,
amax
,
amax
);
max
=
QVector3D
(
-
amax
,
-
amax
,
-
amax
);
//calc AABB
for
(
int
i
=
0
;
i
<
Vertices
.
size
();
++
i
)
{
Vertex
v
=
Vertices
[
i
];
...
...
@@ -81,7 +78,6 @@ Mesh::Node::Node()
Mesh
::
Mesh
(
QOpenGLFunctions_4_3_Core
*
f
,
QString
fileName
)
{
screenTransform
=
QMatrix4x4
();
loaded
=
false
;
linear
=
false
;
this
->
f
=
f
;
...
...
@@ -160,18 +156,18 @@ Mesh::Mesh(QOpenGLFunctions_4_3_Core *f,QString fileName)
QVector3D
min
=
QVector3D
(
amax
,
amax
,
amax
);
QVector3D
max
=
QVector3D
(
-
amax
,
-
amax
,
-
amax
);
//
findObjectDimension(rootNode,QMatrix4x4(),min,max);
findObjectDimension
(
rootNode
,
QMatrix4x4
(),
min
,
max
);
qDebug
()
<<
"AABB"
<<
min
<<
max
;
float
dist
=
qMax
(
max
.
x
()
-
min
.
x
(),
qMax
(
max
.
y
()
-
min
.
y
(),
max
.
z
()
-
min
.
z
()));
float
sc
=
75
.0
/
dist
;
float
sc
=
100
.0
/
dist
;
QVector3D
center
=
(
max
-
min
)
/
2
;
QVector3D
trans
=
-
(
max
-
center
);
// Apply the scale and translation to a matrix
screenTransform
.
setToIdentity
();
//
screenTransform.scale(sc);
//
screenTransform.translate(trans);
screenTransform
.
scale
(
sc
);
screenTransform
.
translate
(
trans
);
loaded
=
true
;
}
...
...
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