Exemple #1
0
void FPSControls::computeMouseTranslation( Qt::MouseButtons buttons,
    const Vector2f& delta, PerspectiveCamera& camera )
{
    if( buttons == Qt::RightButton )
    {
        float x = m_mouseParameters.translationPerPixel.x * delta.x;
        float z = m_mouseParameters.translationPerPixel.y * delta.y;
        applyTranslation( x, 0, z, camera );
    }
    else if( buttons & Qt::LeftButton && buttons & Qt::RightButton )
    {
        float y = -m_mouseParameters.translationPerPixel.y * delta.y;
        applyTranslation( 0, y, 0, camera );
    }
}
Exemple #2
0
int main(int argc, char *argv[])
{
    qputenv("QT_MESSAGE_PATTERN", "[%{type}] (%{file}:%{line}) - %{message}");

    QSettings::setDefaultFormat(QSettings::NativeFormat);
    QApplication::setApplicationName("Serizer");
    QApplication::setApplicationVersion("0.1");
    QApplication::setOrganizationName("Liomka");
    QApplication::setOrganizationDomain("liomka.users.sourceforge.net");

    QApplication app(argc, argv);

    if (!QUPDUpdater::instance()->isUpdateRequested()) {
        app.setQuitOnLastWindowClosed(false);

        applyTranslation();

        MainWindow *window = new MainWindow;

//        QUPDUpdater::instance()->setParentWidget(window);
//        QUPDUpdater::instance()->setFeedURL("https://sourceforge.net/projects/serizer/files/Serizer.xml/download");
//        QUPDUpdater::instance()->checkForUpdates(false);
    }
    return app.exec();
}
Exemple #3
0
/**
 * mouse handler determines what kind of actions are being performed
 */
void alignMouse(int button, int state, vector mousePos) {
  /* set the sensitivity */
  curSensitivity = GLUT_ACTIVE_CTRL == glutGetModifiers()
      ? fineSensitivity : coarseSensitivity;

  /* choose action based on button */
  switch(button) {
    case GLUT_LEFT_BUTTON:
      /* if we are setting the rotation center, set it and break */
      if(settingRotCenter == TRUE) {
        setRotationCenterV(mousePos);
        if(DEBUG) fprintf(stdout,"current rotation center is (%g,%g)\n",
                          curRotCenter.x, curRotCenter.y);
        settingRotCenter = FALSE;
        break;
      }

      /* left button: translation */
      switch(state) {
        case GLUT_DOWN:
          /* translation start */
          moving = TRUE;
          break;
        case GLUT_UP:
          /* translation end, apply it */
          moving = FALSE;
          applyTranslation(curTransAction);
          curTransAction.x = curTransAction.y = 0;
          break;
      }
      break;
    case GLUT_MIDDLE_BUTTON: /* rotation */
      switch(state) {
        case GLUT_DOWN:
          /* rotation start */
          rotating = TRUE;
          break;
        case GLUT_UP:
          /* rotation end, apply rotation  */
          rotating = FALSE;

          applyRotation(curRotCenter, curRotAngle);

          /* reset the rot angle */
          curRotAngle = 0;
          break;
      }
      break;
  }

  /* store the last positions for the up */
  if(state == GLUT_DOWN) {
    lastPos = mousePos;
  }

  redisplay();
}
Exemple #4
0
/* SImage::applyTranslation
 * Applies a palette translation to the image
 *******************************************************************/
bool SImage::applyTranslation(string tr, Palette8bit* pal)
{
	// Some hardcoded translations from ZDoom
	if (!tr.CmpNoCase("\"doom0\""))			tr = "\"112:127=96:111\"";
	else if (!tr.CmpNoCase("\"doom1\""))	tr = "\"112:127=64:79\"";
	else if (!tr.CmpNoCase("\"doom2\""))	tr = "\"112:127=32:47\"";
	else if (!tr.CmpNoCase("\"doom3\""))	tr = "\"112:127=88:103\"";
	else if (!tr.CmpNoCase("\"doom4\""))	tr = "\"112:127=56:71\"";
	else if (!tr.CmpNoCase("\"doom5\""))	tr = "\"112:127=176:191\"";
	else if (!tr.CmpNoCase("\"doom6\""))	tr = "\"112:127=192:207\"";
	else if (!tr.CmpNoCase("\"heretic0\""))	tr = "\"225:240=114:129\"";
	else if (!tr.CmpNoCase("\"heretic1\""))	tr = "\"225:240=145:160\"";
	else if (!tr.CmpNoCase("\"heretic2\""))	tr = "\"225:240=190:205\"";
	else if (!tr.CmpNoCase("\"heretic3\""))	tr = "\"225:240=67:82\"";
	else if (!tr.CmpNoCase("\"heretic4\""))	tr = "\"225:240=9:24\"";
	else if (!tr.CmpNoCase("\"heretic5\""))	tr = "\"225:240=74:89\"";
	else if (!tr.CmpNoCase("\"heretic6\""))	tr = "\"225:240=150:165\"";
	else if (!tr.CmpNoCase("\"heretic7\""))	tr = "\"225:240=192:207\"";
	else if (!tr.CmpNoCase("\"heretic8\""))	tr = "\"225:240=95:110\"";
	else if (!tr.CmpNoCase("\"strife0\""))	tr = "\"32:63=0:31\", \"128:143=64:79\", \"241:246=224:229\", \"247:251=241:245\"";
	else if (!tr.CmpNoCase("\"strife1\""))	tr = "\"32:63=0:31\", \"128:143=176:191\"";
	else if (!tr.CmpNoCase("\"strife2\""))	tr = "\"32:47=208:223\", \"48:63=208:223\", \"128:143=16:31\"";
	else if (!tr.CmpNoCase("\"strife3\""))	tr = "\"32:47=208:223\", \"48:63=208:223\", \"128:143=48:63\"";
	else if (!tr.CmpNoCase("\"strife4\""))	tr = "\"32:63=0:31\", \"80:95=128:143\", \"128:143=80:95\", \"192:223=160:191\"";
	else if (!tr.CmpNoCase("\"strife5\""))	tr = "\"32:63=0:31\", \"80:95=16:31\", \"128:143=96:111\", \"192:223=32:63\"";
	else if (!tr.CmpNoCase("\"strife6\""))	tr = "\"32:63=0:31\", \"80:95=64:79\", \"128:143=144:159\", \"192=1\", \"193:223=1:31\"";
	// Some more from Eternity
	else if (!tr.CmpNoCase("\"tomato\""))	tr = "\"112:113=171:171\", \"114:114=172:172\", \"115:122=173:187\", \"123:124=188:189\", \"125:126=45:47\", \"127:127=1:1\"";
	else if (!tr.CmpNoCase("\"dirt\""))		tr = "\"112:117=128:133\", \"118:120=135:137\", \"121:123=139:143\", \"124:125=237:239\", \"126:127=1:2\"";
	else if (!tr.CmpNoCase("\"blue\""))		tr = "\"112:121=197:206\", \"122:127=240:245";
	else if (!tr.CmpNoCase("\"gold\""))		tr = "\"112:113=160:160\", \"114:119=161:166\", \"120:123=236:239\", \"124:125=1:2\", \"126:127=7:8\"";
	else if (!tr.CmpNoCase("\"sea\""))		tr = "\"112:112=91:91\", \"113:114=94:95\", \"115:122=152:159\", \"123:126=9:12\", \"127:127=8:8\"";
	else if (!tr.CmpNoCase("\"black\""))	tr = "\"112:112=101:101\", \"113:121=103:111\", \"122:125=5:8\", \"126:127=0:0\"";
	else if (!tr.CmpNoCase("\"purple\""))	tr = "\"112:113=4:4\", \"114:115=170:170\", \"116:125=250:254\", \"126:127=46:46\"";
	else if (!tr.CmpNoCase("\"vomit\""))	tr = "\"112:119=209:216\", \"120:121=218:220\", \"122:124=69:75\", \"125:127=237:239\"";
	else if (!tr.CmpNoCase("\"pink\""))		tr = "\"112:113=16:17\", \"114:117=19:25\", \"118:119=27:28\", \"120:124=30:38\", \"125:126=41:43\", \"127:127=46:46\"";
	else if (!tr.CmpNoCase("\"cream\""))	tr = "\"112:112=4:4\", \"113:118=48:63\", \"119:119=65:65\", \"120:124=68:76\", \"125:126=77:79\", \"127:127=1:1\"";
	else if (!tr.CmpNoCase("\"white\""))	tr = "\"112:112=4:4\", \"113:115=80:82\", \"116:117=84:86\", \"118:120=89:93\", \"121:127=96:108\"";

	Translation trans;
	trans.clear();
	Tokenizer tz;
	tz.openString(tr);
	string token = tz.getToken();
	while (!token.IsEmpty())
	{
		trans.parse(token);
		tz.getToken();
		token = tz.getToken();
	}
	return applyTranslation(&trans, pal);
}
Exemple #5
0
void FPSControls::computeXboxTranslation( XINPUT_GAMEPAD* pGamepad,
    PerspectiveCamera& camera )
{
    int lx = pGamepad->sThumbLX;
    int ly = pGamepad->sThumbLY;

    bool move = false;
    float moveX = 0;
    float moveY = 0;
    float moveZ = 0;

    // left stick: move
    if( std::abs( lx ) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  )
    {
        // stick right --> move right
        moveX = lx * m_xboxGamepadParameters.translationPerTick;
        move = true;
    }
    if( std::abs( ly ) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE )
    {
        // stick up --> move forward
        moveZ = -ly * m_xboxGamepadParameters.translationPerTick;
        move = true;
    }

    // dpad: up/down
    if( pGamepad->wButtons & XINPUT_GAMEPAD_DPAD_UP )
    {
        moveY = 0.01f;
        move = true;
    }
    if( pGamepad->wButtons & XINPUT_GAMEPAD_DPAD_DOWN )
    {
        moveY = -0.01f;
        move = true;
    }

    if( move )
    {
        applyTranslation( moveX, moveY, moveZ, camera );
    }
}
Exemple #6
0
        void RotateHandle::render(Model::RotateHandleHit* hit, Renderer::Vbo& vbo, Renderer::RenderContext& renderContext, float angle) {
            Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
            const float distance = renderContext.camera().distanceTo(position());
            const float factor = prefs.getFloat(Preferences::HandleScalingFactor) * distance;

            const Mat4f matrix = translationMatrix(position()) * scalingMatrix(factor);
            Renderer::ApplyModelMatrix applyTranslation(renderContext.transformation(), matrix);

            glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

            Renderer::SetVboState activateVbo(vbo, Renderer::Vbo::VboActive);
            if (hit != NULL) {
                renderAxis(hit, vbo, renderContext);
                renderRing(hit, vbo, renderContext, angle);
            } else {
                Vec3f xAxis, yAxis, zAxis;
                axes(renderContext.camera().position(), xAxis, yAxis, zAxis);

                Renderer::ActivateShader coloredShader(renderContext.shaderManager(), Renderer::Shaders::ColoredHandleShader);

                Renderer::AxisFigure axisFigure(m_axisLength);
                axisFigure.setAxes(true, true, true);
                axisFigure.setXColor(prefs.getColor(Preferences::XColor));
                axisFigure.setYColor(prefs.getColor(Preferences::YColor));
                axisFigure.setZColor(prefs.getColor(Preferences::ZColor));
                axisFigure.render(vbo, renderContext);

                Renderer::ActivateShader shader(renderContext.shaderManager(), Renderer::Shaders::HandleShader);
                shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f));

                Renderer::RingFigure(Axis::AX, yAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
                Renderer::RingFigure(Axis::AY, xAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
                Renderer::RingFigure(Axis::AZ, xAxis, yAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
            }

            glEnable(GL_CULL_FACE);
            glEnable(GL_DEPTH_TEST);
        }
Exemple #7
0
void FPSControls::handleKeyboard( PerspectiveCamera& camera )
{
#ifdef WIN32
    Vector3f delta;

    if( ( GetAsyncKeyState( 'W' ) & 0x8000 ) != 0 )
    {
        delta.z -= m_keyboardParameters.translationPerKeyPress;
    }

    if( ( GetAsyncKeyState( 'S' ) & 0x8000 ) != 0 )
    {
        delta.z += m_keyboardParameters.translationPerKeyPress;
    }

    if( ( GetAsyncKeyState( 'A' ) & 0x8000 ) != 0 )
    {
        delta.x -= m_keyboardParameters.translationPerKeyPress;
    }

    if( ( GetAsyncKeyState( 'D' ) & 0x8000 ) != 0 )
    {
        delta.x += m_keyboardParameters.translationPerKeyPress;
    }

    if( ( GetAsyncKeyState( 'R' ) & 0x8000 ) != 0 )
    {
        delta.y += m_keyboardParameters.translationPerKeyPress;
    }

    if( ( GetAsyncKeyState( 'F' ) & 0x8000 ) != 0 )
    {
        delta.y -= m_keyboardParameters.translationPerKeyPress;
    }

    applyTranslation( delta.x, delta.y, delta.z, camera );
#endif
}
Exemple #8
0
/**
 * align actions
 */
void alignAction(int action) {
  vector actionVector;

  switch(action) {
    case 'a': /* turn animation on or off */
      if(TRUE == (animate = !animate)) {
        glutTimerFunc(framePeriod, alignTimerEvent, 0);
      }
      else {
        displayImg = 1;
      }
      redisplay();
      break;
    case 'c': /* set the rotation center */
      settingRotCenter = TRUE;
      break;
    case 'y': /* speed up the flickering */
      switchPeriod -= switchPerIncrement;
      if(switchPeriod < 0) switchPeriod = 0;
      break;
    case 't': /* slow down the flickering */
      switchPeriod += switchPerIncrement;
      if(switchPeriod > MAX_SWITCH_PERIOD) switchPeriod = MAX_SWITCH_PERIOD;
      break;
    case 'e': /* toggle previous slice tack display */
      showPrevTacks = !showPrevTacks;
      redisplay();
      break;
    case 'w': /* toggle curent slice tack display */
      showCurTacks = !showCurTacks;
      redisplay();
      break;
    case 'Q':
      displayImg = !displayImg;
      redisplay();
      break;
    case 'p': /* print the action list */
    case 'P':
      fprintf(stdout,"---------------------------------------\n");
      dumpActionList(actions);
      fprintf(stdout,"---------------------------------------\n");
      break;
      /*   case 'r': /\* reset the position of the reference image to unmoved *\/ */
      /*     resetImage(); */
      /*     break; */
      /*   case 'u': /\* undo the last action *\/ */
      /*   case 'U': */
      /*     undoLastAction(); */
      /*     break; */
      /* fine direction stuff using numeric keypad */
    case '1': /* down and left */
      actionVector.x = -transIncrX;
      actionVector.y = -transIncrY;
      applyTranslation(actionVector);
      break;
    case '2': /* down */
      actionVector.x = 0;
      actionVector.y = -transIncrY;
      applyTranslation(actionVector);
      break;
    case '3': /* down and right */
      actionVector.x = transIncrX;
      actionVector.y = -transIncrY;
      applyTranslation(actionVector);
      break;
    case '4': /* left */
      actionVector.x = -transIncrX;
      actionVector.y = 0;
      applyTranslation(actionVector);
      break;
    case '6': /* right */
      actionVector.x = transIncrX;
      actionVector.y = 0;
      applyTranslation(actionVector);
      break;
    case '7': /* up and left  */
      actionVector.x = -transIncrX;
      actionVector.y = transIncrY;
      applyTranslation(actionVector);
      break;
    case '8': /* up */
      actionVector.x = 0;
      actionVector.y = transIncrY;
      applyTranslation(actionVector);
      break;
    case '9': /* up and right */
      actionVector.x = transIncrX;
      actionVector.y = transIncrY;
      applyTranslation(actionVector);
      break;
    case '=': /* grow the slice */
    case '+':
      actionVector.x = scaleIncrX;
      actionVector.y = scaleIncrY;
      applyScale(actionVector);
      break;
    case '-': /* shrink the slice */
    case '_':
      actionVector.x = -scaleIncrX;
      actionVector.y = -scaleIncrY;
      applyScale(actionVector);
      break;
    default:
      break;
  }
}
void Transformation::applyTransformation(SDL_Point &p) {
	applyTranslation(p);
	applyScale(p);
}