Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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
Vulkan2021
VkCV Framework
Commits
ccbe042e
Commit
ccbe042e
authored
3 years ago
by
Sebastian Gaida
Browse files
Options
Downloads
Patches
Plain Diff
[
#69
] merge fix from
#60
and test code
parent
ea6919fc
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!56
Resolve "Partikelsystem"
Pipeline
#25912
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/CMakeLists.txt
+0
-1
0 additions, 1 deletion
projects/CMakeLists.txt
projects/particle_simulation/src/main.cpp
+27
-19
27 additions, 19 deletions
projects/particle_simulation/src/main.cpp
with
27 additions
and
20 deletions
projects/CMakeLists.txt
+
0
−
1
View file @
ccbe042e
...
@@ -5,4 +5,3 @@ add_subdirectory(first_mesh)
...
@@ -5,4 +5,3 @@ add_subdirectory(first_mesh)
add_subdirectory
(
particle_simulation
)
add_subdirectory
(
particle_simulation
)
add_subdirectory
(
first_scene
)
add_subdirectory
(
first_scene
)
add_subdirectory
(
voxelization
)
add_subdirectory
(
voxelization
)
add_subdirectory
(
voxelization
)
This diff is collapsed.
Click to expand it.
projects/particle_simulation/src/main.cpp
+
27
−
19
View file @
ccbe042e
...
@@ -19,10 +19,7 @@ int main(int argc, const char **argv) {
...
@@ -19,10 +19,7 @@ int main(int argc, const char **argv) {
true
true
);
);
vkcv
::
CameraManager
cameraManager
(
window
,
windowWidth
,
windowHeight
);
vkcv
::
camera
::
CameraManager
cameraManager
(
window
);
cameraManager
.
getCamera
().
setNearFar
(
0.000000001
f
,
10.
f
);
window
.
initEvents
();
vkcv
::
Core
core
=
vkcv
::
Core
::
create
(
vkcv
::
Core
core
=
vkcv
::
Core
::
create
(
window
,
window
,
...
@@ -43,7 +40,7 @@ int main(int argc, const char **argv) {
...
@@ -43,7 +40,7 @@ int main(int argc, const char **argv) {
const
vkcv
::
AttachmentDescription
present_color_attachment
(
const
vkcv
::
AttachmentDescription
present_color_attachment
(
vkcv
::
AttachmentOperation
::
STORE
,
vkcv
::
AttachmentOperation
::
STORE
,
vkcv
::
AttachmentOperation
::
CLEAR
,
vkcv
::
AttachmentOperation
::
CLEAR
,
core
.
getSwapchain
Ima
geFormat
());
core
.
getSwapchain
().
ge
t
Format
());
vkcv
::
PassConfig
particlePassDefinition
({
present_color_attachment
});
vkcv
::
PassConfig
particlePassDefinition
({
present_color_attachment
});
...
@@ -94,14 +91,14 @@ int main(int argc, const char **argv) {
...
@@ -94,14 +91,14 @@ int main(int argc, const char **argv) {
const
vkcv
::
VertexLayout
particleLayout
(
bindings
);
const
vkcv
::
VertexLayout
particleLayout
(
bindings
);
const
vkcv
::
PipelineConfig
particlePipelineDefinition
(
const
vkcv
::
PipelineConfig
particlePipelineDefinition
{
particleShaderProgram
,
particleShaderProgram
,
UINT32_MAX
,
UINT32_MAX
,
UINT32_MAX
,
UINT32_MAX
,
particlePass
,
particlePass
,
{
particleLayout
},
{
particleLayout
},
{
core
.
getDescriptorSet
(
descriptorSet
).
layout
},
{
core
.
getDescriptorSet
(
descriptorSet
).
layout
},
true
)
;
true
}
;
const
std
::
vector
<
glm
::
vec3
>
vertices
=
{
glm
::
vec3
(
-
0.005
,
0.005
,
0
),
const
std
::
vector
<
glm
::
vec3
>
vertices
=
{
glm
::
vec3
(
-
0.005
,
0.005
,
0
),
glm
::
vec3
(
0.005
,
0.005
,
0
),
glm
::
vec3
(
0.005
,
0.005
,
0
),
...
@@ -170,18 +167,25 @@ int main(int argc, const char **argv) {
...
@@ -170,18 +167,25 @@ int main(int argc, const char **argv) {
// borders are assumed to be 0.5
// borders are assumed to be 0.5
//pos = glm::vec2((pos.x -0.5f * static_cast<float>(window.getWidth()))/static_cast<float>(window.getWidth()), (pos.y -0.5f * static_cast<float>(window.getHeight()))/static_cast<float>(window.getHeight()));
//pos = glm::vec2((pos.x -0.5f * static_cast<float>(window.getWidth()))/static_cast<float>(window.getWidth()), (pos.y -0.5f * static_cast<float>(window.getHeight()))/static_cast<float>(window.getHeight()));
//borders are assumed to be 1
//borders are assumed to be 1
pos
.
x
=
(
2
*
pos
.
x
-
static_cast
<
float
>
(
window
.
getWidth
()))
/
static_cast
<
float
>
(
window
.
getWidth
());
pos
.
x
=
(
-
2
*
pos
.
x
+
static_cast
<
float
>
(
window
.
getWidth
()))
/
static_cast
<
float
>
(
window
.
getWidth
());
pos
.
y
=
(
2
*
pos
.
y
-
static_cast
<
float
>
(
window
.
getHeight
()))
/
static_cast
<
float
>
(
window
.
getHeight
());
pos
.
y
=
(
-
2
*
pos
.
y
+
static_cast
<
float
>
(
window
.
getHeight
()))
/
static_cast
<
float
>
(
window
.
getHeight
());
glm
::
vec4
camera_pos
=
glm
::
column
(
cameraManager
.
getCamera
().
getView
(),
3
);
glm
::
vec4
row1
=
glm
::
row
(
cameraManager
.
getCamera
(
0
).
getView
(),
0
);
glm
::
vec4
row2
=
glm
::
row
(
cameraManager
.
getCamera
(
0
).
getView
(),
1
);
glm
::
vec4
row3
=
glm
::
row
(
cameraManager
.
getCamera
(
0
).
getView
(),
2
);
glm
::
vec4
camera_pos
=
glm
::
column
(
cameraManager
.
getCamera
(
0
).
getView
(),
3
);
std
::
cout
<<
"row1: "
<<
row1
.
x
<<
", "
<<
row1
.
y
<<
", "
<<
row1
.
z
<<
std
::
endl
;
std
::
cout
<<
"row2: "
<<
row2
.
x
<<
", "
<<
row2
.
y
<<
", "
<<
row2
.
z
<<
std
::
endl
;
std
::
cout
<<
"row3: "
<<
row3
.
x
<<
", "
<<
row3
.
y
<<
", "
<<
row3
.
z
<<
std
::
endl
;
std
::
cout
<<
"camerapos: "
<<
camera_pos
.
x
<<
", "
<<
camera_pos
.
y
<<
", "
<<
camera_pos
.
z
<<
std
::
endl
;
std
::
cout
<<
"camerapos: "
<<
camera_pos
.
x
<<
", "
<<
camera_pos
.
y
<<
", "
<<
camera_pos
.
z
<<
std
::
endl
;
std
::
cout
<<
"camerapos: "
<<
camera_pos
.
x
<<
", "
<<
camera_pos
.
y
<<
", "
<<
camera_pos
.
z
<<
std
::
endl
;
//glm::vec4 view_axis = glm::row(cameraManager.getCamera().getView(), 2);
//glm::vec4 view_axis = glm::row(cameraManager.getCamera().getView(), 2);
// std::cout << "view_axis: " << view_axis.x << ", " << view_axis.y << ", " << view_axis.z << std::endl;
// std::cout << "view_axis: " << view_axis.x << ", " << view_axis.y << ", " << view_axis.z << std::endl;
//std::cout << "Front: " << cameraManager.getCamera().getFront().x << ", " << cameraManager.getCamera().getFront().z << ", " << cameraManager.getCamera().getFront().z << std::endl;
//std::cout << "Front: " << cameraManager.getCamera().getFront().x << ", " << cameraManager.getCamera().getFront().z << ", " << cameraManager.getCamera().getFront().z << std::endl;
glm
::
mat4
viewmat
=
cameraManager
.
getCamera
().
getView
();
glm
::
mat4
viewmat
=
cameraManager
.
getCamera
(
0
).
getView
();
spawnPosition
=
glm
::
vec3
(
pos
.
x
,
pos
.
y
,
0.
f
);
spawnPosition
=
glm
::
vec3
(
pos
.
x
,
pos
.
y
,
0.
f
);
tempPosition
=
glm
::
inverse
(
viewmat
)
*
glm
::
vec4
(
spawnPosition
,
1.0
f
);
tempPosition
=
viewmat
*
glm
::
vec4
(
spawnPosition
,
1.0
f
);
spawnPosition
=
glm
::
vec3
(
tempPosition
.
x
,
tempPosition
.
y
,
tempPosition
.
z
);
spawnPosition
=
glm
::
vec3
(
tempPosition
.
x
,
tempPosition
.
y
,
tempPosition
.
z
);
particleSystem
.
setRespawnPos
(
glm
::
vec3
(
-
spawnPosition
.
x
,
-
spawnPosition
.
y
,
-
spawnPosition
.
z
));
particleSystem
.
setRespawnPos
(
glm
::
vec3
(
-
spawnPosition
.
x
,
-
spawnPosition
.
y
,
spawnPosition
.
z
));
std
::
cout
<<
"respawn pos: "
<<
spawnPosition
.
x
<<
", "
<<
spawnPosition
.
y
<<
", "
<<
spawnPosition
.
z
<<
std
::
endl
;
std
::
cout
<<
"respawn pos: "
<<
spawnPosition
.
x
<<
", "
<<
spawnPosition
.
y
<<
", "
<<
spawnPosition
.
z
<<
std
::
endl
;
});
});
...
@@ -195,8 +199,12 @@ int main(int argc, const char **argv) {
...
@@ -195,8 +199,12 @@ int main(int argc, const char **argv) {
auto
start
=
std
::
chrono
::
system_clock
::
now
();
auto
start
=
std
::
chrono
::
system_clock
::
now
();
glm
::
vec4
colorData
=
glm
::
vec4
(
1.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
glm
::
vec4
colorData
=
glm
::
vec4
(
1.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
cameraManager
.
getCamera
().
setPosition
(
glm
::
vec3
(
0.
f
,
0.
f
,
0.
f
));
uint32_t
camIndex0
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
PILOT
);
std
::
cout
<<
"FRONT: "
<<
cameraManager
.
getCamera
().
getFront
().
x
<<
", "
<<
cameraManager
.
getCamera
().
getFront
().
y
<<
", "
<<
cameraManager
.
getCamera
().
getFront
().
z
<<
std
::
endl
;
uint32_t
camIndex1
=
cameraManager
.
addCamera
(
vkcv
::
camera
::
ControllerType
::
TRACKBALL
);
cameraManager
.
getCamera
(
camIndex0
).
setPosition
(
glm
::
vec3
(
0
,
0
,
-
2
));
cameraManager
.
getCamera
(
camIndex1
).
setPosition
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
0.0
f
));
cameraManager
.
getCamera
(
camIndex1
).
setCenter
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
-
1.0
f
));
while
(
window
.
isWindowOpen
())
{
while
(
window
.
isWindowOpen
())
{
window
.
pollEvents
();
window
.
pollEvents
();
...
@@ -211,20 +219,20 @@ int main(int argc, const char **argv) {
...
@@ -211,20 +219,20 @@ int main(int argc, const char **argv) {
position
.
fill
(
&
pos
);
position
.
fill
(
&
pos
);
auto
end
=
std
::
chrono
::
system_clock
::
now
();
auto
end
=
std
::
chrono
::
system_clock
::
now
();
float
deltatime
=
std
::
chrono
::
duration
<
float
>
(
end
-
start
)
.
count
()
;
auto
deltatime
=
std
::
chrono
::
duration
_cast
<
std
::
chrono
::
microseconds
>
(
end
-
start
);
start
=
end
;
start
=
end
;
particleSystem
.
updateParticles
(
deltatime
);
particleSystem
.
updateParticles
(
0.000001
*
static_cast
<
float
>
(
deltatime
.
count
())
);
modelMatrices
.
clear
();
modelMatrices
.
clear
();
for
(
Particle
particle
:
particleSystem
.
getParticles
())
{
for
(
Particle
particle
:
particleSystem
.
getParticles
())
{
modelMatrices
.
push_back
(
glm
::
translate
(
glm
::
mat4
(
1.
f
),
particle
.
getPosition
()));
modelMatrices
.
push_back
(
glm
::
translate
(
glm
::
mat4
(
1.
f
),
particle
.
getPosition
()));
}
}
cameraManager
.
getCamera
().
updateView
(
deltatime
);
cameraManager
.
update
(
0.000001
*
static_cast
<
double
>
(
deltatime
.
count
())
);
std
::
vector
<
glm
::
mat4
>
mvp
;
std
::
vector
<
glm
::
mat4
>
mvp
;
mvp
.
clear
();
mvp
.
clear
();
for
(
const
auto
&
m
:
modelMatrices
)
{
for
(
const
auto
&
m
:
modelMatrices
)
{
mvp
.
push_back
(
m
*
cameraManager
.
get
Camera
().
getProjection
()
*
cameraManager
.
get
Camera
().
get
View
());
mvp
.
push_back
(
m
*
cameraManager
.
get
Active
Camera
().
get
MVP
());
}
}
vkcv
::
PushConstantData
pushConstantData
((
void
*
)
mvp
.
data
(),
sizeof
(
glm
::
mat4
));
vkcv
::
PushConstantData
pushConstantData
((
void
*
)
mvp
.
data
(),
sizeof
(
glm
::
mat4
));
...
...
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