Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bbguimaraes
college
Commits
963e6b2a
Commit
963e6b2a
authored
Jul 17, 2016
by
bbguimaraes
Browse files
sms: simple wind simulation
parent
8e7a235c
Changes
3
Hide whitespace changes
Inline
Side-by-side
sms/sms/include/simulation.h
View file @
963e6b2a
...
...
@@ -14,6 +14,7 @@ class Simulation {
bool
m_texturable
;
unsigned
int
m_texture_width
;
unsigned
int
m_texture_height
;
bool
m_wind
;
public:
Simulation
()
:
...
...
@@ -22,7 +23,8 @@ class Simulation {
m_textured
(
false
),
m_texturable
(
false
),
m_texture_width
(
0
),
m_texture_height
(
0
)
{}
m_texture_height
(
0
),
m_wind
(
false
)
{}
const
std
::
vector
<
SpringMassSystem
*>
*
systems
()
const
{
return
&
this
->
m_systems
;}
...
...
@@ -33,6 +35,7 @@ class Simulation {
bool
texturable
()
const
{
return
this
->
m_texturable
;}
unsigned
int
texture_width
()
const
{
return
this
->
m_texture_width
;}
unsigned
int
texture_height
()
const
{
return
this
->
m_texture_height
;}
bool
wind
()
const
{
return
this
->
m_wind
;}
void
set_systems
(
const
std
::
vector
<
SpringMassSystem
*>
&
v
)
{
this
->
m_systems
=
v
;}
...
...
@@ -43,6 +46,7 @@ class Simulation {
void
set_texturable
(
bool
t
)
{
this
->
m_texturable
=
t
;}
void
set_texture_width
(
unsigned
int
w
)
{
this
->
m_texture_width
=
w
;}
void
set_texture_height
(
unsigned
int
h
)
{
this
->
m_texture_height
=
h
;}
void
set_wind
(
bool
w
)
{
this
->
m_wind
=
w
;}
void
update
();
};
...
...
sms/sms/src/display.cpp
View file @
963e6b2a
...
...
@@ -165,6 +165,10 @@ void Display::keyPressEvent(QKeyEvent * event) {
if
(
x
->
texturable
())
x
->
set_textured
(
!
x
->
textured
());
break
;
case
'W'
:
for
(
auto
x
:
this
->
m_simulations
)
x
->
set_wind
(
!
x
->
wind
());
break
;
case
Qt
::
Key_Control
:
this
->
m_ctrl_key_down
=
true
;
break
;
...
...
sms/sms/src/main.cpp
View file @
963e6b2a
...
...
@@ -51,8 +51,10 @@ int main(int argc, char ** argv) {
void
update_simulations
(
std
::
vector
<
Simulation
>
*
simulations
,
Display
*
display
)
{
const
auto
F
=
Vector
();
const
auto
W
=
Vector
(
0.0
f
,
0.0
f
,
-
0.2
f
)
*
(
static_cast
<
float
>
(
std
::
rand
())
/
RAND_MAX
);
for
(
auto
&
simulation
:
*
simulations
)
{
const
auto
F
=
simulation
.
wind
()
?
W
:
Vector
();
for
(
auto
system
:
*
simulation
.
systems
())
for
(
auto
&
mass
:
*
system
->
masses
())
{
auto
f
=
F
;
...
...
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