Accessing to RED Object Interfaces
From the user point of view, all the RED objects created through the RED::Factory
and passed to the HOOPS Luminate API are of the class RED::Object
. This base class implements a very small set of methods which mainly consists of the dynamic casting mechanism. The casting mechanism enables the user to retrieve sets of methods, called interfaces, from those base objects.
Hence, here is the example of the creation of a viewpoint:
RED::Object* viewpoint = RED::Factory::CreateInstance( CID_REDViewpoint );
RED::IViewpoint* iviewpoint = viewpoint->As< RED::IViewpoint >();
The list of valid CIDs can be found in REDCID.h
. Another example with a light source:
RED::Object* light = RED::Factory::CreateInstance( CID_REDLightShape );
RED::ILightShape* ilight = light->As< RED::ILightShape >();
Some objects may implement several interfaces. For example, the light source created above also implements the RED::IShape
interface:
RED::IShape* ishape = light->As< RED::IShape >();