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
Is there any way to get the height of a vertex from the heightfield?
Something like: Terrain.getVertexTransform(x,y);
greetings
Daniel
About the author
Torque Owner Ben Carnes
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
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); }