Tuesday, September 6, 2011

Just a small update

I've added project serialization using boost::serialization; although it was rather easy to implement, it took some time until I fully understood how to serialize classes which inherit from one or several base classes. For example, all entity components inherit from a base class EntityComponent which among others serializes the component's parent transform. Similarily, all resources inherit from a common base class Resource, which stores the resource's file path. In order to make sure that the desired inherited class members are serialized properly as well, one should use the BOOST_CLASS_EXPORT_GUID macro, which has to be defined for every class at the top of each source file from which these classes are serialized:

 BOOST_CLASS_EXPORT_GUID( EntityComponent, "EntityComponent" )  
 BOOST_CLASS_EXPORT_GUID( ModelController, "ModelController" )  
 BOOST_CLASS_EXPORT_GUID( CameraController, "CameraController" )  
 BOOST_CLASS_EXPORT_GUID( SkeletonController, "SkeletonController" )  

If not used, your program may simply crash without telling you where and why. At least that's what happened to me, ruining an otherwise perfectly fine Saturday afternoon :/

Also, it's now possible to create and attach cameras to entities through the editor. In addition to their primary free-fly camera, all 3D viewport can then select and preview all available cameras. This is useful to set up and test in-game cameras. The screenshot illustrates how a third person camera may be set up for a mech game:


No comments:

Post a Comment