void ResizeBrushesToolController::doPick(const InputState& inputState, Model::PickResult& pickResult) {
     if (handleInput(inputState)) {
         const Model::Hit hit = doPick(inputState.pickRay(), pickResult);
         if (hit.isMatch())
             pickResult.addHit(hit);
     }
 }
Beispiel #2
0
void Game::doAction(const Actions action) {
	switch (action)
	{
	case GO: doGo(); break;
	case QUIT: doQuit(); break;
	case PICK: doPick(); break;
	case DROP: doDrop(); break;
	case READ: doRead(); break;
	case BREAK: doBreak(); break;
	case SEE: doSee(); break;
	case OPEN: doOpen(); break;
	case FILL: doFill(); break;
	case USE: doUse(); break;
	case PUT: doPut(); break;
	case NOACTION: doNothing(); break;
	default: doNothing();
	}
}
Beispiel #3
0
void Game::doPick() {
	if (object != verb)
	{
		Item toPick = room_list[current_room]->getItem(object);
		if (checkAction(toPick, PICK))
		{
			toPick = room_list[current_room]->removeItem(object);
			player->pickItem(toPick);
			room_list[current_room]->changeState(toPick.first);
			cout << "You picked the " << toPick.first << "." << endl;
		}
		else cout << "You can't pick that item" << endl;
	}
	else {
		cout << "Which item do you want to pick?" << endl;
		cout << ">";
		getline(cin, object);
		doPick();
	}
}
Beispiel #4
0
// FlTk Event handler for the window
// TODO: if you want to make the train respond to other events 
// (like key presses), you might want to hack this.
int TrainView::handle(int event)
{
	// see if the ArcBall will handle the event - if it does, then we're done
	// note: the arcball only gets the event if we're in world view
	if (tw->worldCam->value())
		if (arcball.handle(event)) return 1;

	// remember what button was used
	static int last_push;

	switch(event) {
		case FL_PUSH:
			last_push = Fl::event_button();
			if (last_push == 1) {
				doPick();
				damage(1);
				return 1;
			};
			break;
		case FL_RELEASE:
			damage(1);
			last_push=0;
			return 1;
		case FL_DRAG:
			if ((last_push == 1) && (selectedCube >=0)) {
				ControlPoint* cp = &world->points[selectedCube];

				double r1x, r1y, r1z, r2x, r2y, r2z;
				getMouseLine(r1x,r1y,r1z, r2x,r2y,r2z);

				double rx, ry, rz;
				mousePoleGo(r1x,r1y,r1z, r2x,r2y,r2z, 
						  static_cast<double>(cp->pos.x), 
						  static_cast<double>(cp->pos.y),
						  static_cast<double>(cp->pos.z),
						  rx, ry, rz,
						  (Fl::event_state() & FL_CTRL) != 0);
				cp->pos.x = (float) rx;
				cp->pos.y = (float) ry;
				cp->pos.z = (float) rz;
				damage(1);
			}
			break;
			// in order to get keyboard events, we need to accept focus
		case FL_FOCUS:
			return 1;
		case FL_ENTER:	// every time the mouse enters this window, aggressively take focus
				focus(this);
				break;
		case FL_KEYBOARD:
		 		int k = Fl::event_key();
				int ks = Fl::event_state();
				if (k=='p') {
					if (selectedCube >=0) 
						printf("Selected(%d) (%g %g %g) (%g %g %g)\n",selectedCube,
							world->points[selectedCube].pos.x,world->points[selectedCube].pos.y,world->points[selectedCube].pos.z,
							world->points[selectedCube].orient.x,world->points[selectedCube].orient.y,world->points[selectedCube].orient.z);
					else
						printf("Nothing Selected\n");
					return 1;
				};
				break;
	}

	return Fl_Gl_Window::handle(event);
}