Cogs.Core
MeshComponent.cpp
1#include "MeshComponent.h"
2
3#include "Context.h"
4#include "Types.h"
5
6#include "Resources/MeshManager.h"
7
8using namespace Cogs::Reflection;
9
11{
12 Field fields [] = {
13 Field(Name("meshHandle"), &MeshComponent::meshHandle),
14 };
15
16 TypeDatabase::createType<MeshComponent>().setBase<Component>().setFields(fields);
17}
18
20{
21 if (!meshHandle) {
22 meshHandle = context->meshManager->create();
23
24 setChanged();
25 }
26
27 return context->meshManager->get(meshHandle);
28}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
MeshHandle meshHandle
Handle to a Mesh resource to use when rendering.
Definition: MeshComponent.h:29
static void registerType()
Register the type in the type system.
COGSCORE_DLL_API Mesh * getMesh(class Context *context)
Utility for getting a pointer to the Mesh instance held by the component.
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Contains reflection support.
Definition: Component.h:11
void setChanged(Cogs::Core::Context *context, Cogs::ComponentModel::Component *component, Reflection::FieldId fieldId)
Must be Called after changing a Component field. Mark field changed. Request engine update.
Definition: FieldSetter.h:25
Meshes contain streams of vertex data in addition to index data and options defining geometry used fo...
Definition: Mesh.h:265
Represents an unique name.
Definition: Name.h:70