Terrain slope
by Ferdinand Stewart · in Torque 3D Professional · 03/06/2012 (11:24 am) · 5 replies
Hi All,
I was hoping someone here could shed some light on how to get the slope of the terrain at XY, or something similar. like accessing the polygon.
Thoughts, function, resources anyting would be appreciated.
I found stuff in the forums, by they were all about A* in 2d or something similar.
I was hoping someone here could shed some light on how to get the slope of the terrain at XY, or something similar. like accessing the polygon.
Thoughts, function, resources anyting would be appreciated.
I found stuff in the forums, by they were all about A* in 2d or something similar.
About the author
#3
11/25/2012 (6:31 am)
I have a issue with this as well. I have a object that hits the ground (projectile actually) falls from the sky. When it hits the ground I want it to rotate to the slope of the terrain. The onCollision of the projectile gives me pos and normal (x,y,z) Since the projectile disappears I replace it with an object but when I create the object the rotation values are "1 0 0 0" which requires 4 numbers and I only have 3 from the %normal so how do I rotate the object so it lays on the side of the hill rather than half in half out ?
#4
11/25/2012 (8:42 pm)
Try calling %obj.setRotation() with the values from the normal. Should work - should face the object in the direction of the normal vector....
#5
11/28/2012 (10:23 pm)
Also, have a look at this resource: setForwardVector. You could simply set the forward vector of your object to the terrain's normal.
Associate Steve Acaster
[YorkshireRifles.com]
//start above terrain, end below terrain %start = vectorAdd(%xyz, "0 0 1");//up a bit %end = vectorSub(%xyz, "0 0 1");//down a bit %masks = $TypeMasks::TerrainObjectType; %scan = ContainerRayCast(%start, %end, %masks); // If the terrain object was found in the scan if( %scan != 0) { echo(%scan);//all of it // Get the normal of the location we clicked on %norm = getWords(%scan, 4, 6); %x = getWord(%scan, 4); %y = getWord(%scan, 5); if(%x > 0.7 || %x < -0.7 || %y > 0.7 || %y < -0.7) { echo("angle is > 40 degrees"); } else { echo("angle is < 40 degrees"); } }So, something like that, check the .chm file in documentation folder for more info on raycasts if you need it.