// Updates the object. void SceneObject::Update( float elapsed, bool addVelocity ) { // Calculate the friction for this update. float friction = 1.0f - m_friction * elapsed; // Move the object. m_velocity *= friction; // Check if there is velecity to to be added into the translation if( addVelocity == true ) { D3DXVECTOR3 velocity = m_velocity * elapsed; AddTranslation( velocity.x, velocity.y, velocity.z ); } // Spin the object. m_spin *= friction; D3DXVECTOR3 spin = m_spin * elapsed; AddRotation( spin.x, spin.y, spin.z ); // Update the object's world matrix. D3DXMatrixMultiply( &m_worldMatrix, &m_rotationMatrix, &m_translationMatrix ); // Create a view matrix for the object. D3DXMatrixInverse( &m_viewMatrix, NULL, &m_worldMatrix ); // Update the object's forward vector. m_forward.x = (float)sin( m_rotation.y ); m_forward.y = (float)-tan( m_rotation.x ); m_forward.z = (float)cos( m_rotation.y ); D3DXVec3Normalize( &m_forward, &m_forward ); // Update the object's right vector. m_right.x = (float)cos( m_rotation.y ); m_right.y = (float)tan( m_rotation.z ); m_right.z = (float)-sin( m_rotation.y ); D3DXVec3Normalize( &m_right, &m_right ); // Update the object's bounding volume using the translation matrix only. // This will maintain an axis aligned bounding box around the object in // world space rather than the object's local space. RepositionBoundVolume( &m_translationMatrix ); }
TranslationHandler::TranslationHandler(QObject *parent) : QObject(parent), mCurrentLanguage("en"), mTranslator(NULL) { // Add our available languages // Keep this list sorted AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Chinese (Simplified)"), "cppcheck_zh_CN"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Dutch"), "cppcheck_nl"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "English"), "cppcheck_en"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Finnish"), "cppcheck_fi"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "French"), "cppcheck_fr"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "German"), "cppcheck_de"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Italian"), "cppcheck_it"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Japanese"), "cppcheck_ja"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Korean"), "cppcheck_ko"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Russian"), "cppcheck_ru"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Serbian"), "cppcheck_sr"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Spanish"), "cppcheck_es"); AddTranslation(QT_TRANSLATE_NOOP("MainWindow", "Swedish"), "cppcheck_sv"); }
/** ** Load a .po file */ void LoadPO(const char *file) { FILE *fd; char buf[4096]; enum { MSGNONE, MSGID, MSGSTR } state; char msgid[16 * 1024]; char msgstr[16 * 1024]; char *s; char *currmsg = NULL; char fullfile[1024]; if (!file || !*file) { return; } LibraryFileName(file, fullfile, sizeof(fullfile)); fd = fopen(fullfile, "rb"); if (!fd) { fprintf(stderr, "Could not open file: %s\n", file); return; } state = MSGNONE; msgid[0] = msgstr[0] = '\0'; // skip 0xEF utf8 intro if found char c = fgetc(fd); if (c == (char)0xEF) { fgetc(fd); fgetc(fd); } else { rewind(fd); } while (fgets(buf, sizeof(buf), fd)) { // Comment if (buf[0] == '#') { continue; } s = buf; // msgid or msgstr if (!strncmp(s, "msgid ", 6)) { if (state == MSGSTR) { *currmsg = '\0'; if (*msgid != '\0') { AddTranslation(msgid, msgstr); } } state = MSGID; currmsg = msgid; *currmsg = '\0'; s += 6; while (*s == ' ') ++s; } else if (!strncmp(s, "msgstr ", 7)) { if (state == MSGID) { *currmsg = '\0'; } state = MSGSTR; currmsg = msgstr; *currmsg = '\0'; s += 7; while (*s == ' ') ++s; } // String if (*s == '"') { ++s; while (*s && *s != '"') { if (*s == '\\') { ++s; if (*s) { if (*s == 'n') { *currmsg++ = '\n'; } else if (*s == 't') { *currmsg++ = '\t'; } else if (*s == 'r') { *currmsg++ = '\r'; } else if (*s == '"') { *currmsg++ = '"'; } else if (*s == '\\') { *currmsg++ = '\\'; } else { fprintf(stderr, "Invalid escape character: %c\n", *s); } ++s; } else { fprintf(stderr, "Unterminated string\n"); } } else { *currmsg++ = *s++; } } continue; } } if (state == MSGSTR) { *currmsg = '\0'; AddTranslation(msgid, msgstr); } fclose(fd); }