[vtkusers] Updating scene continously

Paul Fossey pfossey at msn.com
Fri Jun 2 10:55:41 EDT 2000


On Fri, 2 Jun 2000 21:44:02 +0800, you wrote:

>I'm using vtk to display my simulation result. 
>I want the simulated result to be display on the screen continously. My simulation program will write data in a specific file(xxx.1, xxx.2, xxx.3) in every step of the simulation and a small vtk program is being written to display the data.
>
>I'm using vtkPolydata for carrying the data read in.
>Due to the architecture of vtk, I do know that, once the content in my vtkPolydata change and if renWin->Render() is triggered. Then the scene will be updated. But my problem is how to trigger 
>renWin->Render() after the "iren->Start()"???
>
>I know think of something "Timer", "onTimer" which read in new data and trigger "iren->Start" in specific time interval. But how to set this kind of timer? Can anyone help??
>
>Also, does anyone has another better approach to my problem??
>_____________________________________________________
>Sent by Hong Kong E-Mail at http://www.hkem.com
>It's free. It's easy. Sign up your account Now! 
>
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>vtkusers mailing list
>vtkusers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/vtkusers

ASSUMTION:
I assume you are implementing this on WIN32 (NT/95)

I would not recommend using a timer to generate your animation.

This is what I am doing:
---------------------------------------------------
I have a render window owned by a modal dialog box.

This is the overloaded window proc from the dialog:

///////////////////////////////////////////////////////////////////////////////
LRESULT MovieDlg::WindowProc(UINT message, WPARAM wParam, LPARAM
lParam) 
{
	if( message == WM_KICKIDLE )
	{
		// If there are more frames to process
		if( m_pController->ProcessTimeSlice() )
			return 1L;
		else
			return 0L;
	}
	return SmartDlg::WindowProc(message, wParam, lParam);
}

This is the time slice processor:
I pre create an array of position data for the movie, and then iterate
though that array to "play" the movie.

/////////////////////////////////////////////////////////////
bool Movie::ProcessTimeSlice()
{
	bool fMoreToDo = false;

	if( m_pPos && IsPlaying() )
	{
		// Move the sustainer
		GetRender3D()->GetAssembly( 1 )->AddPosition(
m_pPos->deltaX, m_pPos->deltaY, m_pPos->deltaZ );
		GetRender3D()->GetAssembly( 1 )->RotateZ(
m_pPos->deltaTheta );

		// Move the camera to track the target
		LookAt( m_pFlightPos->targetX, m_pPos->targetY,
m_pPos->targetZ );

		// Iterate to the next flight position.
		m_pPos = m_Path.GetNextPosition();

		if( m_pPos )
			fMoreToDo = true;

		GetRender3D()->Refresh( ); // Calls iren->Render()
	}
	return fMoreToDo;
}

/////////////////////////////////////////////////////////////////////
There is a descent article on using this technique at:
http://www.wdj.com/archive/0807/feature.html


I hope this helps.

Regards,
Paul.







More information about the vtkusers mailing list