示例#1
0
void Character::initNodePath(Player *player,
							 CollisionTraverser *traverser,
							 CollisionTraverser *traverserQueue,
							 CollisionHandlerQueue *colliHandlerQueue,
							 Filename charDir,
							 Filename charWalkDir,
							 Filename charStandDir,
							 std::string lodNodename,
							 std::string colliNodeName) {
	LODNode *lod = new LODNode(lodNodename);
	NodePath lodNodePath(lod);
	lodNodePath.reparent_to(player->getWindow()->get_render());
	lod->add_switch(50, 0);

	// load character and place on the grounds
	NodePath character = player->getWindow()->load_model(player->getPanda()->get_models(), charDir);
	character.reparent_to(lodNodePath);
	character.set_scale(0.203, 0.203, 0.203);

	// add collision node to character
	CollisionNode *collNode = new CollisionNode(colliNodeName);
	collNode->add_solid(new CollisionSphere(0, 0, 0, 2.5));
	NodePath fromObj = character.attach_new_node(collNode);
	CollisionHandlerPusher *colliHandlerPusher = new CollisionHandlerPusher();
	colliHandlerPusher->add_collider(fromObj, character);

	traverser->add_collider(fromObj, colliHandlerPusher);
	traverserQueue->add_collider(fromObj, colliHandlerQueue);

	// Load the walk animation
	player->getWindow()->load_model(character, charStandDir);
	player->getWindow()->load_model(character, charWalkDir);

	// bind animation
	auto_bind(character.node(), animCollection);

	stopMoving();
	nodePath = character;
	
	standAnimName = animCollection.get_anim_name(0);
	walkAnimName = animCollection.get_anim_name(1);

	// get animation names
	//for(int i = 0; i < animCollection.get_num_anims(); i++)
	//	cout << animCollection.get_anim_name(i) << endl;
}
示例#2
0
int main(int argc, char **argv)
{
	char *busid = NULL;
	char *remote_host = NULL;

	enum {
		cmd_unknown = 0,
		cmd_use_by_usbip,
		cmd_use_by_other,
		cmd_list,
		cmd_scriptlist,
		cmd_autobind,
		cmd_export_to,
		cmd_unexport,
		cmd_help,
		cmd_hotplug
	} cmd = cmd_unknown;

	if (geteuid() != 0)
		g_warning("running non-root?");

	for (;;) {
		int c;
		int index = 0;

		c = getopt_long(argc, argv, "u:o:hlsae:x:b:H", longopts, &index);
		if (c == -1)
			break;

		switch (c) {
			case 'u':
				cmd = cmd_use_by_usbip;
				busid = optarg;
				break;
			case 'o' :
				cmd = cmd_use_by_other;
				busid = optarg;
				break;
			case 'l' :
				cmd = cmd_list;
				break;
			case 's' :
				cmd = cmd_scriptlist;
				break;
			case 'a' :
				cmd = cmd_autobind;
				break;
			case 'b':
				busid = optarg;
				break;
			case 'e':
				cmd = cmd_export_to;
				remote_host = optarg;
				break;
			case 'x':
				cmd = cmd_unexport;
				remote_host = optarg;
				break;
			case 'H':
				cmd = cmd_hotplug;
				break;
			case 'h': /* fallthrough */
			case '?':
				cmd = cmd_help;
				break;
			default:
				g_error("getopt");
		}

		//if (cmd)
		//	break;
	}

	switch (cmd) {
		case cmd_use_by_usbip:
			use_device_by_usbip(busid);
			break;
		case cmd_use_by_other:
			use_device_by_other(busid);
			break;
		case cmd_list:
			show_devices();
			break;
		case cmd_scriptlist:
			show_devices_script();
			break;
		case cmd_autobind:
			auto_bind();
			break;
		case cmd_export_to:
			export_to(remote_host, busid);
			break;
		case cmd_unexport:
			unexport_from(remote_host, busid);
			break;
		case cmd_hotplug:
			hotplug();
			break;
		case cmd_help: /* fallthrough */
		case cmd_unknown:
			show_help();
			break;
		default:
			g_error("NOT REACHED");
	}

	return 0;
}