Game Development Reference
In-Depth Information
Figure 22.4
The ActorComponentsEditor showing two components.
C++ classes, such as the TransformComponent , which stores position and orienta-
tion, or the GridRenderComponent , which stores the color, texture filename, and size
of a grid scene node. Each of these components has member data that should be exposed
to the editor. Exposing these data members to the editor would mean creating controls
like a text box to edit a filename or a combo box to make a selection from a list.
One method might be to simply write some C# code that mirrors each C++ compo-
nent. It does create a weakness in the editor, however. If the C++ component changes
by adding or removing data members, the editor must be changed, recompiled, and
redistributed to anyone using it. Wouldn
t a better solution be data driven?
Imagine an XML file that defined components from the editor ' s point of view:
'
<Components>
<Component name=
TransformComponent
>
<Element name=
Position
type=
Vec3
fieldNames=
x,y,z
/>
<Element name=
YawPitchRoll
type=
Vec3
fieldNames=
x,y,z
/>
</Component>
<Component name=
GridRenderComponent
>
<Element name=
Color
type=
RGBA
/>
<Element name=
Texture
type=
File
extensions=
Image Files(*.JPG;*.GIF;*.DDS)
*.JPG;*.GIF;*.DDS
/>
<Element name=
Division
type=
int
/>
</Component>
</Components>
 
Search WWH ::




Custom Search