| | 82 | |
| | 83 | == Resource Manager == |
| | 84 | There is a filehandler, that loades stores and unloades resources, like .obj-models, wav's, ogg's, textures and so on |
| | 85 | |
| | 86 | == usage in a WorldEntity like the Player == |
| | 87 | {{{ |
| | 88 | #include "resource_manager.h" /* includes the headers of the ResourceManager */ |
| | 89 | |
| | 90 | Player::Player() /* in the initialisation we load the module */ |
| | 91 | { |
| | 92 | . |
| | 93 | . |
| | 94 | . |
| | 95 | /* the following loads an OBJ-file named models/reaplow.obj |
| | 96 | * The type is OBJ (if no type is specified the model will try to determine it for itself) |
| | 97 | * RP_CAMPAIGN tells the ResourceManager when, and if it will be allowed to delete the Model |
| | 98 | */ |
| | 99 | this->model = (Model*)ResourceManager::load("models/reaplow.obj", OBJ, RP_CAMPAIGN); |
| | 100 | } |
| | 101 | |
| | 102 | Player::~Player() |
| | 103 | { |
| | 104 | /* here we would unload the Resource, that we allocated, but because WorldEntity |
| | 105 | * is doing it anyway, we do not have to concern ourselves with this. |
| | 106 | * But one could do something like: ResourceManager::unload(this->model); to do it |
| | 107 | */ |
| | 108 | } |
| | 109 | |
| | 110 | /* and thats it */ |
| | 111 | }}} |
| | 112 | |
| | 113 | == settings == |
| | 114 | As we see in the Player::Player() example, there are some options to be considered when |
| | 115 | allocating a resource: |
| | 116 | |
| | 117 | __RESOURCE TYPES__: different types known to the resourceManager |
| | 118 | {{{ |
| | 119 | /** |
| | 120 | OBJ: a .obj-file |
| | 121 | PRIM: a Model primitive (CUBE, CYLINDER, SPHERE and so on...) |
| | 122 | WAV: a wave-file |
| | 123 | OGG: i think you get it |
| | 124 | */ |
| | 125 | enum ResourceType {OBJ, PRIM, WAV, MP3, OGG, IMAGE}; |
| | 126 | }}} |
| | 127 | |
| | 128 | __RESOURCE PRIORITIES__: different unload-stages |
| | 129 | {{{ |
| | 130 | /** |
| | 131 | RP_NO: will be unloaded on request |
| | 132 | RP_LEVEL: will be unloaded at the end of a Level |
| | 133 | RP_CAMPAIGN: will be unloaded at the end of a Campaign |
| | 134 | RP_GAME: will be unloaded at the end of the whole Game (when exiting orxonox) |
| | 135 | */ |
| | 136 | enum ResourcePriority {RP_NO = 0, RP_LEVEL = 1, RP_CAMPAIGN = 2, RP_GAME = 3}; |
| | 137 | }}} |
| | 138 | |