void CharMouse (int button, int state, int x, int y) { must_render = true; if (ToolsFinalStage ()) return; if (state<1) { rotactive = false; moveactive = false; return; } if (button == 1) { startx = x; starty = y; startrotx = xrotation; startroty = yrotation; rotactive = true; } else if (button == 3) { startx = x; starty = y; startposx = xposition; startposy = yposition; moveactive = true; } else if (button == 4) { zposition -= 0.1; xposition += 0.03; } else if (button == 5) { zposition += 0.1; xposition -= 0.03; } }
void RenderSingleFrame (double timestep) { if (!must_render) return; check_gl_error (); // ------------------ 3d scenery ---------------------------------- set_gl_options (TUX); ClearRenderContext (colDDBackgr); string hlname = TestFrame.GetHighlightName (curr_joint); TestChar.highlight_node = TestChar.GetNodeName (hlname); glPushMatrix (); SetToolLight (); GluCamera.Update (timestep); TestFrame.CalcKeyframe (curr_frame, &TestChar, ref_position); TestChar.Draw (); glPopMatrix (); // ----------------- 2d screen ------------------------------------ SetupGuiDisplay (); set_gl_options (TEXFONT); if (FrameHasChanged ()) DrawChanged (); FT.SetFont ("bold"); FT.SetSize (20); FT.SetColor (colYellow); FT.DrawString (-1, 10, "Keyframe mode"); FT.SetFont ("normal"); FT.SetSize (16); int xl, yt; for (int i=0; i<TestFrame.numFrames; i++) { if (i != curr_frame) { FT.SetColor (colLGrey); FT.SetFont ("normal"); } else { FT.SetColor (colYellow); FT.SetFont ("bold"); } xl = ITrunc (i, framebase) * 100 + 20; yt = IFrac (i, framebase) * 18 + 20; FT.DrawString (xl, yt, Int_StrN (i)); } FT.SetFont ("normal"); FT.SetColor (colLGrey); PrintFrameParams (param.y_resolution - 330, TestFrame.GetFrame (curr_frame)); if (ToolsFinalStage ()) { FT.SetSize (20); FT.SetColor (colYellow); FT.DrawString (-1, param.y_resolution - 50, "Quit program. Save character list (y/n)"); } Reshape (param.x_resolution, param.y_resolution); Winsys.SwapBuffers(); must_render = false; }
void SingleFrameMouse (int button, int state, int x, int y) { must_render = true; if (ToolsFinalStage ()) return; if (button == 4) { GluCamera.distance += 0.1; } else if (button == 5) { GluCamera.distance -= 0.1; } }
void RenderChar (double timestep) { if (!must_render) return; bool is_visible = false; check_gl_error(); // ------------- 3d scenery --------------------------------------- set_gl_options (TUX); ClearRenderContext (colDDBackgr); TestChar.highlight_node = TestChar.GetNodeName (curr_node); glLoadIdentity (); glPushMatrix (); SetToolLight (); TestChar.ResetRoot (); TestChar.ResetJoints (); glTranslatef (xposition, yposition, zposition); glRotatef (xrotation, 1, 0, 0); glRotatef (yrotation, 0, 1, 0); glRotatef (zrotation, 0, 0, 1); if (drawcount > 0) TestChar.Draw (); glPopMatrix (); drawcount++; // --------------- 2d screen -------------------------------------- SetupGuiDisplay (); set_gl_options (TEXFONT); FT.SetFont ("bold"); FT.SetSize (20); FT.SetColor (colYellow); FT.DrawString (-1, 10, "Edit mode"); if (CharHasChanged ()) DrawChanged (); FT.SetFont ("normal"); FT.SetSize (16); int xl, yt; for (int i=0; i<=lastnode; i++) { if (i != curr_node) { FT.SetColor (colLGrey); FT.SetFont ("normal"); } else { FT.SetColor (colYellow); FT.SetFont ("bold"); } xl = ITrunc (i, charbase) * 100 + 20; yt = IFrac (i, charbase) * 18 + 60; FT.DrawString (xl, yt, TestChar.GetNodeJoint (i)); } int num = action->num; int type; if (num > 0) { for (int i=0; i<num; i++) { is_visible = false; type = action->type[i]; yt = param.y_resolution - 120 + i * 18; switch (type) { case 0: DrawActionVec (i, "trans", yt, action->vec[i]); break; case 1: DrawActionFloat (i, "x-rot", yt, action->dval[i]); break; case 2: DrawActionFloat (i, "y-rot", yt, action->dval[i]); break; case 3: DrawActionFloat (i, "z-rot", yt, action->dval[i]); break; case 4: DrawActionVec (i, "scale", yt, action->vec[i]); break; case 5: DrawActionFloat (i, "vis", yt, action->dval[i]); is_visible = true; break; default: break; } } } if (is_visible) FT.SetColor (colYellow); else FT.SetColor (colLGrey); FT.DrawString (20, 20, action->name); if (ToolsFinalStage ()) { FT.SetSize (20); FT.SetColor (colYellow); FT.DrawString (-1, param.y_resolution - 50, "Quit program. Save character list (y/n)"); } Reshape (param.x_resolution, param.y_resolution); Winsys.SwapBuffers (); if (drawcount > 3) must_render = false; }
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; } }
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; } }