Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94982670
particlesystem.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 11, 22:35
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Dec 13, 22:35 (2 d)
Engine
blob
Format
Raw Data
Handle
22885723
Attached To
rSYMKIT symkit
particlesystem.cpp
View Options
#include "particlesystem.h"
#include "particle.h"
ParticleSystem
::
ParticleSystem
(
const
SVector
<
3
>&
offset
,
const
QString
&
label
,
specs_t
flags
)
:
SKActor
(
label
,
flags
),
offset
(
offset
)
{
}
ParticleSystem
::
ParticleSystem
(
const
std
::
initializer_list
<
Particle
*>&
init
)
:
SKActor
(
""
,
S_EVOLVE
|
S_RENDER
|
S_POSITION
),
particles
(
init
)
{
}
void
ParticleSystem
::
evolve
(
float
dt
)
{
for
(
auto
particle
:
particles
)
{
if
(
particle
->
isRunningDescriptor
())
particle
->
updateDescriptor
(
dt
);
}
}
ParticleSystem
::
iterator
ParticleSystem
::
begin
()
{
return
particles
.
begin
();
}
ParticleSystem
::
iterator
ParticleSystem
::
end
()
{
return
particles
.
end
();
}
ParticleSystem
::
const_iterator
ParticleSystem
::
begin
()
const
{
return
particles
.
begin
();
}
ParticleSystem
::
const_iterator
ParticleSystem
::
end
()
const
{
return
particles
.
end
();
}
void
ParticleSystem
::
attach
(
Particle
*
actor
)
{
if
(
!
actor
)
{
;
// throw an error
}
particles
.
push_back
(
actor
);
}
void
ParticleSystem
::
detach
(
Particle
*
actor
)
{
if
(
!
actor
)
{
;
// throw an error
}
particles
.
remove
(
actor
);
}
void
ParticleSystem
::
detachAll
()
{
particles
.
clear
();
}
SVector
<
3
>
ParticleSystem
::
position
()
const
{
return
offset
;
}
void
ParticleSystem
::
setOffset
(
const
SVector
<
3
>&
offset
)
{
this
->
offset
=
offset
;
}
// obtain static methods access
#include "sktools.h"
#include "camera.h"
#include <QMatrix4x4>
#include "specs/scalable.h"
#include "specs/orientable.h"
void
ParticleSystem
::
render
(
symkit
::
render_s
&
args
)
{
/* Load position, scaling, color */
QMatrix4x4
matrix
;
for
(
auto
particle
:
particles
)
{
if
(
particle
->
isRendering
())
{
matrix
.
setToIdentity
();
symkit
::
loadActorPosition
(
particle
,
matrix
);
Orientable
*
orient
=
dynamic_cast
<
Orientable
*>
(
particle
);
if
(
orient
)
symkit
::
loadActorOrientation
(
orient
,
matrix
);
Scalable
*
scal
=
dynamic_cast
<
Scalable
*>
(
particle
);
if
(
scal
)
symkit
::
loadActorScaling
(
scal
,
matrix
);
args
.
camera
->
loadModelview
(
args
.
shaderProgram
,
args
.
matrix
*
matrix
);
symkit
::
loadActorPolygonMode
(
particle
,
args
.
polygonMode
);
symkit
::
loadActorColor
(
particle
,
args
.
shaderProgram
);
particle
->
render
(
args
);
}
}
}
Event Timeline
Log In to Comment