bool Terrain::init(const char * ppmFile){ height_map = Texture::loadPPM(ppmFile, width, height); /* Create a 1024*1024 array of vertex coordinates (Vector3). Populate the array as follows: the x values should correspond to the array's x index, the z values to the y index. For example: Vector3[x][y].x = x, Vector3[x][y].z = y. The y value should be the corresponding value from the height map array (Vector3[x][y].y = heightmap[x][y]). */ for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ coords[x][y] = Vector3(x, height_map[3*(x*height + y)], y); if((coords[x][y])[1] > max_height) max_height = (coords[x][y])[1]; } } setNormals(); update_levels(0); return true; }
virtual Boolean add_plugin (PluginInfo *info, Plugin *plugin) { Boolean result (False); if (info && plugin) { PluginStruct *ps (new PluginStruct (info, plugin, log)); if (ps && ps->info) { update_levels (*ps); if (pluginTable.store (ps->info->get_handle (), ps)) { if (ps->info && ps->HasInterface) { interfaceTable.store (ps->info->get_handle (), ps); } result = True; } else { delete ps; ps = 0; } if (discovered) { discover_all_plugins (plugin); if (ps->HasInterface) { discover_plugin (plugin); } } if (started) { LevelStruct *ls (levelsTail); while (ls) { if (info->uses_level (ls->Level)) { plugin->update_plugin_state (PluginStateInit, ls->Level); } ls = ls->prev; } ls = levelsTail; while (ls) { if (info->uses_level (ls->Level)) { plugin->update_plugin_state (PluginStateStart, ls->Level); } ls = ls->prev; } } } update_obs (PluginDiscoverAdd, ps->info->get_handle ()); result = True; } return result; }