AnimSprite::AnimSprite(const char* a_cpTexture, GLFWwindow* window) { GameWindow = window; m_dElapsedTime = 0; m_v3Position = Vector3(g_gl_width/2, g_gl_height/2, 0); LoadVertShader("./resources/VertexShader.glsl"); LoadFragShader("./resources/FragmentShader.glsl"); LinkShaders(); GLint uvAttrib = glGetAttribLocation(m_ShaderProgram, "texcoord"); glEnableVertexAttribArray(uvAttrib); matrix_location = glGetUniformLocation(m_ShaderProgram, "matrix"); LoadSlices(a_cpTexture); LoadAnimations(m_atlas.sAnimations.c_str()); LoadTexture(m_atlas.sSheet.c_str()); m_dFrameDuration = (1.0/5.0); m_sCurrentAnimation = "move N"; m_sCurrentSlice = "move N 0"; iCurrentFrame = 0; iLoopMarker = 0; currentCycle = LOOP; m_texSize = m_atlas.v2Size; SetSlice(); UVSetup(); }
void AnimSprite::SetAnimation(std::string a_sAnimation, AnimCycle cycle, int frame = 0) { m_sCurrentAnimation = a_sAnimation; iCurrentFrame = 0; iLoopMarker = frame; iPlayDirection = 1; currentCycle = cycle; switch (cycle) { case ONCE: break; case LOOP: iLoopMarker = 0; break; case PINGPONG: break; case REVERSE: iCurrentFrame = m_mAnimations[m_sCurrentAnimation].size(); iLoopMarker = iCurrentFrame; break; case RANDOM: break; case SINGLE: break; default: SetAnimation(a_sAnimation, cycle); break; } m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; SetSlice(); UVSetup(); }
void mitk::BaseRenderer::SetGeometrySlice(const itk::EventObject & geometrySliceEvent) { const SliceNavigationController::GeometrySliceEvent* sliceEvent = dynamic_cast<const SliceNavigationController::GeometrySliceEvent *>(&geometrySliceEvent); assert(sliceEvent!=NULL); SetSlice(sliceEvent->GetPos()); }
void AnimSprite::PlayAnimation() { m_dElapsedTime += getDeltaTime(); // if the elapsed time is greater than desired frame duration: if (m_dElapsedTime > m_dFrameDuration) { m_dElapsedTime = 0; switch(currentCycle) { //case ONCE, if not at the end of the animation, advance one frame case ONCE: if (m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame] != m_mAnimations.at(m_sCurrentAnimation).back()) { iCurrentFrame++; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } break; //case LOOP, if the animation is at last frame, change frame to "loop marker" frame case LOOP: if (m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame] == m_mAnimations.at(m_sCurrentAnimation).back()) { iCurrentFrame = iLoopMarker; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } else { iCurrentFrame++; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } break; case PINGPONG: // if at the end of animation, change direction if (m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame] == m_mAnimations.at(m_sCurrentAnimation).back()) { iPlayDirection = -1; iCurrentFrame += iPlayDirection; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } // if at the beginning, change direction else if (m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame] == m_mAnimations.at(m_sCurrentAnimation).front()) { iPlayDirection = 1; iCurrentFrame += iPlayDirection; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } else { iCurrentFrame += iPlayDirection; m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame]; } break; } SetSlice(); UVSetup(); } }
// ################################################################# // void DfiInfo::ReadDfiFile(string fname) { TextParser tpCntl; string str; string label,label_base,label_leaf; int ct; REAL_TYPE ct2; int nnode=0; //入力ファイルをセット int ierror = tpCntl.read(fname); if ( ierror ) { Hostonly_ stamped_printf("\tinput file not found '%s'\n",fname.c_str()); Exit(0); } //FileInfo //Prefix //label = "/DistributedFileInfo/Prefix"; label = "/FileInfo/Prefix"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } Prefix=str; //FileFormat //label = "/DistributedFileInfo/FileFormat"; label = "/FileInfo/FileFormat"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } FileFormat=str; //GuideCell //label = "/DistributedFileInfo/GuideCell"; label = "/FileInfo/GuideCell"; if ( !(tpCntl.getInspectedValue(label, ct )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { GuideCell = ct; } //DataType label = "/FileInfo/DataType"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } DataType=str; //Endian label = "/FileInfo/Endian"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } Endian=str; //ArrayShape label = "/FileInfo/ArrayShape"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } ArrayShape=str; //Component label = "/FileInfo/Component"; if ( !(tpCntl.getInspectedValue(label, ct )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { Component = ct; } //Unit //Length label = "/Unit/Length"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } Length=str; //L0 label = "/Unit/L0"; if ( !(tpCntl.getInspectedValue(label, ct2 )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { L0 = ct2; } //Velocity label = "/Unit/Velocity"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } Velocity=str; //V0 label = "/Unit/V0"; if ( !(tpCntl.getInspectedValue(label, ct2 )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { V0 = ct2; } //Length label = "/Unit/Pressure"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } Pressure=str; //P0 label = "/Unit/P0"; if ( !(tpCntl.getInspectedValue(label, ct2 )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { P0 = ct2; } //DiffPrs label = "/Unit/DiffPrs"; if ( !(tpCntl.getInspectedValue(label, ct2 )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } else { DiffPrs = ct2; } //FilePath label = "/FilePath/Process"; if ( !(tpCntl.getInspectedValue(label, str )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } dfi_proc=str; //read process ReadDfiProc(dfi_proc); //TimeSlice nnode=0; label_base = "/TimeSlice/Slice"; if ( tpCntl.chkNode(label_base) ) //nodeがあれば { nnode = tpCntl.countLabels(label_base); } label_base = "/TimeSlice"; for (int i=0; i<nnode; i++) { if ( !(tpCntl.getNodeStr(label_base, i+1, str)) ) { printf("\tParsing error : No Elem name\n"); Exit(0); } if( strcasecmp(str.substr(0,5).c_str(), "Slice") ) continue; //step label=label_base+"/"+str+"/Step"; if ( !(tpCntl.getInspectedValue(label, ct )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } //time label=label_base+"/"+str+"/Time"; if ( !(tpCntl.getInspectedValue(label, ct2 )) ) { Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n",label.c_str()); Exit(0); } SetSlice(ct,ct2); } //TextParserの破棄 tpCntl.remove(); //内部変数の計算 SetValue(); #if 0 cout << endl; cout << endl; //for(int i=0;i<ndfi;i++){ cout << "" << endl; cout << "Prefix = " << this->Prefix << endl; //cout << "RankIDinMPIworld = " << this->RankID_in_MPIworld << endl; //cout << "GroupIDinMPIworld = " << this->GroupID_in_MPIworld << endl; cout << "NumberOfRankIn = " << this->NumberOfRank << endl; cout << "NumberOfGroup = " << this->NumberOfGroup << endl; cout << "GlobalOrigin[0] = " << this->Global_Origin[0] << endl; cout << "GlobalOrigin[1] = " << this->Global_Origin[1] << endl; cout << "GlobalOrigin[2] = " << this->Global_Origin[2] << endl; cout << "GlobalRegion[0] = " << this->Global_Region[0] << endl; cout << "GlobalRegion[1] = " << this->Global_Region[1] << endl; cout << "GlobalRegion[2] = " << this->Global_Region[2] << endl; cout << "GlobalVoxel[0] = " << this->Global_Voxel[0] << endl; cout << "GlobalVoxel[1] = " << this->Global_Voxel[1] << endl; cout << "GlobalVoxel[2] = " << this->Global_Voxel[2] << endl; cout << "GlobalDivision[0] = " << this->Global_Division[0] << endl; cout << "GlobalDivision[1] = " << this->Global_Division[1] << endl; cout << "GlobalDivision[2] = " << this->Global_Division[2] << endl; cout << "FileFormat = " << this->FileFormat << endl; cout << "GuideCell = " << this->GuideCell << endl; cout << "" << endl; cout << "NodeInfoSize = " << this->NodeInfoSize << endl; for(int j=0; j< this->NodeInfoSize; j++ ) { cout << "" << endl; cout << "Node[" << j << "].RankID = " << this->Node[j].RankID << endl; cout << "Node[" << j << "].HostName = " << this->Node[j].HostName << endl; cout << "Node[" << j << "].VoxelSize[0] = " << this->Node[j].VoxelSize[0] << endl; cout << "Node[" << j << "].VoxelSize[1] = " << this->Node[j].VoxelSize[1] << endl; cout << "Node[" << j << "].VoxelSize[2] = " << this->Node[j].VoxelSize[2] << endl; cout << "Node[" << j << "].HeadIndex[0] = " << this->Node[j].HeadIndex[0] << endl; cout << "Node[" << j << "].HeadIndex[1] = " << this->Node[j].HeadIndex[1] << endl; cout << "Node[" << j << "].HeadIndex[2] = " << this->Node[j].HeadIndex[2] << endl; cout << "Node[" << j << "].TailIndex[0] = " << this->Node[j].TailIndex[0] << endl; cout << "Node[" << j << "].TailIndex[1] = " << this->Node[j].TailIndex[1] << endl; cout << "Node[" << j << "].TailIndex[2] = " << this->Node[j].TailIndex[2] << endl; cout << "Node[" << j << "].IJK = " << this->Node[j].IJK << endl; cout << "Node[" << j << "].IJK_JK = " << this->Node[j].IJK_JK << endl; cout << "Node[" << j << "].IJK_K = " << this->Node[j].IJK_K << endl; } cout << "" << endl; //cout << "step.size() = " << this->step.size() << endl; //for(int j=0; j< this->step.size(); j++ ) { // cout << "step[" << j << "] = " << this->step[j] << endl; //} cout << "Sc.size() = " << this->Sc.size() << endl; for(int j=0; j< this->Sc.size(); j++ ) { cout << "step[" << j << "] = " << this->Sc[j]->step << endl; cout << "time[" << j << "] = " << this->Sc[j]->time << endl; } cout << "" << endl; cout << "index_y.size() = " << this->index_y.size() << endl; for(int j=0; j< this->index_y.size(); j++ ) { cout << "index_y[" << j << "] = " << this->index_y[j] << endl; } cout << "" << endl; cout << "index_z.size() = " << this->index_z.size() << endl; for(int j=0; j< this->index_z.size(); j++ ) { cout << "index_z[" << j << "] = " << this->index_z[j] << endl; } //} cout << endl; cout << endl; //Exit(0); #endif }
void nraApplicationModel::MessageDispatcher(nraWeakPointer<CReconItem> ReconItem) { nraSharedPointer<CUIMessage> UIMessage; CUIAddMark* pAddMark; CUIDestroyMark* pDestroyMark; CUIMoveMark* pMoveMark; CUISetLabel* pSetLabel; CUISetSlice* pSetSlice; CUISetSlider* pSetSlider; CUISetStack* pSetStack; CUIDisable* pDisable; //queue< nraSharedPointer<CUIMessage> > MessageQueue; m_boolSemaphore = false; while(!(*ReconItem).MessageQueue.empty()) { UIMessage = (*ReconItem).MessageQueue.front(); (*ReconItem).MessageQueue.pop(); pAddMark = dynamic_cast<CUIAddMark*>(UIMessage.GetPointer()); if(pAddMark) { emit AddMark(pAddMark->GetTag(), pAddMark->GetType(), pAddMark->GetAccLabel(), pAddMark->GetX(), pAddMark->GetY()); continue; } pDestroyMark = dynamic_cast<CUIDestroyMark*>(UIMessage.GetPointer()); if(pDestroyMark) { emit DestroyMark(pDestroyMark->GetTag()); continue; } pMoveMark = dynamic_cast<CUIMoveMark*>(UIMessage.GetPointer()); if(pMoveMark) { emit MoveMark(pMoveMark->GetTag(), pMoveMark->GetX(), pMoveMark->GetY()); continue; } pSetLabel = dynamic_cast<CUISetLabel*>(UIMessage.GetPointer()); if(pSetLabel) { emit SetLabel(pSetLabel->GetTag(), pSetLabel->GetLabel()); continue; } pSetSlice = dynamic_cast<CUISetSlice*>(UIMessage.GetPointer()); if(pSetSlice) { emit SetSlice(pSetSlice->GetSlice()); continue; } pSetSlider = dynamic_cast<CUISetSlider*>(UIMessage.GetPointer()); if(pSetSlider) { emit SetSlider(pSetSlider->GetMin(),pSetSlider->GetMax(),pSetSlider->GetVal()); continue; } pSetStack = dynamic_cast<CUISetStack*>(UIMessage.GetPointer()); if(pSetStack) { emit SetStack(pSetStack->GetStack()); continue; } pDisable = dynamic_cast<CUIDisable*>(UIMessage.GetPointer()); if(pDisable) { emit Disable(); continue; } } m_boolSemaphore = true; }