/***************************************************************** * Object_Template * * HANK Project, Copyright 1997-2001 * The University of Iowa Computer Science Department * hank@cs.uiowa.edu * * Author: * * Last Modification Info: $Id$ *****************************************************************/ #include #include "Hank/obj/Object_Template.H" #include "Hank/db/hankdb.H" #include "Hank/util/logstream.H" Object_Template::Object_Template( const long id ) : HankDB::PerceivableObject( id ) { } Object_Template::Object_Template( const long id, std::list< const Hank::ParameterBase* >& plist ) : HankDB::PerceivableObject( id ) { } Object_Template::~Object_Template() { } void Object_Template::ogl_init( void ) { // ************************************************************* // initialize the opengl aspects of this object if needed. For // instance, create display lists, load textures, etc.... // ************************************************************* } void Object_Template::ogl_draw( void ) { // ************************************************************* // Perform the actual draw routines here. // ************************************************************* } void Object_Template::initialize( void ) { // **************************************************** // Examine the property list and find the properties needed for // initialization of this object. Refer to the FAQ on object // creation for a detailed explanation of parameters as used in // object initialization. // **************************************************** } // *********************************************************** // delayedCreateObject_Template // *********************************************************** void delayedCreateObject_Template( const long id, std::list< const Hank::ParameterBase* >& param_list ) { // Here is where the actual object is instanced via the "new" // operator. Most likely, this function will be called by the // scheduler in between major frames. The "static" create function // of this object will set the delayed call in the scheduler. Object_Template *se = new Object_Template( id, param_list ); // For each parameter on the parameter list, add the property to the // object itself so it has a copy of the parameters. std::for_each( param_list.begin(), param_list.end(), HankDB::addPropertyToObject( se ) ); // Call the initialization function and get the object ready. se->initialize(); } // Yes, I know this is bad... very bad... and we need a better way to // get a handle on the scheduler, and probably the universe, or other // such structures, but for the time being this is what's being used. // If you do not like it, please fix it. extern Scheduler* scheduler; // *********************************************************** // create // // Sets up a delayed call in the scheduler to create the object // between major frames. // *********************************************************** void Object_Template::create( const long id, std::list< const Hank::ParameterBase* > param_list ) { // This function adds the delayedCreateObject_Template function to // the delayed call mechanism of the scheduler so that we can create // the vehicle at a later point, between major frames. // Typedef the create call to make it simpler to specify below. typedef void (*Creator)( const long, std::list< const Hank::ParameterBase* >& ); scheduler->addDelayedCall( new DelayedFunction2Call >( delayedCreateObject_Template, id, param_list ) ); }