void dumpPointLight(FILE *outFP, entity_t *ent) { assert(ent->magic == ENTITY_T); pointlight_t *pointlight = ent->entDerived; dumpEntity(outFP, ent); fprintf(outFP, " color: %6d %6d %6d\n",pointlight->color.r,pointlight->color.g,pointlight->color.b); fprintf(outFP, " brightness: %8.4lf\n",pointlight->brightness); printTuple(outFP, " center: ",pointlight->center); }
/** dumpSceneObj **/ void dumpSceneObj(FILE *out, entity_t *ent) { assert(ent->magic == ENTITY_T); sobj_t *obj = ent->entDerived; assert(obj->magic == SCENEOBJ_T); /* First dump the entity_t data */ dumpEntity(out, ent); /* And now the sobj_t specific data */ fprintf(out, " color: %6d %6d %6d\n", obj->color.r, obj->color.g, obj->color.b); vec_print(" diffuse: ", obj->diffuse); vec_print(" reflective:", obj->reflective); }
/** dumpWindow **/ void dumpWindow(FILE *out, entity_t *ent) { // First dump the entity out. dumpEntity(out,ent); // Make a new pointer to make typing easier. window_t *window = ent->entDerived; // Make sure we really have a window_t at the other end. assert(window->magic == WINDOW_T); // Make some new pointers to make typing easier. point_t viewPoint = window->viewPoint; intensity_t ambient = window->ambient; // Print out the stuff we want all pretty and such. fprintf(out," Pixel Width: %d\n",window->pixelColumns); fprintf(out," World Width: %.1f\n",window->windowWidth); fprintf(out," World Height: %.1f\n",window->windowHeight); fprintf(out," viewPoint: %.1f %.1f %.1f\n",viewPoint.x,viewPoint.y,viewPoint.z); fprintf(out," ambient intensity: %.1f %.1f %.1f\n",ambient.x,ambient.y,ambient.z); }
const std::string& CmdEntityDump::execute( const std::vector< std::string >& arguments ) { bool dumpall = false; std::string dumpfile = yaf3d::Application::get()->getMediaPath(); std::string dumpcontent; _cmdResult = ""; if ( arguments.size() < 2 ) { _cmdResult = getUsage(); return _cmdResult; } if ( arguments[ 0 ] == "-all" ) { dumpall = true; } dumpfile += arguments[ 1 ]; dumpcontent = "<!-- entity dump file containing entity type and parameter information -->\n"; std::string timestamp = yaf3d::getTimeStamp(); timestamp.erase( timestamp.size() - 1 ); // remove line-feed at end of timestamp string dumpcontent += "<!-- created by vrc console: " + timestamp + " -->\n\n"; // we get the parameters out of entities after we have constructed them. // we shutdown the application if the option -all is used. the shutdown is necessary as some entities are meant to be singletons or perform // particular tasks in their constructor which may lead to instability or crashes when we create a new instance of them in a brute-force // manner in order to get their parameters. // note: getting the parameters of already exisiting entities makes no problems so no shutdown is needed ( i.e. no use of -all option ). if ( !dumpall ) { yaf3d::BaseEntity* p_entity = yaf3d::EntityManager::get()->findInstance( arguments[ 0 ] ); if ( !p_entity ) { _cmdResult = " entity '" + arguments[ 0 ] + "' cannot be found\n"; _cmdResult += getUsage(); return _cmdResult; } _cmdResult = "dumping entity '" + arguments[ 0 ] + "' to file: " + dumpfile; yaf3d::BaseEntityFactory* p_factory = yaf3d::EntityManager::get()->getEntityFactory( p_entity->getTypeName() ); dumpcontent += dumpEntity( p_entity, p_factory->getCreationPolicy() ); } else { std::vector< yaf3d::BaseEntityFactory* > factories; yaf3d::EntityManager::get()->getAllEntityFactories( factories ); std::stringstream totcount; totcount << factories.size(); dumpcontent += "<!-- total count of available entities: " + totcount.str() + " -->\n\n"; std::vector< yaf3d::BaseEntityFactory* >::iterator p_beg = factories.begin(), p_end = factories.end(); for ( ; p_beg != p_end; ++p_beg ) { yaf3d::BaseEntity* p_entity = yaf3d::EntityManager::get()->createEntity( ( *p_beg )->getType() ); dumpcontent += dumpEntity( p_entity, ( *p_beg )->getCreationPolicy() ); dumpcontent += "\n"; yaf3d::EntityManager::get()->deleteEntity( p_entity ); } // shutdown application now yaf3d::Application::get()->stop(); } // write out the dump file std::ofstream of; of.open( dumpfile.c_str(), std::ios::out | std::ios::binary ); if ( !of ) { _cmdResult += " cannot open file '" + dumpfile + "' for writing the dump."; return _cmdResult; } of << dumpcontent; of.close(); return _cmdResult; }