Raycast on ForestObjectTypes
by Matthew Genge · in Torque 3D Professional · 06/20/2012 (8:24 am) · 5 replies
Dear All,
I've been trying to raycast trees in a forest object but it doesn't seem to return anything. What I want to be able to do it select an individual tree at runtime, get it's position and ID, so I can then delete it later on. I don't know if any of these things are possible, although there are cryptic references on the forum to the ForestObjectType mask. The script I am using is:
The trees have collision meshes and can be raycast when created as TSStatic objects, but it would obviously be better to use forests than try and write script to dynamically load objects. If anyone has managed to raycast individual trees in forests I'd appreciate knowing how you do this...I've already set the trees as collidable but with no effect.
Many thanks
I've been trying to raycast trees in a forest object but it doesn't seem to return anything. What I want to be able to do it select an individual tree at runtime, get it's position and ID, so I can then delete it later on. I don't know if any of these things are possible, although there are cryptic references on the forum to the ForestObjectType mask. The script I am using is:
%position = %pos;
%radius = 20.0;
%mask = $TypeMasks::ForestObjectType;
initContainerRadiusSearch( %position, %radius, %mask );
while ( (%targetObject = containerSearchNext()) != 0 )
{
echo( "Found: " @ %targetObject.getID() @ " " @ %targetObject.getModelFile() );
}The trees have collision meshes and can be raycast when created as TSStatic objects, but it would obviously be better to use forests than try and write script to dynamically load objects. If anyone has managed to raycast individual trees in forests I'd appreciate knowing how you do this...I've already set the trees as collidable but with no effect.
Many thanks
About the author
I am an Earth Scientist who likes writing games for fun.
#2
06/20/2012 (9:46 am)
Thanks Steve, but I have already used every declared mask type. It will return the forest object itself, but not the trees in the forest. It is very strange, surely it must be possible to raycast on individual objects in a forest.
#3
If your collision is failing check that it is a sealed, single-sided mesh.
Having said all that and re-reading your thread, it does appear that a radius search will not pick them up individually.
06/20/2012 (9:54 am)
ForestItems count as StaticObjectType because they are derived from TsStatic.If your collision is failing check that it is a sealed, single-sided mesh.
Having said all that and re-reading your thread, it does appear that a radius search will not pick them up individually.
#4
I just tried to use containerRayCast() and containerFindFirst() with the mask set to StaticObjectType and StaticShapeObjectType and it also returns only the forest object not the individuals. I guess this is fair enough for FPS, but not for RTS. I'd guess it is not possible...pretty much any tree will have double sided meshes for leaves.
06/20/2012 (10:25 am)
I just tried to use containerRayCast() and containerFindFirst() with the mask set to StaticObjectType and StaticShapeObjectType and it also returns only the forest object not the individuals. I guess this is fair enough for FPS, but not for RTS. I'd guess it is not possible...pretty much any tree will have double sided meshes for leaves.
#5
06/20/2012 (10:54 am)
Double sided is only an issue for colMesh.
Associate Steve Acaster
[YorkshireRifles.com]
*koff* ObjectTypes.h *koff*