Font::Font(const String &filename) : Image(filename, 16, 16) {
	m_x = 0;
	m_y = 0;
	m_speedX = 0;
	m_speedY = 0;

	for (unsigned short int f = 0; f < GetNumFrames(); f++)
		glyphs.Add(Glyph(0, 0, GetWidth(), GetHeight()));

	int width32 = 0;
	int height32 = 0;
	int *ptrComp = nullptr;
	
	uint8 * const buffer = stbi_load(filename.ToCString(), &width32, &height32, ptrComp, 4);	//this pointer should never be missing
	
	if (buffer) {
		uint8 *ptrBuffer = buffer;

		//0x<A><B><G><R>
		const uint32 red = 0xff0000ff;
		const uint32 yellow = 0xff00ffff;
		const uint32 black = 0xff000000;
		const uint32 transparent = 0x00000000;

		unsigned short int i, j;
		uint16 row = 0;
		uint16 col = 0;

		for (unsigned short int frame = 0; frame < GetNumFrames(); frame++) {
			row = frame / GetHFrames();
			col = frame % GetHFrames();
			ptrBuffer = buffer + ((GetWidth() * col) * 4) + (row * GetHeight() * GetWidth() * GetHFrames() * 4);
			for (j = 0; j < GetHeight(); j++) {
				for (i = 0; i < GetWidth(); i++) {
					//inside each frame
					if (*((uint32 *)(ptrBuffer)) == black)
						memset(ptrBuffer, transparent, 4);
					else if (*((uint32 *)(ptrBuffer)) == yellow) {
						glyphs[frame].SetOrigX(i);
						glyphs[frame].SetOrigY(j);
						memset(ptrBuffer, transparent, 4);
					} else if (*((uint32 *)(ptrBuffer)) == red) {
						glyphs[frame].SetEndX(i);
						glyphs[frame].SetEndY(j);
						memset(ptrBuffer, transparent, 4);
					}
					ptrBuffer += 4;
				}
				ptrBuffer += ((GetHFrames() * GetWidth()) - GetWidth()) * 4;
			}
		}
		Renderer::Instance().GenFontImage(buffer, width32, height32);
		delete buffer;
	}
}
void FEventGraphData::SetAsAverage()
{
	struct FCopyAverage
	{
		void operator()( FEventGraphSample* EventPtr, const double NumFrames )
		{
			EventPtr->CopyAverage( NumFrames );
		}
	};

	const double NumFrames = (double)GetNumFrames();
	RootEvent->ExecuteOperationForAllChildren( FCopyAverage(), NumFrames );
	Description = FString::Printf( TEXT("Average: %i"), GetNumFrames() );
}
MarkersMotion::MarkersMotion(const char *motionDataFile, const int framesPerSec)
{
	// Start by parsing our motion (raw data) file (.csv)
	m_pDataParser = new LCSVParser(motionDataFile);
	// And set the frequency that the data in the above file was collected.
	m_framesPerSec = framesPerSec;

	// Initialize number of frames and number of markers.
	m_numFrames = m_pDataParser->GetNumEntries() - 1;
	m_numMarkers = m_pDataParser->GetNumFields()/NUM_MARKER_COORDS;

	// Now initialize our 3D "array" of motion data from the parsed data file.
	m_motionData = new double**[GetNumFrames()];

	for(int frame = 0; frame < GetNumFrames(); frame++)
	{
		m_motionData[frame] = new double*[GetNumMarkers()];

		for(int markerIndex = 0; markerIndex < GetNumMarkers(); markerIndex++)
		{
			m_motionData[frame][markerIndex] = new double[NUM_MARKER_COORDS];

			for(int coordinate = 0; coordinate < NUM_MARKER_COORDS; coordinate++)
			{
				// Calculate the proper coordinate index to look up the appropriate data
				// for the given marker.
				int coordinateColumn = (markerIndex * NUM_MARKER_COORDS) + coordinate;

				// Find and store the appropriate data for each coordinate of our marker.
				// Note:  We obtain data from entry (frame + 1) in order to avoid
				//        the first row, which consists of field headers.
				//----------------------------------------------------------------------
				std::string rawEntry;
				m_pDataParser->GetDataEntryInField(frame + 1, coordinateColumn, rawEntry);
				// Check if we've got no data in this entry.
				if(rawEntry.compare("NaN") == 0)
				{
					// If we have no data, add in our NO_DATA constant placeholder.
					m_motionData[frame][markerIndex][coordinate] = NO_DATA;
				}
				else
				{
					// Otherwise, our data is good, so add it appropriately.
					m_motionData[frame][markerIndex][coordinate] = atof(rawEntry.c_str());
				}
			}
		}
	}
}
void
FrameBlender::InsertFrame(uint32_t aFrameNum, RawAccessFrameRef&& aRef)
{
    MOZ_ASSERT(aRef, "Need a reference to a frame");
    MOZ_ASSERT(aFrameNum <= GetNumFrames(), "Inserting invalid frame");

    mFrames.InsertElementAt(aFrameNum, Move(aRef));
    if (GetNumFrames() == 2) {
        MOZ_ASSERT(!mAnim, "Shouldn't have an animation context yet");
        mAnim = new Anim();
    }

    MOZ_ASSERT(GetNumFrames() < 2 || mAnim,
               "If we're animated we should have an animation context now");
}
Exemple #5
0
void Animate::Think()
{
	int num_playing = 0;

	if( !tiki ) {
		return Entity::Think();
	}

	for( int i = 0; i < GetNumFrames(); i++ )
	{
		float max_time = cgi.Anim_Time( tiki, frame[ i ].index );

		if( frame[ i ].time < max_time )
		{
			frame[ i ].time += cg->frametime;
			num_playing++;
		}
		else
		{
			frame[ i ].time = max_time;
		}
	}

	// Optimize performances
	if( !num_playing && this->classinfo() == Animate::classinfostatic() ) {
		turnThinkOff();
	}

	Entity::Think();
}
Exemple #6
0
void cMotion::CalcIndexPhase(double time, int& out_idx, double& out_phase) const
{
	double max_time = GetDuration();

	if (!mLoop)
	{
		if (time <= gMinTime)
		{
			out_idx = 0;
			out_phase = 0;
			return;
		}
		else if (time >= max_time)
		{
			out_idx = GetNumFrames() - 2;
			out_phase = 1;
			return;
		}
	}

	time = std::fmod(time, max_time);
	if (time < 0)
	{
		time += max_time;
	}

	const Eigen::VectorXd& frame_times = mFrames.col(eFrameTime);
	auto it = std::upper_bound(frame_times.data(), frame_times.data() + frame_times.size(), time);
	out_idx = static_cast<int>(it - frame_times.data() - 1);

	double time0 = frame_times(out_idx);
	double time1 = frame_times(out_idx + 1);
	out_phase = (time - time0) / (time1 - time0);
}
void J2716AnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
	std::ofstream file_stream( file, std::ios::out );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	file_stream << "Time [s],Value" << std::endl;

	U64 num_frames = GetNumFrames();
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
		
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char number_str[128];
		AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );

		file_stream << time_str << "," << number_str << std::endl;

		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			file_stream.close();
			return;
		}
	}

	file_stream.close();
}
void Pn5180AnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 /*export_type_user_id*/ )
{
	//export_type_user_id is only important if we have more than one export type.


	std::stringstream ss;
	void* f = AnalyzerHelpers::StartFile( file );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	ss << "Time [s],Packet ID,MOSI,MISO" << std::endl;

	bool mosi_used = true;
	bool miso_used = true;

	if( mSettings->mMosiChannel == UNDEFINED_CHANNEL )
		mosi_used = false;

	if( mSettings->mMisoChannel == UNDEFINED_CHANNEL )
		miso_used = false;

	U64 num_frames = GetNumFrames();
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );

		if( ( frame.mFlags & Pn5180_ERROR_FLAG ) != 0 )
			continue;
		
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char mosi_str[128] = "";
		if( mosi_used == true )
			AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, mosi_str, 128 );

		char miso_str[128] = "";
		if( miso_used == true )
			AnalyzerHelpers::GetNumberString( frame.mData2, display_base, 8, miso_str, 128 );

		U64 packet_id = GetPacketContainingFrameSequential( i ); 
		if( packet_id != INVALID_RESULT_INDEX )
			ss << time_str << "," << packet_id << "," << mosi_str << "," << miso_str << std::endl;
		else
			ss << time_str << ",," << mosi_str << "," << miso_str << std::endl;  //it's ok for a frame not to be included in a packet.
	
		AnalyzerHelpers::AppendToFile( (U8*)ss.str().c_str(), ss.str().length(), f );
		ss.str( std::string() );
							
		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			AnalyzerHelpers::EndFile( f );
			return;
		}
	}

	UpdateExportProgressAndCheckForCancel( num_frames, num_frames );
	AnalyzerHelpers::EndFile( f );
}
Exemple #9
0
//frees all frames
void CSpriteFile::FreeAllFrames()
{
	for(uint32 nCurrFrame = 0; nCurrFrame < GetNumFrames(); nCurrFrame++)
	{
		FreeFrame(nCurrFrame);
	}
}
bool MarkersMotion::GetMarkerPositionAtFrame(const int &frame, const int &markerIndex,
											 double &x, double &y, double &z)
{
	// Make sure we have been given a valid frame #.
	if(frame < 0 || frame > GetNumFrames())
		return false;

	// Make sure we have been given a valid marker index.
	if(markerIndex < 0 || markerIndex > GetNumMarkers())
		return false;

	// Now get the x, y, z coordinates for the requested marker based on the frame
	// and marker index we've been given.  If any of our coordinates contain no data,
	// return false and jump out of here.
	if(m_motionData[frame][markerIndex][X_COORD] == NO_DATA)
		return false;

	if(m_motionData[frame][markerIndex][Y_COORD] == NO_DATA)
		return false;

	if(m_motionData[frame][markerIndex][Z_COORD] == NO_DATA)
		return false;

	// If all of our data is good to go, set x, y, z accordingly and return successfully.
	x = m_motionData[frame][markerIndex][X_COORD];
	y = m_motionData[frame][markerIndex][Y_COORD];
	z = m_motionData[frame][markerIndex][Z_COORD];

	return true;
}
void SpriteSheet::ExportSpriteFrameOffsetsTable(const PlatformConfig& config, std::stringstream& stream, const std::string& actorName, int sizeUniqueTiles) const
{
	stream << "actor_" << actorName << "_sheet_" << m_name << "_frametable:" << std::endl;

	// (w) Frame size (tiles)
	// (w) Frame size (subsprites)
	// (l) Tiles address
	// (l) Subsprite dimension bits table addr
	// (l) Subsprite position offsets table addr

	for(int i = 0; i < GetNumFrames(); i++)
	{
		std::stringstream label;
		label << "actor_" << actorName << "_sheet_" << m_name << "_frame_" << i;

		stream << label.str() << "_header:" << std::endl;

		const SpriteSheet::SpriteFrameDimensions& dimensionData = GetDimensionData(i);

		int sizeTiles = sizeUniqueTiles;

		if(sizeUniqueTiles == 0)
		{
			sizeTiles = GetWidthTiles(i, config.tileWidth) * GetHeightTiles(i, config.tileHeight);
		}

		stream << "\tdc.w 0x" << HEX4(sizeTiles) << "\t; Frame size (tiles)" << std::endl;
		stream << "\tdc.w " << label.str() << "_size_subsprites\t; Frame size (subsprites)" << std::endl;
		stream << "\tdc.l " << label.str() << std::endl;
		stream << "\tdc.l " << label.str() << "_subsprite_dimensions_bits" << std::endl;
		stream << "\tdc.l " << label.str() << "_subsprite_pos_offsets" << std::endl;
		stream << std::endl;
	}
}
void
FrameSequence::InsertFrame(uint32_t framenum, imgFrame* aFrame)
{
  NS_ABORT_IF_FALSE(framenum <= mFrames.Length(), "Inserting invalid frame!");
  mFrames.InsertElementAt(framenum, aFrame);
  if (GetNumFrames() > 1) {
    // If we're creating our second element, we now know we're animated.
    // Therefore, we need to lock the first frame too.
    if (GetNumFrames() == 2) {
      mFrames[0].LockAndGetData();
    }

    // Whenever we have more than one frame, we always lock *all* our frames
    // so we have all the image data pointers.
    mFrames[framenum].LockAndGetData();
  }
}
const uint32 IDataProvider::AdvanceFrame( const float DeltaTimeMS )
{
	if( !bHasAddedSecondStartMarker )
	{
		bHasAddedSecondStartMarker = true;

		// Add the default values.
		FrameCounters.Add( LastSecondFrameCounter );
		AccumulatedFrameCounters.Add( GetNumFrames() );
	}

	ElapsedTimeMS += DeltaTimeMS;
	LastSecondFrameTimeMS += DeltaTimeMS;

	LastSecondFrameCounter ++;

	const uint32 SampleEndIndex = GetNumSamples();
	FrameIndices.Add( FIntPoint( FrameIndex, SampleEndIndex ) );

	FrameTimes.Add( DeltaTimeMS );
	ElapsedFrameTimes.Add( ElapsedTimeMS );

	// Update the values.
	FrameCounters.Last() = LastSecondFrameCounter;
	AccumulatedFrameCounters.Last() = GetNumFrames();

	int NumLongFrames = 0;
	while( LastSecondFrameTimeMS > 1000.0f )
	{
		if( NumLongFrames > 0 )
		{
			// Add the default values.
			FrameCounters.Add( LastSecondFrameCounter );
			AccumulatedFrameCounters.Add( GetNumFrames() );
		}

		LastSecondFrameTimeMS -= 1000.0f;
		bHasAddedSecondStartMarker = false;
		LastSecondFrameCounter = 0;
		NumLongFrames ++;
	}

	FrameIndex = SampleEndIndex;
	return FrameIndex;
}
Exemple #14
0
float UPaperFlipbook::GetTotalDuration() const
{
	if (FramesPerSecond != 0)
	{
		return GetNumFrames() / FramesPerSecond;
	}

	return 0.0f;
}
Exemple #15
0
//================================
// OvrAnimComponent::SetFrame
void OvrAnimComponent::SetFrame( VRMenuObject * self, int const frameNum )
{
	CurFrame = Alg::Clamp( frameNum, 0, GetNumFrames( self ) - 1 );
	// we must reset the base frame and the current time so that the frame calculation
	// remains correct if we're playing.  If we're not playing, this will cause the
	// next Play() to start from this frame.
	BaseFrame = frameNum;
	BaseTime = ovr_GetTimeInSeconds();
	ForceVisibilityUpdate = true;	// make sure visibilities are set next frame update
}
void FEventGraphData::Finalize( const uint32 InFrameStartIndex, const uint32 InFrameEndIndex )
{
	FrameStartIndex = InFrameStartIndex;
	FrameEndIndex = InFrameEndIndex;
	const double NumFrames = (double)GetNumFrames();

	// Set root and thread event.
	RootEvent->SetRootAndThreadForAllChildren();
	// Fix all children. 
	RootEvent->FixChildrenTimesAndCalcAveragesForAllChildren( NumFrames );
}
int SpriteSheet::GetNumCroppedTiles(int tileWidth, int tileHeight) const
{
	int numTiles = 0;

	for(int i = 0; i < GetNumFrames(); i++)
	{
		numTiles += GetWidthTiles(i, tileWidth) * GetHeightTiles(i, tileHeight);
	}

	return numTiles;
}
void SDIOAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
	std::ofstream file_stream( file, std::ios::out );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	file_stream << "Time [s],Value" << std::endl;

	U64 num_frames = GetNumFrames();
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
		
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char number_str[128];
		AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );

		file_stream << time_str << ",";
		
		if (frame.mType == SDIOAnalyzer::FRAME_DIR){
			file_stream << "DIR:";
			if (frame.mData1){
				file_stream << "from Host";
			}else{
				file_stream << "from Slave";
			}
		}else if (frame.mType == SDIOAnalyzer::FRAME_CMD){
			file_stream << "CMD:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_ARG){
			file_stream << "ARG:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_LONG_ARG){
			file_stream << "LONG_ARG:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_CRC){
			file_stream << "CRC:" << number_str;
		}
		
		file_stream << std::endl;

		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			file_stream.close();
			return;
		}
	}

	file_stream.close();
}
Exemple #19
0
//sets a specific frame name
bool CSpriteFile::SetFrame(uint32 nFrame, const char* pszName)
{
	assert(nFrame < GetNumFrames());

	FreeFrame(nFrame);

	m_ppszFrames[nFrame] = new char [strlen(pszName) + 1];

	if(!m_ppszFrames[nFrame])
		return false;

	strcpy(m_ppszFrames[nFrame], pszName);

	return true;
}
MarkersMotion::~MarkersMotion()
{
	// Clear out all of the motion data.
	for(int i = 0; i < GetNumFrames(); i++)
	{
		for(int j = 0; j < GetNumMarkers(); j++)
		{
			delete m_motionData[i][j];
		}
		delete m_motionData[i];
	}
	delete m_motionData;
	m_motionData = NULL;

	delete m_pDataParser;
	m_pDataParser = NULL;
}
Exemple #21
0
void cMotion::Output(const std::string& out_filepath) const
{
	FILE* file = cFileUtil::OpenFile(out_filepath, "w");

	fprintf(file, "{\n");
	fprintf(file, "\"%s\": ", gLoopKey.c_str());

	if (mLoop)
	{
		fprintf(file, "true,\n");
	}
	else
	{
		fprintf(file, "false,\n");
	}

	fprintf(file, "\"Frames\":\n[\n");

	int num_frames = GetNumFrames();
	for (int f = 0; f < num_frames; ++f)
	{
		if (f != 0)
		{
			fprintf(file, ",\n");
		}

		Eigen::VectorXd curr_frame = mFrames.row(f);
		double curr_time = curr_frame[eFrameTime];
		double dur = 0;
		if (f < num_frames - 1)
		{
			double next_time = GetFrameTime(f + 1);
			dur = next_time - curr_time;
		}
		curr_frame[eFrameTime] = dur;
		std::string frame_json = cJsonUtil::BuildVectorJson(curr_frame);
		fprintf(file, "%s", frame_json.c_str());
	}

	fprintf(file, "\n]");
	fprintf(file, "\n}");
	cFileUtil::CloseFile(file);
}
Exemple #22
0
HRESULT CImageImpl::GetFrameInfo(UINT uFrame, LPFRAMEINFO pFrameInfo)
{
    USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST);

    pFrameInfo->delayTime = 0;
    pFrameInfo->disposalMethod = 2;
    pFrameInfo->bkColorIndex = -1;
    pFrameInfo->bkColor = 0xFFFFFFFF;

    if (m_pBitmap == NULL)
        return S_FALSE;

    UINT uAllFrame = 0;
    if (S_OK != GetNumFrames(&uAllFrame))
        return S_FALSE;

    ASSERT(uFrame >= 0 && uFrame < uAllFrame);
    if (uFrame < 0 || uFrame >= uAllFrame)
        return S_FALSE;

    //获得帧时间延迟
    UINT uSize = m_pBitmap->GetPropertyItemSize(PropertyTagFrameDelay);
    if (uSize <= 0)
        return S_FALSE;

    try
    {
        std::vector<BYTE> vecPropBuffer(uSize, 0);
        Gdiplus::PropertyItem* pPropertyItem = (Gdiplus::PropertyItem*)(&vecPropBuffer[0]);
        m_pBitmap->GetPropertyItem(PropertyTagFrameDelay, uSize, pPropertyItem);
        pFrameInfo->delayTime = ((int*)pPropertyItem->value)[uFrame] * 10;
    }
    catch (...)
    {
        return S_FALSE;
    }

    if (pFrameInfo->delayTime < 100)
        pFrameInfo->delayTime = 100;

    return S_OK;
}
Exemple #23
0
void Entity::GetTag( const char *tagname, orientation_t *orient )
{
	refEntity_t ref;

	if( tiki == NULL ) {
		return;
	}

	int num = cgi.Tag_NumForName( tiki, tagname );

	if( num == -1 ) {
		return;
	}

	memset( &ref, 0, sizeof( refEntity_t ) );

	VectorCopy( origin, ref.origin );
	MatrixToEulerAngles( ref.axis, angles );

	ref.reType = RT_MODEL;

	ref.scale = scale;
	ref.hModel = modelhandle;
	ref.hOldModel = modelhandle;
	ref.tiki = tiki;
	ref.entityNumber = 0;
	ref.actionWeight = 1.0f;

	for( int i = 0; i < GetNumFrames(); i++ )
	{
		frameInfo_t *frame = GetFrameInfo( i );

		ref.frameInfo[ i ].index = frame->index;
		ref.frameInfo[ i ].time = frame->time;
		ref.frameInfo[ i ].weight = frame->weight;
	}

	//cgi.TIKI_Orientation( orient, &ref, num );
	*orient = re.TIKI_Orientation( &ref, num );
}
Exemple #24
0
//called to save the current state out to a file
bool CSpriteFile::Save(const char* pszFilename) const
{
	//open up the file
#if _MSC_VER >= 1300
	std::ofstream OutFile(pszFilename, std::ios::out | std::ios::binary);
#else
	ofstream OutFile(pszFilename, ios::out | ios::binary);
#endif

	//check the open
	if(!OutFile)
		return false;

	//write out the header
	uint32 nTempVal;

	OutFile.write((char*)&m_nNumFrames, sizeof(m_nNumFrames));
	OutFile.write((char*)&m_nFrameRate, sizeof(m_nFrameRate));
	
	nTempVal = m_bTransparent ? 1 : 0;
	OutFile.write((char*)&nTempVal, sizeof(nTempVal));
	nTempVal = m_bTranslucent ? 1 : 0;
	OutFile.write((char*)&nTempVal, sizeof(nTempVal));

	OutFile.write((char*)&m_nKey, sizeof(m_nKey));

	//now write out all the strings
	for(uint32 nCurrFrame = 0; nCurrFrame < GetNumFrames(); nCurrFrame++)
	{
		const char* pszFrame = GetFrame(nCurrFrame);

		uint16 nStrLen = pszFrame ? strlen(pszFrame) : 0;
		OutFile.write((char*)&nStrLen, sizeof(nStrLen));
		OutFile.write(pszFrame, nStrLen);
	}

	//success
	return true;
}
//================================
// OvrAnimComponent::Frame
eMsgStatus OvrAnimComponent::Frame( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr, 
	VRMenuObject * self, VRMenuEvent const & event ) 
{
	// only recalculate the current frame if playing
	if ( AnimState == ANIMSTATE_PLAYING )
	{
		double timePassed = ovr_GetTimeInSeconds() - BaseTime;
		FloatFrame = timePassed * FramesPerSecond;
		int totalFrames = ( int )floor( FloatFrame );
		FractionalFrame = FloatFrame - totalFrames;
		int numFrames = GetNumFrames( self );
		int frame = BaseFrame + totalFrames;
		CurFrame = !Looping ? Alg::Clamp( frame, 0, numFrames - 1 ) : frame % numFrames;
		SetFrameVisibilities( app, vrFrame, menuMgr, self );
	} 
	else if ( ForceVisibilityUpdate )
	{
		SetFrameVisibilities( app, vrFrame, menuMgr, self );
		ForceVisibilityUpdate = false;
	}

	return MSG_STATUS_ALIVE;
}
void ManchesterAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 /*export_type_user_id*/ )
{
	std::stringstream ss;
	void* f = AnalyzerHelpers::StartFile( file );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();
	U64 num_frames = GetNumFrames();

	ss << "Time [s],Data" << std::endl;

	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
		
		//static void GetTimeString( U64 sample, U64 trigger_sample, U32 sample_rate_hz, char* result_string, U32 result_string_max_length );
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char number_str[128];
		AnalyzerHelpers::GetNumberString( frame.mData1, display_base, mSettings->mBitsPerTransfer, number_str, 128);

		ss << time_str << "," << number_str;
		ss << std::endl;

		AnalyzerHelpers::AppendToFile( (U8*)ss.str().c_str(), ss.str().length(), f );
		ss.str( std::string() );
							
		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			AnalyzerHelpers::EndFile( f );
			return;
		}
	}
	UpdateExportProgressAndCheckForCancel( num_frames, num_frames );
	AnalyzerHelpers::EndFile( f );
}
double MarkersMotion::GetTotalTime()
{
	// The total time of our recorded data is precisely the number of frames
	// recorded multiplied by the interval between frames.
	return GetNumFrames() * GetTimeStep();
}
void UnioAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 /*export_type_user_id*/ )
{
	//export_type_user_id is only important if we have more than one export type.

	std::stringstream ss;
	void* f = AnalyzerHelpers::StartFile( file );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	ss << "Time [s],Packet ID,Address,Data,MAK,SAK" << std::endl;

	U64 num_frames = GetNumFrames();
	char address_str[128] = "";
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );

		if( frame.mType == AddressFrame8 )
		{
			AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, address_str, 128 );
			if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
			{
				AnalyzerHelpers::EndFile( f );
				return;
			}
			continue;
		}

		if( frame.mType == AddressFrame12 )
		{
			AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, address_str, 128 );
			if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
			{
				AnalyzerHelpers::EndFile( f );
				return;
			}
			continue;
		}

		if( frame.mType == DataFrame )
		{
			char time_str[128];
			AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

			char data_str[128];
			AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, data_str, 128 );

			ss << time_str << ",";

			U64 packet_id = GetPacketContainingFrameSequential( i );
			if( packet_id != INVALID_RESULT_INDEX )
				ss << packet_id;
	
			ss << "," << address_str << "," << data_str;

			if( ( frame.mFlags & MASTER_ACK ) != 0 )
				ss << ",MAK";
			else
				ss << ",NoMAK";

			if( ( frame.mFlags & SLAVE_ACK ) != 0 )
				ss << ",SAK";
			else
				ss << ",NoSAK";

			ss << std::endl;
		}

		AnalyzerHelpers::AppendToFile( (U8*)ss.str().c_str(), ss.str().length(), f );
		ss.str( std::string() );
							
		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			AnalyzerHelpers::EndFile( f );
			return;
		}
	}

	UpdateExportProgressAndCheckForCancel( num_frames, num_frames );
	AnalyzerHelpers::EndFile( f );
}
void SDIOAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
	std::ofstream file_stream( file, std::ios::out );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();
    double timeStamp = 0.0;


    if ( (export_type_user_id == SDIO_EXPORT_FULL) ||(export_type_user_id == SDIO_EXPORT_SHORT))
    {
        // if you want sample numbers
        // file_stream << "Sample Number, Time [s] ,Value ,Description" << std::endl;
        file_stream << "Time [s] ,Value ,Description" << std::endl;
    }
    else
    {
        // if you want sample numbers
        file_stream << "Sample Number, Time [s] ,Value ,Description" << std::endl;
        // file_stream << "Time [s] ,Value"<< std::endl;
    }

	U64 num_frames = GetNumFrames();
    

	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
        U64 cmdType = frame.mData1;
		
		char time_str[128];
        timeStamp = (double)frame.mStartingSampleInclusive;
        timeStamp -= trigger_sample;
        timeStamp /= sample_rate;

        if ( (export_type_user_id == SDIO_EXPORT_FULL) ||(export_type_user_id == SDIO_EXPORT_SHORT))
        {
            // only if we want sample numbers
            // sprintf(time_str, "%012lld %0.10f", frame.mStartingSampleInclusive,timeStamp);
            sprintf(time_str, "%0.10f", timeStamp);
        }
        else
        {
            // only if we want sample numbers
            // sprintf(time_str, "%012lld %0.10f", frame.mStartingSampleInclusive,timeStamp);
            sprintf(time_str, "%0.10f", timeStamp);
        }

        // if regular CMD line data
        if (frame.mType == FRAME_TYPE_CMD_DATA)
        {
            SdioCmd *tmp = SdioCmd::CreateSdioCmd(frame.mData1);

            if (tmp->getCmd() == 52)
            {

                // set up the CCCR for exporting
                // the cccr will be static, so no need to free it
                CCCR *cccr = CCCR::BuildCCCR(frame.mData1);
            }
           
            if (export_type_user_id == SDIO_EXPORT_FULL)
            {
				// const char* detail = tmp->getDetailedString();
				string *s = tmp->getDetailedString();
				file_stream << time_str << "," << "\t" << s->c_str() << endl;
                delete s;
            }
            else if (export_type_user_id == SDIO_EXPORT_SHORT)
            {
                string *s = tmp->getShortString();
                file_stream << time_str << "," << "\t" << s->c_str() << endl;
                delete s;
            }
            else
            {
                // just data
                char number_str[128];
                sprintf(number_str, "0x%012llX", frame.mData1);
                file_stream << time_str << "," << "\t" << number_str << endl;
            }
        }
        else
        {
            char number_str[128];
            // this is DATA Line Data
            sprintf(number_str, "0x%02llX", frame.mData1);
            file_stream << time_str << "," << "\t"<<number_str <<std::endl;
        }

		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			file_stream.close();
			return;
		}
	}
    CCCR::DumpCCCRTable(file_stream);
    CCCR::DumpFBRTable(file_stream);
    CCCR::CleanupCCCR();


	file_stream.close();
}
void SpriteSheet::ExportSpriteFrameDimensions(const PlatformConfig& config, std::stringstream& stream, const std::string& actorName, int sizeUniqueTiles) const
{
	for(int i = 0; i < GetNumFrames(); i++)
	{
		std::stringstream label;
		label << "actor_" << actorName << "_sheet_" << m_name << "_frame_" << i;

		u8 widthTotal;
		u8 widthWhole;
		u8 widthRemainder;
		u8 heightTotal;
		u8 heightWhole;
		u8 heightRemainder;

		std::vector<ion::Vector2i> subSprDimensionsTiles;
		std::vector<ion::Vector2i> subSprOffsetsUnflipped;
		std::vector<ion::Vector2i> subSprOffsetsFlippedX;

		GetWidthSubsprites(i, config.tileWidth, widthTotal, widthWhole, widthRemainder);
		GetHeightSubsprites(i, config.tileHeight, heightTotal, heightWhole, heightRemainder);
		GetSubspriteDimensions(i, subSprDimensionsTiles, config.tileWidth, config.tileHeight);
		GetSubspritePosOffsets(i, subSprOffsetsUnflipped, config.tileWidth, config.tileHeight);
		GetSubspritePosOffsetsFlippedX(i, subSprOffsetsFlippedX, config.tileWidth, config.tileHeight);

		int sizeTiles = sizeUniqueTiles;

		if(sizeUniqueTiles == 0)
		{
			sizeTiles = GetWidthTiles(i, config.tileWidth) * GetHeightTiles(i, config.tileHeight);
		}

		stream << label.str() << "_size_b\t\tequ 0x" << HEX4(sizeTiles * 32) << "\t; Size in bytes" << std::endl;
		stream << label.str() << "_size_t\t\tequ 0x" << HEX4(sizeTiles) << "\t; Size in tiles" << std::endl;
		stream << label.str() << "_size_subsprites\t\tequ 0x" << HEX4(widthTotal * heightTotal) << "\t; Size in subsprites" << std::endl;

		stream << std::endl;

		stream << "; Subsprite offsets from 0,0 (in pixels) - unflipped (ww) and flipped X (ww)" << std::endl;
		stream << label.str() << "_subsprite_pos_offsets:" << std::endl;

		for(int i = 0; i < subSprOffsetsUnflipped.size(); i++)
		{
			stream << "\tdc.l 0x"
				<< HEX4(subSprOffsetsUnflipped[i].x)
				<< HEX4(subSprOffsetsUnflipped[i].y)
				<< ", 0x"
				<< HEX4(subSprOffsetsFlippedX[i].x)
				<< HEX4(subSprOffsetsFlippedX[i].y)
				<< std::endl;
		}

		stream << "\tEven" << std::endl << std::endl;

		stream << "; Subsprite dimension bits (for sprite descs)" << std::endl;
		stream << label.str() << "_subsprite_dimensions_bits:" << std::endl;

		for(int i = 0; i < subSprDimensionsTiles.size(); i++)
		{
			u8 bits = ((subSprDimensionsTiles[i].x - 1) << 2) | (subSprDimensionsTiles[i].y - 1);
			stream << "\tdc.b 0x" << HEX1(bits) << std::endl;
		}

		stream << "\tEven" << std::endl << std::endl;
	}

	stream << std::dec;
	stream << std::endl;
}