[vtkusers] problems with transformation loop

Alia aks01 at doc.ic.ac.uk
Sat Sep 7 07:14:26 EDT 2002


hello

I have an array of transformations, I want to apply successively to an
actor.  However my loop seems to apply each transformation to the
initial state of the actor, and not the previous state.

Instead of a smooth animation I end up with a series of very jerky
images.

I would be extremely grateful for any suggestions  :S

(code attached)

Alia



//**********************************************************8
//**********************************************************8
//***********************RUN SEQUENCE***********************8
//**********************************************************8
//**********************************************************8

void tpst::runwarpsequence(vtkThinPlateSplineTransform** mytpstArray,
					string myobj, string mytex, int
mystartframe,
					int myfinalframe, char
mycamresponse)
{  	// create a rendering window and renderer
	vtkRenderer *ren = vtkRenderer::New();
	vtkRenderWindow* renWindow = vtkRenderWindow::New();
	renWindow->AddRenderer(ren);
	//renWindow->SwapBuffersOn();

	//create an interactor and associate it with the render window
	vtkRenderWindowInteractor *RWInteractor =
vtkRenderWindowInteractor::New();
	RWInteractor->SetRenderWindow(renWindow);

	// read in object and bitmap files for surface and texture
	vtkOBJReader *reader = vtkOBJReader::New();
	reader->SetFileName(myobj.c_str());
	vtkBMPReader* readerBmp = vtkBMPReader::New();
	readerBmp->SetFileName(mytex.c_str());

	//create a texture for bitmap
	vtkTexture* atext = vtkTexture::New();
	atext->SetInput(readerBmp->GetOutput());
	atext->InterpolateOn();

	std::cout<< "The source obj file is " << myobj << endl;
	std::cout << "The source texture file is " << mytex << endl;

	//create actor
	vtkActor* faceActor = vtkActor::New();
//	faceActor->SetMapper(faceMapper);
	faceActor->SetTexture(atext);
	//faceActor->SetTexture(atext);
	faceActor->GetProperty()->SetOpacity(1);
	faceActor->GetProperty()->SetInterpolationToGouraud();
	faceActor->GetProperty()->SetColor (215, 215, 237);
	faceActor->GetProperty()->SetRepresentationToWireframe();

	//****NEW
	vtkTransformPolyDataFilter* warp =
vtkTransformPolyDataFilter::New();
   	warp->SetInput(reader->GetOutput());
   	warp->SetTransform(mytpstArray[1]);

	//LOOP here
	for (int i=mystartframe; i<=myfinalframe-1; i++)
	{

	vtkTransformPolyDataFilter* warp =
vtkTransformPolyDataFilter::New();
   	warp->SetInput(reader->GetOutput());
   	warp->SetTransform(mytpstArray[i]);
	//**I THINK THE ABOVE BIT IS WRONG


	warp->Update();
	vtkPolyDataMapper* mapper =	vtkPolyDataMapper::New();
   	mapper->SetInput(warp->GetOutput());
	mapper->Update();

	//	vtkActor* faceActor = vtkActor::New();
	faceActor->SetMapper(mapper);


	ren->AddActor(faceActor);
	renWindow->SetSize(400, 400);
	renWindow->Render();

	std::cout<<"done transformation" << i << endl;

	//RWInteractor->Start();

	//ren->RemoveActor(faceActor);
	/*
	vtkTransformPolyDataFilter* warp =
vtkTransformPolyDataFilter::New();
   	warp->SetInput(warp->GetOutput());
   	warp->SetTransform(mytpstArray[i]);
	*/	//**I BUT THIS DOESNT WORK EITHER
	}

	RWInteractor->Start();
}



---------------------------------------------------------
To lift an autumn hair is no sign of great strength;
To see the sun and moon is no sign of sharp sight;
To hear the noise of thunder is no sign of a quick ear.
-Sun Tzu on The Art Of War
---------------------------------------------------------





More information about the vtkusers mailing list