Can't enumerate a scene object's link points?
by Michael Vargas · in Torque X 2D · 05/27/2007 (10:55 pm) · 6 replies
Hi,
I noticed that there seems to be no way for a T2DSceneObject to iterate through all of its linkpoints. Instead, it seems to be required that the names of the linkpoints are known by the code ahead of time, or else that some standard convention is followed. It would be nice to be able to say:
sceneObject.LinkPoints.Count
as well as:
foreach (T2DLinkPointComponent linkPoint in sceneObject.LinkPoints)
{
// do stuff
}
...but I don't know of a way to accomplish this currently.
I noticed that there seems to be no way for a T2DSceneObject to iterate through all of its linkpoints. Instead, it seems to be required that the names of the linkpoints are known by the code ahead of time, or else that some standard convention is followed. It would be nice to be able to say:
sceneObject.LinkPoints.Count
as well as:
foreach (T2DLinkPointComponent linkPoint in sceneObject.LinkPoints)
{
// do stuff
}
...but I don't know of a way to accomplish this currently.
#2
I don't have the docs with me, so the following might not be exactly accurate :| But if my memory serves me correctly, most Torque collections support standard C# IEnumerable interface. What this means is that they have some "Iterator/GetEnumerator()"-property/method that allows you to go through the items.
Not exactly an answer, but hopefully it gets you to right track :)
Matias
06/05/2007 (1:18 am)
Hi Micheal,I don't have the docs with me, so the following might not be exactly accurate :| But if my memory serves me correctly, most Torque collections support standard C# IEnumerable interface. What this means is that they have some "Iterator/GetEnumerator()"-property/method that allows you to go through the items.
Not exactly an answer, but hopefully it gets you to right track :)
Matias
#3
this is where I am now
any way to do this
int a = sceneObject.Linkpoints.count;
how could I ammend the source?
thanks
01/24/2010 (3:41 pm)
Hey, blast from the 2007 past this is where I am now
any way to do this
int a = sceneObject.Linkpoints.count;
how could I ammend the source?
thanks
#4
Assuming you want to iterate through all the link points and not just pick out one or two in the sequence then my personal inclination would be to add a custom Enumerator to the T2DLinkPointComponent class so that you can just do a foreach() on it.
01/24/2010 (5:02 pm)
T2DLinkPointComponent does register interfaces for all the link points - see: _GetInterfaces(). Although that seems a bit clunky to me since T2DSceneObject provides a LinkPoint property anyway.Assuming you want to iterate through all the link points and not just pick out one or two in the sequence then my personal inclination would be to add a custom Enumerator to the T2DLinkPointComponent class so that you can just do a foreach() on it.
#5
anything simpler i could do?
01/24/2010 (10:28 pm)
if i needed just a linkpoints.count, instead of a for each loop anything simpler i could do?
#6
01/25/2010 (12:36 pm)
Get the interfaces that were registered for the link points. Or add a method to the T2DLinkPointComponent class to give you the number of link points.
Torque Owner Michael Vargas