THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/06/2004 at 01:54, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.500
Platform: Windows ;
Language(s) : C++ ;
---------
Hi.
I write a function, that calculate a global position and tangent on spline object (s. below).
Here came the problem:
if the spline type is not "linear" and have some curves, than are the calculated positions on spline not uniform (dont have same length on spline between)!
Sure, the variable "fWay" is always increase by the same value.
Where is the problem?
POSDIR posdirWayToSplinePosDir( SplineObject* pobjMain,
const Real fWay, const Real fStartPos)
{
POSDIR posdirOutput;
posdirOutput.vectPos= Vector(0);
posdirOutput.vectDir= Vector(0);
/*
if (!pobjMain)
{
return posdirOutput;
}
else if (pobjMain->GetType()!=Ospline)
{
return posdirOutput;
}
else
*/ // NOTE: trust the caller -> pointer check disabled
if (!pobjMain->InitLength(0, NULL)) // use only the 1st segment
{
return posdirOutput;
}
Real fSplNatPos=
pobjMain->UniformTonatural(fWay/pobjMain->GetLength() + fStartPos);
// natural position spline
// TODO: to implementate loop mode -> here is the place ( modulo operation)
Matrix matrSplGlob= pobjMain->GetMg(); // get the global matrix of...
posdirOutput.vectPos= pobjMain->GetSplinePoint(fSplNatPos, 0, NULL) * matrSplGlob;
// local to global coorditates convert
posdirOutput.vectDir= pobjMain->GetSplineTangent(fSplNatPos, 0, NULL) ^ matrSplGlob;
pobjMain->FreeLength(); // free memory used by GetLength
return posdirOutput;
}