bool psEffectObjSpire::Update(csTicks elapsed) { if(!anchor || !anchor->IsReady()) // wait for anchor to be ready return true; if(!psEffectObj::Update(elapsed)) return false; //float scale = 1; float topScale = 1; float height = 1; float padding = 1; if(keyFrames->GetSize() > 0) { // COLOUR float lerpfactor = LERP_FACTOR; csVector3 lerpColour = LERP_VEC_KEY(KA_COLOUR,lerpfactor); float lerpAlpha = LERP_KEY(KA_ALPHA,lerpfactor); for(int a=0; a<vertCount; ++a) colour[a].Set(lerpColour.x, lerpColour.y, lerpColour.z, lerpAlpha); topScale = LERP_KEY(KA_TOPSCALE,lerpfactor); height = LERP_KEY(KA_HEIGHT,lerpfactor); padding = LERP_KEY(KA_PADDING,lerpfactor); } CalculateData(shape, segments, vert, texel, topScale, height, padding); return true; }
//------------------------------------------------------------------------------ Solver::SolverState BatchEstimator::AdvanceState() { switch (currentState) { case INITIALIZING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "INITIALIZING\n"); #endif // ReportProgress(); CompleteInitialization(); break; case PROPAGATING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "PROPAGATING\n"); #endif // ReportProgress(); FindTimeStep(); break; case CALCULATING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "CALCULATING\n"); #endif // ReportProgress(); CalculateData(); break; case LOCATING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "LOCATING\n"); #endif // ReportProgress(); ProcessEvent(); break; case ACCUMULATING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "ACCUMULATING\n"); #endif // ReportProgress(); Accumulate(); break; case ESTIMATING: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "ESTIMATING\n"); #endif // ReportProgress(); Estimate(); break; case CHECKINGRUN: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "CHECKINGRUN\n"); #endif // ReportProgress(); CheckCompletion(); break; case FINISHED: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "FINISHED\n"); #endif RunComplete(); // ReportProgress(); break; default: #ifdef DEBUG_STATE_MACHINE MessageInterface::ShowMessage("Entered Estimator state machine: " "Bad state for an estimator.\n"); #endif /* throw EstimatorException("Solver state not supported for the simulator")*/; } return currentState; }
//----------------------------------------------------------------------------- void LineProfileCanvas::RefreshData( const RequestData& data, int x /* = -1 */, int y /* = -1 */, int w /* = -1 */, int h /* = -1 */, bool boForceRefresh /* = false */ ) //----------------------------------------------------------------------------- { wxCriticalSectionLocker locker( m_critSect ); bool boAOIChanged = false; bool boImageFormatChanged = false; const ImageBuffer* pIB = data.image_.getBuffer(); const TBayerMosaicParity bayerParity = GetProcessBayerParity() ? data.bayerParity_ : bmpUndefined; const int channelCount = ( ( bayerParity != bmpUndefined ) ? 4 : pIB->iChannelCount ); if( !MustUpdate( pIB, channelCount, x, y, w, h, boForceRefresh, &boAOIChanged, &boImageFormatChanged ) ) { return; } if( boImageFormatChanged || ( m_bayerParity != bayerParity ) ) { SetupGDIData( pIB, channelCount, bayerParity ); } if( boAOIChanged || !m_ppData || boImageFormatChanged ) { // free old memory DeallocateProfileBuffer(); // allocate new memory m_ppData = new int* [channelCount]; for( int channel = 0; channel < channelCount; channel++ ) { m_horDataCount = ( bayerParity != bmpUndefined ) ? ( ( m_AOIw + 1 ) / 2 ) : m_AOIw; m_verDataCount = ( bayerParity != bmpUndefined ) ? ( ( m_AOIh + 1 ) / 2 ) : m_AOIh; m_ppData[channel] = new int[GetDataCount()]; } if( m_pNumericalDisplay ) { const int columnCount = m_pNumericalDisplay->GetTable()->GetNumberCols(); const int columnsNeeded = channelCount + 1; if( columnCount < columnsNeeded ) { m_pNumericalDisplay->AppendCols( columnsNeeded - columnCount ); } else if( columnCount > columnsNeeded ) { m_pNumericalDisplay->DeleteCols( columnCount - 1, columnCount - columnsNeeded ); } int rowCount = m_pNumericalDisplay->GetTable()->GetNumberRows(); int rowsNeeded = 1 + GetDataCount(); if( rowCount < rowsNeeded ) { m_pNumericalDisplay->AppendRows( rowsNeeded - rowCount ); } else if( rowCount > rowsNeeded ) { m_pNumericalDisplay->DeleteRows( rowsNeeded - 1, rowCount - rowsNeeded ); } m_pNumericalDisplay->SetCellValue( 0, 0, wxT( "Data Point" ) ); for( int i = 0; i < channelCount; i++ ) { m_pNumericalDisplay->SetCellBackgroundColour( 0, i + 1, *m_Pens[i].pColour_ ); m_pNumericalDisplay->SetCellTextColour( 0, i + 1, *wxWHITE ); } } } assert( ( channelCount <= PLANE_CNT ) && wxT( "A pixel format defines more channels then this tool can handle" ) ); for( int channel = 0; channel < channelCount; channel++ ) { memset( m_ppData[channel], 0, sizeof( int )*GetDataCount() ); } m_bayerParity = bayerParity; m_ChannelCount = channelCount; switch( pIB->pixelFormat ) { case ibpfMono10: case ibpfBGR101010Packed_V2: case ibpfRGB101010Packed: case ibpfYUV422_10Packed: case ibpfYUV422_UYVY_10Packed: case ibpfYUV444_UYV_10Packed: case ibpfYUV444_10Packed: m_valCount = VAL_COUNT_10_BIT; break; case ibpfRGB121212Packed: case ibpfMono12: case ibpfMono12Packed_V1: case ibpfMono12Packed_V2: m_valCount = VAL_COUNT_12_BIT; break; case ibpfRGB141414Packed: case ibpfMono14: m_valCount = VAL_COUNT_14_BIT; break; case ibpfRGB161616Packed: case ibpfMono16: m_valCount = VAL_COUNT_16_BIT; break; case ibpfRGBx888Packed: case ibpfBGR888Packed: case ibpfRGB888Packed: case ibpfRGBx888Planar: case ibpfYUV422Packed: case ibpfYUV422_UYVYPacked: case ibpfYUV444_UYVPacked: case ibpfYUV444Packed: case ibpfYUV422Planar: case ibpfMono8: default: m_valCount = VAL_COUNT_8_BIT; break; } CalculateData( pIB, bayerParity ); bool boFullUpdate = boAOIChanged || boImageFormatChanged; UpdateAnalysisOutput( boFullUpdate ); }
bool psEffectObjSpire::PostSetup() { static unsigned int uniqueID = 0; csString facName = "effect_spire_fac_"; facName += uniqueID++; meshFact = engine->CreateMeshFactory("crystalspace.mesh.object.genmesh", facName.GetData()); effectsCollection->Add(meshFact->QueryObject()); // create the actual sprite3d data iMeshObjectFactory* fact = meshFact->GetMeshObjectFactory(); csRef<iGeneralFactoryState> facState = scfQueryInterface<iGeneralFactoryState> (fact); // setup the material csRef<iMaterialWrapper> mat = effectsCollection->FindMaterial(materialName); if(!mat) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Couldn't find effect material: %s\n", materialName.GetData()); return false; } fact->SetMaterialWrapper(mat); // ensure the minimum number of segments for the shape switch(shape) { case SPI_CIRCLE: case SPI_CYLINDER: segments = (segments >= 3 ? segments : 3); facState->SetVertexCount(2 * segments + 2); break; case SPI_ASTERIX: segments = (segments >= 3 ? segments : 3); facState->SetVertexCount(4 * segments); break; case SPI_STAR: segments = (segments >= 3 ? segments : 3); facState->SetVertexCount(6 * segments); break; case SPI_LAYERED: segments = (segments >= 1 ? segments : 1); facState->SetVertexCount(4 * segments); break; } vertCount = facState->GetVertexCount(); CalculateData(shape, segments, facState->GetVertices(), facState->GetTexels()); animLength = 10; if(keyFrames->GetSize() > 0) animLength += keyFrames->Get(keyFrames->GetSize()-1)->time; // create the tris switch(shape) { case SPI_CIRCLE: case SPI_CYLINDER: facState->SetTriangleCount(4*segments); for(int q=0; q<segments; ++q) { facState->GetTriangles()[q*4 ].Set(q*2, q*2+1, q*2+2); facState->GetTriangles()[q*4+1].Set(q*2+1, q*2+3, q*2+2); facState->GetTriangles()[q*4+2].Set(q*2, q*2+2, q*2+1); facState->GetTriangles()[q*4+3].Set(q*2+1, q*2+2, q*2+3); } break; case SPI_ASTERIX: facState->SetTriangleCount(4*segments); for(int q=0; q<segments; ++q) { facState->GetTriangles()[q*4 ].Set(q*4, q*4+2, q*4+1); facState->GetTriangles()[q*4+1].Set(q*4, q*4+2, q*4+3); facState->GetTriangles()[q*4+2].Set(q*4+2, q*4, q*4+1); facState->GetTriangles()[q*4+3].Set(q*4+2, q*4, q*4+3); } break; case SPI_STAR: facState->SetTriangleCount(8*segments); for(int q=0; q<segments; ++q) { facState->GetTriangles()[q*8 ].Set(q*8, q*8+1, q*8+3); facState->GetTriangles()[q*8+1].Set(q*8, q*8+1, q*8+4); facState->GetTriangles()[q*8+2].Set(q*8+1, q*8+2, q*8+4); facState->GetTriangles()[q*8+3].Set(q*8+1, q*8+2, q*8+5); facState->GetTriangles()[q*8+4].Set(q*8, q*8+3, q*8+1); facState->GetTriangles()[q*8+5].Set(q*8, q*8+4, q*8+1); facState->GetTriangles()[q*8+6].Set(q*8+1, q*8+4, q*8+2); facState->GetTriangles()[q*8+7].Set(q*8+1, q*8+5, q*8+2); } break; case SPI_LAYERED: facState->SetTriangleCount(4*segments); for(int q=0; q<segments; ++q) { facState->GetTriangles()[q*4 ].Set(q*4, q*4+2, q*4+1); facState->GetTriangles()[q*4+1].Set(q*4, q*4+2, q*4+3); facState->GetTriangles()[q*4+2].Set(q*4, q*4+4, q*4+1); facState->GetTriangles()[q*4+3].Set(q*4, q*4+4, q*4+3); } break; } return true; }
//------------------------------------------------------------------------------ Solver::SolverState SequentialEstimator::AdvanceState() { switch (currentState) { case INITIALIZING: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the INITIALIZING state\n"); #endif CompleteInitialization(); break; case PROPAGATING: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the PROPAGATING state\n"); #endif FindTimeStep(); break; case CALCULATING: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the CALCULATING state\n"); #endif CalculateData(); break; case LOCATING: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the LOCATING state\n"); #endif ProcessEvent(); break; case ESTIMATING: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the ESTIMATING state\n"); #endif Estimate(); break; case CHECKINGRUN: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the CHECKINGRUN state\n"); #endif CheckCompletion(); break; case FINISHED: #ifdef WALK_STATE_MACHINE MessageInterface::ShowMessage("Executing the FINISHED state\n"); #endif RunComplete(); break; default: throw EstimatorException("Unknown state encountered in the " + instanceName + " sequential estimator."); } return currentState; }