Beispiel #1
0
void CharKeys (unsigned int key, bool special, bool release, int x, int y) {
	int keyfact;
	must_render = true;

	if (ToolsFinalStage ()) {
		if (key == SDLK_y || key == SDLK_j) {
			SaveToolCharacter ();
			SaveToolFrame ();
			Winsys.Quit();
		} else if (key == SDLK_n) Winsys.Quit ();
		return;
	}

	if (key == 304) shift = !release;
	if (key == 306) control = !release;
	if (key == 308) alt = !release;
	if (shift) keyfact = -1; else keyfact = 1;

	if (release) return;

	int type = action->type[curr_act];	
	switch (key) {
		case SDLK_TAB: SetToolMode (1); break;
		case SDLK_ESCAPE: case SDLK_q: QuitTool (); break;
		case SDLK_F10: ScreenshotN (); break;
		case SDLK_s: SaveToolCharacter ();  break;
		case SDLK_c: ScreenshotN (); break;
		case SDLK_m: TestChar.useMaterials = !TestChar.useMaterials; break;
		case SDLK_h: TestChar.useHighlighting = !TestChar.useHighlighting; break;
		case SDLK_r: 
			TestChar.Reset (); 
			ReloadToolCharacter ();
			ToolsInit ();
			break;
		case SDLK_u: if (action != NULL) {
				RecallAction (action);
				TestChar.RefreshNode (curr_node);
			} break;
		case SDLK_PLUS: case SDLK_EQUALS: // zoom in
			zposition += 0.1;
			xposition -= 0.03;
			break;
		case SDLK_MINUS: // zoom out
			zposition -= 0.1;
			xposition += 0.03;
			break;

		// set rotations for view
		case SDLK_1: SetRotation (0, 0, 0); break;
		case SDLK_2: SetRotation (-50, 180, 15); break;
		case SDLK_3: SetRotation (0, 180, 0); break;
		case SDLK_4: SetRotation (0, -80, 0); break;

		// select node
		case SDLK_PAGEUP: ChangeNode (-1); break;
		case SDLK_PAGEDOWN: ChangeNode (1); break;
		case SDLK_END: ChangeNode (charbase); break;
		case SDLK_HOME: ChangeNode (-charbase); break;

		// select action
		case SDLK_DOWN: 
			if (curr_act < lastact) curr_act++; 
			if (action->type[curr_act] == 4) comp = 0; else comp = 1;
			break; 
		case SDLK_UP: 
			if (curr_act > 0) curr_act--; 
			if (action->type[curr_act] == 4) comp = 0; else comp = 1;
			break; 
		case SDLK_LEFT: ChangeValue (type, -1); break;
		case SDLK_RIGHT: ChangeValue (type, 1); break;

		// select value
		case SDLK_SPACE: 
			if (type == 0 || type == 4) {
				comp++;
				if (comp > 3) comp = 0;
				if (type == 0 && comp == 0) comp = 1;
			} break;
		default: break;
	}
}
Beispiel #2
0
void SingleFrameKeys (unsigned int key, bool special, bool release, int x, int y) {
//PrintInt (key);
	must_render = true;
	int keyfact;
	TKeyframe2 *frame = TestFrame.GetFrame (curr_frame);

	// setting the camera change state
	if (key == SDLK_F1) {GluCamera.turnright = !release; return;}
	else if (key == SDLK_F2) {GluCamera.turnleft = !release; return;}
	else if (key == SDLK_F3) {GluCamera.nearer = !release; return;}
	else if (key == SDLK_F4) {GluCamera.farther = !release; return;}

	// additional keys if needed
	switch (key)
	{
	case SDLK_LSHIFT:
	case SDLK_RSHIFT:
		shift = !release; break;
	case SDLK_LCTRL:
	case SDLK_RCTRL:
		control = !release; break;
	case SDLK_LALT:
	case SDLK_RALT:
		alt = !release; break;
	}

	if (shift) keyfact = -1; else keyfact = 1;

	if (release) return;

	switch (key) {
		case SDLK_y: case SDLK_j:
			if (ToolsFinalStage ()) {
				SaveToolCharacter ();
				SaveToolFrame ();
				Winsys.Quit();
			} break;
		case SDLK_n: if (ToolsFinalStage ()) Winsys.Quit (); break;

		case SDLK_ESCAPE: case SDLK_q: QuitTool (); break;
		case SDLK_s: SaveToolFrame (); break;
		case SDLK_TAB: SetToolMode (0); break;

		case SDLK_a:
			TestFrame.AddFrame (); 
			SetFrameChanged (true);
			break;
		case SDLK_INSERT:
			TestFrame.InsertFrame (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_DELETE:
			curr_frame = TestFrame.DeleteFrame (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_PAGEDOWN: if (curr_frame < TestFrame.numFrames-1) curr_frame++; break;
		case SDLK_PAGEUP: if (curr_frame > 0) curr_frame--; break;
		case SDLK_UP: if (curr_joint > 0) curr_joint--; break;
		case SDLK_DOWN: if (curr_joint < last_joint) curr_joint++; break;
		case SDLK_RIGHT:
				if (curr_joint < 4) frame->val[curr_joint] += 0.05;
				else frame->val[curr_joint] += 1;
				SetFrameChanged (true);
				break;
		case SDLK_LEFT: 
				if (curr_joint < 4) frame->val[curr_joint] -= 0.05;
				else frame->val[curr_joint] -= 1;
				SetFrameChanged (true);
				break;
		case SDLK_0: 
			frame->val[curr_joint] = 0.0;
			SetFrameChanged (true);
			break;
		case SDLK_SPACE:
			if (curr_joint < 4) frame->val[curr_joint] += 0.05 * keyfact;
			else frame->val[curr_joint] += 1 * keyfact;
			SetFrameChanged (true);
			break;

		case SDLK_RETURN:
			TestFrame.InitTest (ref_position, &TestChar); 
			SetToolMode (2);
			must_render = true;
			break;

		case SDLK_m: TestChar.useMaterials = !TestChar.useMaterials; break;
		case SDLK_h: TestChar.useHighlighting = !TestChar.useHighlighting; break;
		case SDLK_c: 
			if (control) TestFrame.CopyToClipboard (curr_frame); 
			else TestFrame.ClearFrame (curr_frame);
			SetFrameChanged (true);
			break;
		case SDLK_v: 
			if (control) TestFrame.PasteFromClipboard (curr_frame); 
			SetFrameChanged (true);
			break;
		case SDLK_p: if (curr_frame>0) 
			TestFrame.CopyFrame (curr_frame-1, curr_frame); break;
		case SDLK_F10: ScreenshotN (); break;

		case SDLK_1: GluCamera.angle = 0; break;
		case SDLK_2: GluCamera.angle = 45; break;
		case SDLK_3: GluCamera.angle = 90; break;
		case SDLK_4: GluCamera.angle = 135; break;
		case SDLK_5: GluCamera.angle = 180; break;
		case SDLK_6: GluCamera.angle = 225; break;
		case SDLK_7: GluCamera.angle = 270; break;
		case SDLK_8: GluCamera.angle = 315; break;
	}
}