bool CModelMD3::UpdateLowerModel() { int Animation = GetLegsCurrentAnimation(); if(Animation > 5) Animation += 7; bool loop = false; if(Animation == BOTH_DEATH1) { if(UpdateModel(&m_Lower,loop)) SetLegsAnimation(BOTH_DEAD1); return true; } if(Animation == LEGS_JUMPB) { if(UpdateModel(&m_Lower,loop)) SetLegsAnimation(LEGS_LAND); return true; } if(Animation == LEGS_LAND) { if(UpdateModel(&m_Lower,loop)) SetLegsAnimation(LEGS_IDLE); return true; } else loop = true; return UpdateModel(&m_Lower,loop); }
void *HuffmanCoDec::Decompress( const void *pCompressedBuffer, int iCompressedBufSize, void *pUncompressedBuf, int *piUncompressedBufSize, FNCOMPSTAT fnStat, DWORD dwData ) { ASSERT( pCompressedBuffer ); ASSERT( 0 < iCompressedBufSize ); ASSERT( piUncompressedBufSize ); bitBuffer.AttachForReading( pCompressedBuffer, iCompressedBufSize ); *piUncompressedBufSize = ( int )bitBuffer.GetBits( 32 ); if ( pUncompressedBuf == NULL ) pUncompressedBuf = malloc ( *piUncompressedBufSize ); if ( pUncompressedBuf == NULL ) throw( "Not enough memory" ); BYTE *pBufPos = ( BYTE * )pUncompressedBuf; InitializeTree(); for( ;; ) { int nextSymbol = DecodeSymbol(); if ( nextSymbol == iEND_OF_STREAM ) break; *pBufPos++ = ( BYTE )nextSymbol; UpdateModel( nextSymbol ); } return pUncompressedBuf; }
void idGLDrawableView::setMedia(const char *name) { float ratio = 1; if (name && *name) { material = declManager->FindMaterial(name); } else { material = NULL; } if ( material->GetNumStages() == 0 ) { material = declManager->FindMaterial( "_default" ); } if ( material->GetStage(0)->texture.image ) { ratio = (float)((float)material->GetImageWidth() / (float)material->GetImageHeight()); } if ( objectId == -1 ) { // Don't change a custom model } else if ( ratio == 1 ) { objectId = 0; } else if ( ratio == 2 ) { objectId = 1; } else if ( ratio == 4 ) { objectId = 2; } else if ( ratio == 0.5 ) { objectId = 3; } else if ( ratio == 0.25 ) { objectId = 4; } UpdateModel(); }
// called by main thread only void UpdateRecords() { arr_1t<LogRecord> _aTemps; m_tLock.lock(); _aTemps.swap(m_aRecordsTemp); m_tLock.unlock(); if(_aTemps.empty()) return; int ns=(m_nWrPos+m_nCapacity-m_nRdPos)%m_nCapacity; int nd=ns+(int)_aTemps.size()-m_nMaxSize; if(nd>0) { m_nRdPos+=nd; } for(size_t i=0;i<_aTemps.size();i++) { m_aRecords[m_nWrPos++%m_nCapacity]=_aTemps[i]; } UpdateModel(); }
// called by main thread only void ClearRecords() { LockGuard<AtomicMutex> lock(m_tLock); m_aRecordsTemp.clear(); m_nRdPos=m_nWrPos; UpdateModel(); }
void WorldSimulation::AdvanceFake(Real dt) { bool oldFake = fakeSimulation; fakeSimulation = true; for(size_t i=0;i<controlSimulators.size();i++) controlSimulators[i].Step(dt,this); for(size_t i=0;i<hooks.size();i++) hooks[i]->Step(dt); time += dt; UpdateModel(); fakeSimulation = oldFake; //kill any autokill hooks at end of timestep bool anyKilled = false; vector<SmartPointer<WorldSimulationHook> > newhooks; for(size_t i=0;i<hooks.size();i++) { if(hooks[i]->autokill) { if(!anyKilled) newhooks.insert(newhooks.end(),hooks.begin(),hooks.begin()+i); else anyKilled = true; } else if(anyKilled) newhooks.push_back(hooks[i]); } if(anyKilled) swap(hooks,newhooks); }
// Methods void UIElement::Update(){ if (bResetActivation) bActivated = false; // Animation timers if (bUpdateMe || mifTimers.size() > 0){ // Dont even ask... its crazy magic for (auto child : mifTimers){ mifTimers[child.first].first.first -= (float)App::GetDeltaTime(); (*child.second.second)(this,child.second.first.first,child.second.first.second); if (child.second.first.first <= 0.0f){ (*child.second.second)(this,0.0f,child.second.first.second); mifTimers.erase(child.first); return; } } UpdateModel(); } // Animation count reset if (uiAnimationValue >= 0 && mifTimers.size() == 0){ uiAnimationValue = 0; } // Update children for (auto child : mcuiElements){ if (child.second != nullptr) child.second->Update(); } }
void Game::Go() { UpdateModel(); gfx.BeginFrame(); ComposeFrame(); gfx.EndFrame(); }
QRssDisplayModel::QRssDisplayModel(QTreeView* pItemsView, QObject* parrent, bool autoUpdate) : QAbstractItemModel(parrent), m_pRssManager(RssManager::getInstance()), m_pTorrentDownloader(FileDownloader::getInstance()) { m_pItemsView = pItemsView; m_pUdpateTimer = new QTimer(this); setupFeedMenu(); setupItemMenu(); UpdateModel(); connect(m_pRssManager.get(), SIGNAL(FeedChanged(QUuid)), this, SLOT(UpdateModel())); connect(m_pTorrentDownloader.get(), SIGNAL(DownloadReady(QUrl, QTemporaryFile*)), SLOT(onTorrentDownloaded(QUrl, QTemporaryFile*))); connect(m_pUdpateTimer, SIGNAL(timeout()), this, SLOT(UpdateVisibleData())); if (autoUpdate) { m_pUdpateTimer->start(1000); } }
void amyWidgetTableDelegate::ConnectWidget2ModelUpdate(QWidget* w,const char* signal,const QModelIndex& index)const { m_Wigdet2Index.insert(w,index); connect(w,signal,this,SLOT(UpdateModel())); //QAbstractItemModel* m=(QAbstractItemModel*)index.model(); //connect(m,SIGNAL(dataChanged())) }
void Transform::MoveTowards(glm::vec3& to, float amount) { glm::vec3 moveto = glm::normalize(to); moveto *= amount; m_Position *= glm::translate(glm::mat4(), moveto); m_PositionVector = glm::vec3(m_Position[3][0], m_Position[3][1], m_Position[3][2]); UpdateModel(); }
void WorldSimulation::Advance(Real dt) { if(fakeSimulation) { AdvanceFake(dt); return; } for(ContactFeedbackMap::iterator i=contactFeedback.begin();i!=contactFeedback.end();i++) { Reset(i->second); } Timer timer; Real timeLeft=dt; Real accumTime=0; int numSteps = 0; //printf("Advance %g -> %g\n",time,time+dt); while(timeLeft > 0.0) { Real step = Min(timeLeft,simStep); for(size_t i=0;i<controlSimulators.size();i++) controlSimulators[i].Step(step); for(size_t i=0;i<hooks.size();i++) hooks[i]->Step(step); odesim.Step(step); accumTime += step; timeLeft -= step; numSteps++; //accumulate contact information for(ContactFeedbackMap::iterator i=contactFeedback.begin();i!=contactFeedback.end();i++) { if(i->second.accum || i->second.accumFull) { ODEContactList* list = odesim.GetContactFeedback(i->first.first,i->first.second); assert(list); if(i->second.accum) { if(list->forces.empty()) i->second.hadSeparation = true; else i->second.hadContact = true; for(size_t k=0;k<list->forces.size();k++) { i->second.meanForce += list->forces[k]; i->second.meanPoint += list->points[k].x*(1.0/list->forces.size()); } } if(i->second.accumFull) { i->second.times.push_back(time + accumTime); i->second.contactLists.push_back(*list); } } } } time += dt; UpdateModel(); //convert sums to means for(ContactFeedbackMap::iterator i=contactFeedback.begin();i!=contactFeedback.end();i++) { if(i->second.accum) { i->second.meanForce /= numSteps; i->second.meanPoint /= numSteps; } } //printf("WorldSimulation: Sim step %gs, real step %gs\n",dt,timer.ElapsedTime()); }
void idGLDrawableView::setLocalParm( int parmNum, float value ) { if ( parmNum < 0 || parmNum >= MAX_ENTITY_SHADER_PARMS ) { return; } worldEntity.shaderParms[ parmNum ] = value; UpdateModel(); }
bool WorldSimulation::ReadState(File& f) { #if TEST_READ_WRITE TestReadWriteState(odesim,"odesim"); for(size_t i=0;i<controlSimulators.size();i++) TestReadWriteState(controlSimulators[i],"controller"); for(size_t i=0;i<hooks.size();i++) TestReadWriteState(*hooks[i],"hook"); #endif READ_FILE_DEBUG(f,time,"WorldSimulation::ReadState"); if(!odesim.ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: ODE sim failed to read\n"); return false; } //controlSimulators will read the robotControllers' states for(size_t i=0;i<controlSimulators.size();i++) { if(!controlSimulators[i].ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: Control simulator %d failed to read\n",i); return false; } } for(size_t i=0;i<hooks.size();i++) { if(!hooks[i]->ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: Hook %d failed to read\n",i); return false; } } int n; READ_FILE_DEBUG(f,n,"WorldSimulation::ReadState: reading number of contactFeadback items"); if(n < 0) { fprintf(stderr,"Invalid number %d of contactFeedback items\n",n); return false; } contactFeedback.clear(); for(int i=0;i<n;i++) { pair<ODEObjectID,ODEObjectID> key; ContactFeedbackInfo info; if(!ReadFile(f,key.first)) { fprintf(stderr,"Unable to read contact feedback %d object 1\n",i); return false; } if(!ReadFile(f,key.second)) { fprintf(stderr,"Unable to read contact feedback %d object 2\n",i); return false; } if(!ReadFile(f,info)) { fprintf(stderr,"Unable to read contact feedback %d info\n",i); return false; } contactFeedback[key] = info; } UpdateModel(); return true; }
void WorldSimulation::AdvanceFake(Real dt) { bool oldFake = fakeSimulation; fakeSimulation = true; for(size_t i=0;i<controlSimulators.size();i++) controlSimulators[i].Step(dt); for(size_t i=0;i<hooks.size();i++) hooks[i]->Step(dt); time += dt; UpdateModel(); fakeSimulation = oldFake; }
void idGLDrawableView::setCustomModel( const idStr modelName ) { if ( modelName.Length() ) { objectId = -1; } else { objectId = 0; } customModelName = modelName; UpdateModel(); }
bool CModelMD3::UpdateUpperModel(int weapon) { int Animation = GetTorsoCurrentAnimation(); bool loop = false; if(Animation == BOTH_DEATH1) { loop = false; if(UpdateModel(&m_Upper,loop)) SetTorsoAnimation(BOTH_DEAD1); return true; } if(Animation == TORSO_ATTACK) { loop = false; if(UpdateModel(&m_Upper,loop)) SetTorsoAnimation(TORSO_STAND); return true; } if(Animation == TORSO_DROP) { loop = false; if(UpdateModel(&m_Upper,loop)) if(!weapon) SetTorsoAnimation(TORSO_STAND2); else SetTorsoAnimation(TORSO_STAND); return true; } if(Animation == TORSO_ATTACK2) { loop = false; if(UpdateModel(&m_Upper,loop)) SetTorsoAnimation(TORSO_STAND2); return true; } else loop = true; return UpdateModel(&m_Upper,loop); }
void CModelGTF::DrawModel() { //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Before we render the model we need to update the animation frames UpdateModel(); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Render the model and all it's objects RenderModel(); }
void ModelControl::OnCombo(wxCommandEvent &event) { if (!init) return; int id = event.GetId(); if (id == ID_MODEL_LOD) { // int value = event.GetInt(); // // MPQFile f(model->name); // if (f.isEof() || (f.getSize() < sizeof(ModelHeader))) { // LOG_ERROR << "Unable to open MPQFile:" << model->name.c_str(); // f.close(); // return; // } // // model->showModel = false; // model->setLOD(&f, value); // model->showModel = true; // // /* // for (size_t i=0; i<model->geosets.size(); i++) { // int id = model->geosets[i].id; // model->showGeosets[i] = (id==0); // } // // cc->RefreshModel(); // */ // // f.close(); } else if (id == ID_MODEL_NAME) { /* Alfred 2009/07/16 fix crash, remember CurrentSelection before UpdateModel() */ int CurrentSelection = modelname->GetCurrentSelection(); if (CurrentSelection < (int)attachments.size()) { UpdateModel(attachments[CurrentSelection]); att = attachments[CurrentSelection]; model = static_cast<WoWModel*>(attachments[CurrentSelection]->model()); animControl->UpdateModel(model); modelname->SetSelection(CurrentSelection); } } }
bool WorldSimulation::ReadState(File& f) { #if TEST_READ_WRITE TestReadWriteState(odesim,"odesim"); for(size_t i=0;i<controlSimulators.size();i++) TestReadWriteState(controlSimulators[i],"controller"); for(size_t i=0;i<hooks.size();i++) TestReadWriteState(*hooks[i],"hook"); #endif if(!ReadFile(f,time)) return false; if(!odesim.ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: ODE sim failed to read\n"); return false; } //controlSimulators will read the robotControllers' states for(size_t i=0;i<controlSimulators.size();i++) { if(!controlSimulators[i].ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: Control simulator %d failed to read\n",i); return false; } } for(size_t i=0;i<hooks.size();i++) { if(!hooks[i]->ReadState(f)) { fprintf(stderr,"WorldSimulation::ReadState: Hook %d failed to read\n",i); return false; } } int n; if(!ReadFile(f,n)) return false; if(n < 0) return false; contactFeedback.clear(); for(size_t i=0;i<n;i++) { pair<ODEObjectID,ODEObjectID> key; ContactFeedbackInfo info; if(!ReadFile(f,key.first)) return false; if(!ReadFile(f,key.second)) return false; if(!ReadFile(f,info)) return false; contactFeedback[key] = info; } UpdateModel(); return true; }
/* ================ sdClientAnimated::Present ================ */ void sdClientAnimated::Present( void ) { UpdateModel(); if ( !renderEntity.hModel || animatedFlags.hidden ) { return; } if ( renderSystem->IsSMPEnabled() ) { if ( animator.CreateFrame( gameLocal.time, false ) ) { } } // add to refresh list if ( renderEntityHandle == -1 ) { renderEntityHandle = gameRenderWorld->AddEntityDef( &renderEntity ); } else { gameRenderWorld->UpdateEntityDef( renderEntityHandle, &renderEntity ); } }
void hhForceField::ReadFromSnapshot( const idBitMsgDelta &msg ) { physicsObj.ReadFromSnapshot(msg); damagedState = !!msg.ReadBits(1); activationRate = msg.ReadFloat(); deactivationRate = msg.ReadFloat(); undamageFadeRate = msg.ReadFloat(); applyImpulseAttempts = msg.ReadBits(32); cachedContents = msg.ReadBits(32); fade = msg.ReadFloat(); nextCollideFxTime = msg.ReadBits(32); fieldState = (States)msg.ReadBits(4); bool hidden = !!msg.ReadBits(1); if (IsHidden() != hidden) { if (hidden) { Hide(); SetSkinByName( spawnArgs.GetString("skin_off" ) ); GetPhysics()->SetContents( 0 ); } else { Show(); SetSkinByName( NULL ); GetPhysics()->SetContents( cachedContents ); } } float f; bool changed = false; f = msg.ReadFloat(); changed = (changed || (renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] != f)); renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = f; f = msg.ReadFloat(); changed = (changed || (renderEntity.shaderParms[SHADERPARM_MODE] != f)); renderEntity.shaderParms[SHADERPARM_MODE] = f; if (changed) { UpdateModel(); UpdateVisuals(); } }
bool GraphicsClass::Frame() { bool result; UpdateModel(); result = m_Input->Frame(); if(m_Input->IsEscapePressed() == true) { return false; } m_Timer->Frame(); m_Fps->Frame(); result = m_Text->SetFps(m_Fps->GetFps(), m_D3D->GetDeviceContext()); m_Input->DetectInput(m_Timer->GetTime()); Render(); m_Text->SetActiveBlockCount(m_ActiveCubes, m_D3D->GetDeviceContext()); return true; }
/* ===================== sdClientAnimated::SetStaticModel ===================== */ void sdClientAnimated::SetStaticModel( const char* modelName ) { assert( modelName ); FreeModelDef(); renderEntity.hModel = renderModelManager->FindModel( modelName ); if ( renderEntity.hModel ) { renderEntity.hModel->Reset(); } renderEntity.callback = NULL; renderEntity.numJoints = 0; renderEntity.joints = NULL; if ( renderEntity.hModel ) { renderEntity.bounds = renderEntity.hModel->Bounds( &renderEntity ); } else { renderEntity.bounds.Zero(); } UpdateModel(); }
/* ===================== sdClientAnimated::SetModel ===================== */ void sdClientAnimated::SetModel( const char* modelName ) { FreeModelDef(); renderEntity.hModel = animator.SetModel( modelName ); if ( renderEntity.hModel == NULL ) { SetStaticModel( modelName ); return; } gameEdit->RefreshRenderEntity( spawnArgs, renderEntity ); if ( renderEntity.customSkin != NULL ) { renderEntity.customSkin = animator.ModelDef()->GetDefaultSkin(); } // set the callback to update the joints renderEntity.callback = sdClientAnimated::ModelCallback; animator.GetJoints( &renderEntity.numJoints, &renderEntity.joints ); animator.GetBounds( gameLocal.time, renderEntity.bounds ); UpdateModel(); }
int NextPPMdVariantIByte(PPMdModelVariantI *self) { if(self->endofstream) return -1; PPMdContext *mincontext=self->MaxContext; if(mincontext->LastStateIndex!=0) DecodeSymbol1VariantI(mincontext,self); else DecodeBinSymbolVariantI(mincontext,self); while(!self->core.FoundState) { do { self->core.OrderFall++; mincontext=PPMdContextSuffix(mincontext,&self->core); if(!mincontext) { self->endofstream=true; return -1; } } while(mincontext->LastStateIndex==self->core.LastMaskIndex); DecodeSymbol2VariantI(mincontext,self); } uint8_t byte=self->core.FoundState->Symbol; if(self->core.OrderFall==0&&(uint8_t *)PPMdStateSuccessor(self->core.FoundState,&self->core)>=self->alloc->UnitsStart) { self->MaxContext=PPMdStateSuccessor(self->core.FoundState,&self->core); //PrefetchData(MaxContext) } else { UpdateModel(self,mincontext); //PrefetchData(MaxContext) if(self->core.EscCount==0) ClearPPMdModelMask(&self->core); } return byte; }
void *HuffmanCoDec::Compress( const void *pUncompressedBuffer, int iUncompressedBufSize, void * pCompressedBuffer, int *piCompressedBufSize, FNCOMPSTAT fnStat, DWORD dwData ) { ASSERT( pUncompressedBuffer ); ASSERT( 0 < iUncompressedBufSize ); ASSERT( piCompressedBufSize ); // We want to use this as a BYTE array, not a void *. BYTE *pUncompBuf = ( BYTE * )pUncompressedBuffer; *piCompressedBufSize = 3 * iUncompressedBufSize / 2; if ( pCompressedBuffer == NULL ) pCompressedBuffer = malloc ( 1 + *piCompressedBufSize ); if ( pCompressedBuffer == NULL ) throw( "Not enough memory" ); bitBuffer.AttachForWriting( ((char *)pCompressedBuffer) + 1, *piCompressedBufSize ); bitBuffer.PutBits( ( DWORD )iUncompressedBufSize, 32 ); InitializeTree(); while( iUncompressedBufSize ) { BYTE nextSymbol = *pUncompBuf++; iUncompressedBufSize--; EncodeSymbol( nextSymbol ); UpdateModel( nextSymbol ); } EncodeSymbol( iEND_OF_STREAM ); bitBuffer.Flush(); *piCompressedBufSize = bitBuffer.GetSizeInBytes() + 1; * ((char *) pCompressedBuffer) = (char) CODEC::HUFFMAN; pCompressedBuffer = (BYTE *) realloc ( pCompressedBuffer, bitBuffer.GetSizeInBytes() + 1 ); return pCompressedBuffer; }
/*Organize the whole process of object tracking*/ void TrackAssociation::ObjectTrackingAtKeyFrame(int frameNO, cv::Mat &image, bool external_detection) { std::vector<cv::Rect> evidence; std::vector<float> evidence_weight; //Predict using feature tracks motion descriptors UpdateModelsByPrediction(); if(external_detection) { PeopleDetection(frameNO, image, evidence, evidence_weight); //If external detection is available, perform Data Association by greedy method std::vector<AffinityVal> affinity_mat; CalculateAffinityScore(evidence,affinity_mat); std::vector<int> assign_match; std::vector<bool> evidence_used, model_used; FindMatch(affinity_mat,evidence,assign_match,evidence_used,model_used); //Tracking by particle filtering. If appearance model not available, normal method is applied std::list<ObjSubTrack*> new_track_list; // Some sub object track candidates may be declared as new obj tracks std::list<float> new_weight_list; //Update obj tracks with external detection (particle filtering) UpdateModel(objSeg,evidence,evidence_weight,assign_match,evidence_used,new_track_list,new_weight_list); //For evidence that neither matched or added, create new models for them CreateNewObjTracks(objSeg,evidence,evidence_weight,evidence_used,new_track_list,new_weight_list); //Clean sub track models CleanSubTrackVector(); //Init appearance models for all main sub tracks InitAppearanceModelForMainTracks(); }else { TrackWithoutExternalDetection(objSeg); } SuperviseTrainingForSubTracks(); DrawDetectionModels(image,frameNO); }
// Iterates through all the models counting and creating a list void ModelControl::RefreshModel(Attachment *root) { try { attachments.clear(); WoWModel *m = static_cast<WoWModel*>(root->model()); if (m) { // wxASSERT(m); attachments.push_back(root); if (!init) UpdateModel(root); LOG_INFO << "ModelControl Refresh: Adding Model..."; } for (std::vector<Attachment *>::iterator it=root->children.begin(); it!=root->children.end(); ++it) { //m = NULL; m = static_cast<WoWModel*>((*it)->model()); if (m) { attachments.push_back((*it)); if (!init) UpdateModel((*it)); LOG_INFO << "ModelControl Refresh: Adding Attachment" << m->name() << "at level 1..."; } for (std::vector<Attachment *>::iterator it2=(*it)->children.begin(); it2!=(*it)->children.end(); ++it2) { m = static_cast<WoWModel*>((*it2)->model()); if (m) { //models.push_back(m); attachments.push_back((*it2)); if (!init) UpdateModel((*it2)); LOG_INFO << "ModelControl Refresh: Adding Attachment" << m->name() << "at level 2..."; } for (std::vector<Attachment *>::iterator it3=(*it2)->children.begin(); it3!=(*it2)->children.end(); ++it3) { m = static_cast<WoWModel*>((*it3)->model()); if (m) { //models.push_back(m); attachments.push_back((*it3)); if (!init) UpdateModel((*it3)); LOG_INFO << "ModelControl Refresh: Adding Attachment" << m->name() << "at level 3..."; } } } } // update combo box with the list of models? wxString tmp; modelname->Clear(); for (std::vector<Attachment*>::iterator it=attachments.begin(); it!=attachments.end(); ++it) { m = dynamic_cast<WoWModel*>((*it)->model()); if (m) { tmp = m->name().toStdString(); modelname->Append(tmp.AfterLast(MPQ_SLASH)); } } LOG_INFO << "ModelControl Refresh: Found" << attachments.size() << "Models..."; if (modelname->GetCount() > 0) modelname->SetSelection(0); } catch( ... ) { LOG_ERROR << "Problem occured in ModelControl::RefreshModel(Attachment *)"; } }
void idGLDrawableView::setObject( int Id ) { objectId = Id; UpdateModel(); }