[vtkusers] terrain walk with vtkTerrainDataPointPlacer

saviour_91 tudord91 at yahoo.com
Mon Oct 29 14:55:54 EDT 2012


Hi there.
I am working with vtk for a few months now and I got stuck at traversing a
surface generated by a height map. I have an object and the camera is
focused on it and following it when I move it from the keyboard (like in a
third person game). I found out that the class vtkTerrainDataPointPlacer
could do the job of maintaining the object at the surface at a given height
offset. But I couldn't find a decent example. I placed the object initially
in the ground (half above the surface, half below) and called the respective
function in order to update its position and place it entirely above the
ground. But it seems it wouldn't be that easy.
A glimpse of my code is below:


objectActor->SetPosition(975, 274, -307);  //in order to be half buried
vtkSmartPointer<vtkTerrainDataPointPlacer> ter =
vtkSmartPointer<vtkTerrainDataPointPlacer>::New();
ter->AddProp(smoothedActor);  //smoothedActor is the actor in which I've
placed the interpolated terrain
ter->SetHeightOffset(10);

vtkSmartPointer<vtkCoordinate> coordinate = 
vtkSmartPointer<vtkCoordinate>::New();
coordinate->SetCoordinateSystemToNormalizedDisplay();
coordinate->SetValue(objectActor->GetPosition());
int* val;
double newWorldPos[3];
double newWorldOrientation[9];
val = coordinate->GetComputedDisplayValue(renderer);
displayPos[0] = (double)val[0];
displayPos[1] = (double)val[1];

ter->ComputeWorldPosition(renderer, displayPos, newWorldPos,
newWorldOrientation);	//computes the position for the initial point 

objectActor->SetPosition(newWorldPos[0], newWorldPos[1], newWorldPos[2]); 
//the object position is updated



The problem is the terrain and object disappear and in the vtkOutputWindow
it appears:
Warning: In C:\...\VTK\Rendering\vtkPicker.cxx, line 206
vtkPicker (04094FF0): Cannot process points


If you could tell me what is supposed to be the display position, I would be
grateful. Also, if you require my whole code, I will attach it.

Thank you in advance,
Tudor.






--
View this message in context: http://vtk.1045678.n5.nabble.com/terrain-walk-with-vtkTerrainDataPointPlacer-tp5716880.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list