void setEyePosition(int curFrame, int numFrames, int fps, void* userData) { OSG::Navigator* nav = G.mgr->getNavigator(); OSG::Vec3f *dir = static_cast<OSG::Vec3f*>(userData); float t = curFrame / (float)fps; OSG::Vec3f newAbsolutePosition = calcTranslation(t, *dir); OSG::Vec3f lastAbsolutePosition(0,0,0); if(curFrame - 1 > 0) { t = (curFrame - 1) / (float)fps; lastAbsolutePosition = calcTranslation(t, *dir); } OSG::Vec3f diffPosition = newAbsolutePosition - lastAbsolutePosition; OSG::Pnt3f newPosition = nav->getFrom().subZero() + diffPosition; setEyePositionHelper(newPosition, nav->getAt(), nav->getUp()); }
void GameObject::TranslateTo(D3DXVECTOR3& p) { if(tObject == MESH){ myMesh.Position = p; } else { myVertex.Position = p; } calcTranslation(); for(auto it = children.begin(); it != children.end(); it++) (*it)->TranslateTo(p); }
void moveTo(int curFrame, int numFrames, int fps, void* userData) { OSG::Vec3f* dir = static_cast<OSG::Vec3f*>(userData); float t = curFrame / (float)fps; OSG::Vec3f newAbsolutePosition = calcTranslation(t, *dir); OSG::Vec3f lastAbsolutePosition(0,0,0); if(curFrame - 1 > 0) { t = (curFrame - 1) / (float)fps; lastAbsolutePosition = calcTranslation(t, *dir); } OSG::Matrix& mat = G.figure1TransC->editMatrix(); OSG::Vec3f curPosition = getCurrentTranslation(mat); OSG::Vec3f diffPosition = newAbsolutePosition - lastAbsolutePosition; OSG::Vec3f newPosition = curPosition + diffPosition; mat.setIdentity(); mat.setTranslate(newPosition); G.figure1TransC->setMatrix(mat); }
void GameObject::TranslateTo(float x, float y, float z) { if(tObject == MESH){ myMesh.Position.x = x; myMesh.Position.y = y; myMesh.Position.z = z; } else { myVertex.Position.x = x; myVertex.Position.y = y; myVertex.Position.z = z; } calcTranslation(); for(auto it = children.begin(); it != children.end(); it++) (*it)->TranslateTo(x,y,z); }
void GameObject::Translate(float x, float y, float z) { //tObject==MESH ? position = &myMesh.Position : position = &myVertex.Position; if(tObject == MESH){ myMesh.Position.x += x; myMesh.Position.y += y; myMesh.Position.z += z; } else { myVertex.Position.x += x; myVertex.Position.y += y; myVertex.Position.z += z; } calcTranslation(); for(auto it = children.begin(); it != children.end(); it++) (*it)->Translate(x,y,z); }
GameObject::GameObject(Mesh* m, float& posX, float& posY, float& posZ, float& scale, float& rotX, float& rotY, float& rotZ, float dur,PositionType tPos) : //position(NULL), //color(&myMesh.Color), tObject(MESH), tPosition(tPos), velocity(0,0,0), lookDirection(1,0,0), mMeshOirentation(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), duration(dur), parent(NULL) { myMesh.MeshToRender = m; myMesh.Position = D3DXVECTOR3(posX, posY, posZ);; //position = &myMesh.Position; myMesh.Color = D3DXCOLOR(0,0,0,0); //color = &myMesh.Color; myMesh.Scale = D3DXVECTOR3(scale, scale, scale); calcScale(); calcTranslation(); RotateTo(rotX, rotY, rotZ); }
/*********************************************************** Die Übersetztung begint mit dem setzen der Startmarke und endet auch mit ihr: # W_1 W_2 W_3 ... W_N # ***********************************************************/ vector<int> translater::searchBestScentences(vector<int> vSentence) { int iMarker = m_pDictB->getNumWords(); int iLength = vSentence.size(); int iLastWord = 0; int iTemp; int iCount = 0; float fW; list<pair<vector<int>, float> > hypotheses; list<pair<vector<int>, float> >::iterator Iterartor; vector<pair<int, float> > vWordSet; pair<vector<int>, float> hypothese; vector<int> vTemp; // Die Wortmenge Initialisieren for(int i = 0; i < vSentence.size(); i++) { iTemp = vSentence[i]; list<pair<int, float> >::iterator it; list<pair<int, float> > li = m_pEMDict->getEMspBestnWords(iTemp, 3); for(it = li.begin(); it != li.end(); it++) { pair<int, float> word = *it; word.second = log(word.second); vWordSet.push_back(word); } vWordSet.push_back(make_pair(iMarker, 1.0)); } // Initiale beste Hypothese setzten vTemp.push_back(iMarker); hypothese = make_pair(vTemp, 1.0f); do { for(int i = 0; i < vWordSet.size(); i++) { // Die Menge der Hypothesen wird nun erweitert, // indem die Acktuelle Hypothese um jedes Wort erweitert wird vTemp = hypothese.first; iTemp = vWordSet[i].first; vTemp.push_back(iTemp); hypotheses.push_back(make_pair(vTemp, calcTranslation(vTemp, vSentence))); // Hypothesen der Wahrscheinlickeit nach Sortieren hypotheses.sort(compareSecond()); while(hypotheses.size() >= g_iStackSize) hypotheses.pop_back(); } Iterartor = hypotheses.begin(); hypothese = *Iterartor; iCount++; /* //hypotheses.compareThird(); for(Iterartor = hypotheses.begin(); Iterartor!=hypotheses.end(); Iterartor++) { hypothese = *Iterartor; for(int a = 0; a < hypothese.first.size(); a++) { printf("%s ", m_pDictA->getWord(hypothese.first[a]).c_str()); } printf("%.3f\n", hypothese.second); }*/ // Und das Letzte Element aushängen vTemp = hypothese.first; iLastWord = vTemp[vTemp.size()-1]; hypotheses.pop_front(); } while((iLastWord != iMarker) && (iCount < g_iTranslateSteps)); return vTemp; }