Cogs.Core
Source
Systems
Appearance
TextureGeneratorSystem.cpp
1
#include "TextureGeneratorSystem.h"
2
3
#include "Foundation/Logging/Logger.h"
4
5
#include "Context.h"
6
7
#include "Components/Appearance/MaterialComponent.h"
8
9
#include "Resources/TextureManager.h"
10
#include "Resources/MaterialManager.h"
11
12
#include "Services/Services.h"
13
14
#include "Generators/TextureGenerator.h"
15
16
void
Cogs::Core::TextureGeneratorSystem::update
(
Context
* context)
17
{
18
auto
textureGenerator =
context
->
services
->getService<
TextureGenerator
>();
19
20
for
(
const
auto
& component :
pool
) {
21
if
(component.diffuseMap == ImageType::None)
continue
;
22
23
auto
materialComponent = component.getComponent<
MaterialComponent
>();
24
25
auto
texture = textureGenerator->getTexture(component.diffuseMap);
26
27
if
(materialComponent && materialComponent->diffuseMap != texture) {
28
materialComponent->diffuseMap = texture;
29
materialComponent->
setChanged
();
30
}
else
if
(component.material) {
31
auto
key = component.material->material->getTextureKey(
"diffuseMap"
);
32
33
component.material->setTextureProperty(key, texture);
34
}
35
}
36
}
37
Cogs::ComponentModel::Component::setChanged
void setChanged()
Sets the component to the ComponentFlags::Changed state with carry.
Definition:
Component.h:202
Cogs::Core::ComponentSystemBase::context
Context * context
Pointer to the Context instance the system lives in.
Definition:
ComponentSystem.h:136
Cogs::Core::ComponentSystemBase::update
void update()
Updates the system state to that of the current frame.
Definition:
ComponentSystem.h:65
Cogs::Core::ComponentSystem< TextureGeneratorComponent >::pool
ComponentPool< TextureGeneratorComponent > pool
Pool of components managed by the system.
Definition:
ComponentSystem.h:235
Cogs::Core::Context
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition:
Context.h:83
Cogs::Core::Context::services
std::unique_ptr< class Services > services
Services.
Definition:
Context.h:174
Cogs::Core::TextureGenerator
Definition:
TextureGenerator.h:21
Cogs::Core::MaterialComponent
Exposes material properties for legacy entities and code.
Definition:
MaterialComponent.h:22
Generated by
1.9.6