Game Development Community

Get Heightfield Vertices

by AIDan · in Torque Game Engine · 05/18/2002 (9:16 am) · 3 replies

Hi

Is there any way to get the height of a vertex from the heightfield?

Something like: Terrain.getVertexTransform(x,y);

greetings
Daniel

#1
03/18/2004 (10:08 am)
Try entering terrain.dump(); in the console to get the list of terrain methods.

I didn't see any methods for directly accessing the heightfield in the terrain script object. I think you have to mess with the C++ code to do that.

Here are the terrain script object methods
Methods:
  clearScopeToClient() - 
  delete() - 
  dump() - 
  getClassName() - 
  getForwardVector() - 
  getGroup() - 
  getHeightfieldScript() - 
  getId() - 
  getName() - 
  getObjectBox() - 
  getPosition() - 
  getScale() - 
  getTextureScript() - 
  getTransform() - 
  getType() - 
  getWorldBox() - 
  getWorldBoxCenter() - 
  save() - 
  schedule() - 
  scopeToClient() - 
  setHeightfieldScript() - 
  setName() - 
  setScale() - 
  setScopeAlways() - 
  setTextureScript() - 
  setTransform() - 
  start() - 
  stop() -

However, I found some script code that might help you. Thanks to whoever wrote it, I don't remember where I found it.

This code allows the player to spawn a static data object on the terrain. Notice that it uses ContainerRayCast to find where a vecotor would intersect the terrain.

function serverCmdinteract(%client)
{ 
   //get player position
   %player = %client.player;
   
   %eye = %player.getEyeVector();
   %vec = vectorScale(%eye, 400);

   %startPoint = %player.getEyeTransform();
   %endPoint = VectorAdd(%startPoint,%vec);
   %searchMasks = $TypeMasks::TerrainObjectType;

   //cast ray
   %object = ContainerRayCast(%startPoint,%endPoint,%searchMasks, %player); 
   echo(">object created>>" @ %object);
   
   //get
   %x = getWord(%object,1);
   echo(">object created>>" @ %x);
   %y = getWord(%object,2);
   echo(">object created>>" @ %y);
   %z = getWord(%object,3);
   echo(">object created>>" @ %z);
   
   
 %item = new StaticShape(Flag)
 {  
    position = localclientconnection.camera.getPosition();
    rotation = "1 0 0 0";
    datablock  = Flag;
 };    
  
  %item.setTransform(%x SPC %y SPC %z);

    
}
#2
03/18/2004 (10:55 am)
On the TerrainBlock class there are methods to get the height and/or normal of a location.
#3
03/20/2004 (7:56 am)


I came across a console function that might be helpful to you

getTerrainHeight, F32, 2, 2, "(Point2I pos) - gets the terrain height at the specified position."