Beispiel #1
0
void View::prepare(Model *model) {
    // add the attributes
    model->add_gl_attribute(gl::Attribute(0, 3, GL_FLOAT, false, get_vector_data(model->get_vertices())));
    model->add_gl_attribute(gl::Attribute(1, 3, GL_FLOAT, false, get_vector_data(model->get_normals())));
    model->add_gl_attribute(gl::Attribute(2, 2, GL_FLOAT, false, get_vector_data(model->get_uvs())));

    // bind the model's attributes to buffers
    for (auto &attribute : model->get_gl_attributes()) {
        renderer->bind(attribute, STATIC);
    }

    // bind the vertex groups
    for (VertexGroup &vertex_group : model->get_vertex_groups()) {
        // bind the element indices into a buffer
        renderer->bind(vertex_group, STREAM, ELEMENT);
    }
}
Categ_non_param_cdf<int>  
CategoricalProbabilityPropertyGroup::get_distribution(int node_id) const{
  std::vector<Grid_continuous_property::property_type> prob = get_vector_data( node_id );
  return Categ_non_param_cdf<int>(prob.size(), prob.begin());
}
Non_param_cdf<>
IndicatorContinuousPropertyGroup::get_distribution(int node_id) const{
  std::vector<Grid_continuous_property::property_type> prob = get_vector_data( node_id );
  return Non_param_cdf<>(thresholds_.begin(),thresholds_.end(), prob.begin() );
}
Beispiel #4
0
// process an incoming respawn info packet
void multi_respawn_process_packet(ubyte *data, header *hinfo)
{
	ubyte code,cur_link_status;
	char cur_primary_bank,cur_secondary_bank;
	ushort net_sig,ship_ets;
	short player_id;
	int player_index;
	vector v;	
	char parse_name[1024] = "";
	int offset = HEADER_LENGTH;

	// determine who send the packet	
	player_index = find_player_id(hinfo->id);
	if(player_index == -1){
		nprintf(("Network","Couldn't find player for processing respawn packet!\n"));
	}

	// get the opcode
	GET_DATA(code);

	// do something based upon the opcode
	switch((int)code){

	case AI_RESPAWN_NOTICE: 
		p_object *pobjp;

		GET_USHORT( net_sig );
		pobjp = mission_parse_get_arrival_ship( net_sig );
		Assert( pobjp != NULL );
		multi_respawn_ai( pobjp );
		break;		

	case RESPAWN_BROADCAST:
		// get the respawn data
		GET_USHORT(net_sig);
		get_vector_data( data, &offset, v );
		GET_SHORT(player_id);
		GET_DATA(cur_primary_bank);
		GET_DATA(cur_secondary_bank);
		GET_DATA(cur_link_status);
		GET_USHORT(ship_ets);
		GET_STRING(parse_name);
		player_index = find_player_id(player_id);
		if(player_index == -1){
			nprintf(("Network","Couldn't find player to respawn!\n"));
			break;
		}

		// create the ship and assign its position, net_signature, and class
		// respawn the player
		multi_respawn_player(&Net_players[player_index], cur_primary_bank, cur_secondary_bank, cur_link_status, ship_ets, net_sig, parse_name, &v);

		// if this is for me, I should jump back into gameplay
		if(&Net_players[player_index] == Net_player){
			extern int Player_multi_died_check;
			Player_multi_died_check = -1;

			gameseq_post_event(GS_EVENT_ENTER_GAME);
		}
		break;
	
	case RESPAWN_REQUEST:
		// determine whether he wants to respawn as an observer or not
		GET_DATA(code);

		nprintf(("Network","Received respawn request\n"));
		if(player_index == -1){
			nprintf(("Network","Received respawn request from unknown player!\n"));
			break;
		} 		     		

		// make sure he's not making an invalid request
		if((code == 0) && !(Net_players[player_index].flags & NETINFO_FLAG_RESPAWNING)){
			nprintf(("Network","Received respawn request from player who shouldn't be respawning!\n"));
			Int3();
			break;
		} else if((code == 1) && !(Net_players[player_index].flags & NETINFO_FLAG_LIMBO)){
			nprintf(("Network","Received respawn observer request from a player who shouldn't be respawning as an observer!\n"));
			Int3();
			break;
		}

		// otherwise perform the operation
		// respawn the guy as an observer
		if(code){
			multi_respawn_make_observer(&Net_players[player_index]);			
		}
		// respawn him as normal
		else {						
			// create his new ship, and change him from respawning to respawned
			Assert(Net_players[player_index].p_info.p_objp != NULL);
			if(Net_players[player_index].p_info.p_objp != NULL){
				multi_respawn_player(&Net_players[player_index], Net_players[player_index].s_info.cur_primary_bank, Net_players[player_index].s_info.cur_secondary_bank,Net_players[player_index].s_info.cur_link_status, Net_players[player_index].s_info.ship_ets, 0, Net_players[player_index].p_info.p_objp->name);
			}			
		}	
		break;
	}

	PACKET_SET_SIZE();
}