counting backwards or iterating backwards, how?
by deepscratch · in Torque 3D Professional · 02/28/2014 (4:46 am) · 7 replies
hi all,
I am having a hell of a time working out how to get this piece of code and script counting from the highest counted number downwards to 1
here is the code that works counting up and the code I am trying to get to count backwards. I have also included the script bit.
this is the code
I am having a hell of a time working out how to get this piece of code and script counting from the highest counted number downwards to 1
here is the code that works counting up and the code I am trying to get to count backwards. I have also included the script bit.
this is the code
Point3F DecalRoad::getLeftCarriageWayPoint(int num) // p2 should count forward, and does
{
Point3F temp1;
if(mEdges[num].p1 > mEdges[num].p0)
{
temp1 = mEdges[num].p1 - mEdges[num].p0;
}
else
{
temp1 = mEdges[num].p0 - mEdges[num].p1;
}
RayInfo rInfo;
Point3F temp2 = mEdges[num].p0 + (temp1*0.5);//p0 is the inner point, p1 would be the center point
if (gServerContainer.castRay(Point3F(temp2.x, temp2.y, 8000), Point3F(temp2.x, temp2.y, -8000), TerrainObjectType, &rInfo))
{
return rInfo.point;
}
return temp2;
}
Point3F DecalRoad::getRightCarriageWayPoint(int num) // p0 should count backward
{
Point3F temp1;
if(mEdges[num].p1 < mEdges[num].p0)
{
temp1 = mEdges[num].p1 - mEdges[num].p0;
}
else
{
temp1 = mEdges[num].p0 - mEdges[num].p1;
}
RayInfo rInfo;
Point3F temp2 = mEdges[num].p2 + (temp1*0.5);//p2 is the outer point, p1 would be the center point
if (gServerContainer.castRay(Point3F(temp2.x, temp2.y, 8000), Point3F(temp2.x, temp2.y, -8000), TerrainObjectType, &rInfo))
{
return rInfo.point;
}
return temp2;
}About the author
email me at medan121@gmail.com
Recent Threads
#3
02/28/2014 (8:07 am)
that gets them going in the right direction, but when they reach the first(second to last)node, they lose the plot.
#5
or
isn't getNumSplinePoints the length of the internal array/vector
so nodes 0 -> (len - 1) but backwards
02/28/2014 (11:53 am)
for (%i = %decalRoad.getNumSplinePoints() - 1; %i >= 0; %i --) {
}or
%i = %decalRoad.getNumSplinePoints();
while ((%i --) > -1) {
}isn't getNumSplinePoints the length of the internal array/vector
so nodes 0 -> (len - 1) but backwards
#6
wins the day, they are now counting backwards and following the nodes in reverse order, excellent.
02/28/2014 (7:30 pm)
@Jeff Hfor (%i = %decalRoad.getNumSplinePoints() - 1; %i >= 0; %i --) {
}wins the day, they are now counting backwards and following the nodes in reverse order, excellent.
#7
02/28/2014 (7:54 pm)
glad i could help =)
Torque Owner deepscratch
DeepScratchStudios
this is the script
function WheeledVehiclePathedAI::setDecalRoadRightCarriageWay(%this,%decalRoad)//this should count backward { echo("Adding Decal Road Right to : " @ %this @ " : " @ %this.getName()); for(%i=0; %i < %decalRoad.getNumSplinePoints(); %i++){ echo("adding Right splinePoint " @ %i @ ":" @ %decalRoad.getName() @ ":" @ %decalRoad.getRightCarriageWayPoint(%i)); %this.addPathPoint("Node_" @ %i , %decalRoad.getRightCarriageWayPoint(%i), 30); } } function WheeledVehiclePathedAI::setDecalRoadLeftCarriageWay(%this,%decalRoad)//this counts forward { echo("Adding Decal Road Left to : " @ %this @ " : " @ %this.getName()); for(%i=0; %i < %decalRoad.getNumSplinePoints(); %i++){ echo("adding left splinePoint " @ %i @ ":" @ %decalRoad.getName() @ ":" @ %decalRoad.getLeftCarriageWayPoint(%i)); %this.addPathPoint("Node_" @ %i , %decalRoad.getLeftCarriageWayPoint(%i), 30); } }any help would be great.