void templateAppInit(int width, int height) { GFX_start(); glViewport(0.0f, 0.0f, width, height); GFX_set_matrix_mode(PROJECTION_MATRIX); GFX_load_identity(); GFX_set_perspective(80.0f, (float)width / (float)height, 1.0f, 100.0f, -90.0f); obj = OBJ_load(OBJ_FILE, 1); unsigned int i = 0; while (i != obj->n_objmesh) { if (strstr(obj->objmesh[i].name, "maze")) { navigation = NAVIGATION_init((char *)"maze"); navigation->navigationconfiguration.agent_height = 2.0f; navigation->navigationconfiguration.agent_radius = 0.4f; if (NAVIGATION_build(navigation, obj, i)) { console_print("Navigation generated.\n"); } else { console_print("Unable to create the navigation mesh."); } } OBJ_optimize_mesh(obj, i, 128); OBJ_build_mesh2(obj, i); OBJ_free_mesh_vertex_data(obj, i); ++i; } init_physic_world(); load_physic_world(); player = OBJ_get_mesh(obj, "player", 0); player->btrigidbody->setAngularFactor(0.0f); maze = OBJ_get_mesh(obj, "maze", 0); distance = maze->radius * 2.0f; i = 0; while (i != obj->n_texture) { OBJ_build_texture(obj, i, obj->texture_path, TEXTURE_MIPMAP | TEXTURE_16_BITS, TEXTURE_FILTER_2X, 0.0f); ++i; } i = 0; while (i != obj->n_objmaterial) { OBJ_build_material(obj, i, NULL); ++i; } program = PROGRAM_create((char *)"default", VERTEX_SHADER, FRAGMENT_SHADER, 1, 0, program_bind_attrib_location, NULL); }
void load_game( void ) { obj = OBJ_load( OBJ_FILE, 1 ); unsigned int i = 0; while( i != obj->n_objmesh ) { if( strstr( obj->objmesh[ i ].name, "maze" ) ) { navigation = NAVIGATION_init( ( char * )"maze" ); navigation->navigationconfiguration.agent_height = 2.0f; navigation->navigationconfiguration.agent_radius = 0.4f; if( NAVIGATION_build( navigation, obj, i ) ) { console_print( "Navigation generated.\n"); } else { console_print( "Unable to create the navigation mesh." ); } } OBJ_optimize_mesh( obj, i, 128 ); OBJ_build_mesh2( obj, i ); OBJ_free_mesh_vertex_data( obj, i ); ++i; } init_physic_world(); load_physic_world(); dispatcher->setNearCallback( near_callback ); enemy = OBJ_get_mesh( obj, "enemy", 0 ); enemy->btrigidbody->setAngularFactor( 0.0f ); navigationpathdata_player.path_point_count = navigationpathdata_enemy.path_point_count = 0; player_next_point = enemy_next_point = -1; player = OBJ_get_mesh( obj, "player", 0 ); player->btrigidbody->setAngularFactor( 0.0f ); maze = OBJ_get_mesh( obj, "maze", 0 ); distance = maze->radius * 2.0f; i = 0; while( i != obj->n_texture ) { OBJ_build_texture( obj, i, obj->texture_path, TEXTURE_MIPMAP | TEXTURE_16_BITS, TEXTURE_FILTER_2X, 0.0f ); ++i; } i = 0; while( i != obj->n_objmaterial ) { OBJ_build_material( obj, i, NULL ); ++i; } program = PROGRAM_create( ( char * )"default", VERTEX_SHADER, FRAGMENT_SHADER, 1, 0, program_bind_attrib_location, NULL ); }