12-31-2018, 02:14 AM
Hi !
I wrote this code to place objects on my spline volume :
So basically when crossTfPosition > 0, I'm searching a position on the volume, else I'm just taking the position on the spline (as crossTF 0 is on my spline).
When tfPosition is 0 or 1, I get the same position distance on spline using spline.Interpolate() and volume.InterpolateVolume(). But for any values in between, the position distance is totally different. It's like the tfPosition is stretched or not normalized in one of that functions.
Can you tell me if my code is correct, if there is a better way to do it and what could be the issue with the TF calculation ?
Thanks for support !
regards,
Anthony
I wrote this code to place objects on my spline volume :
Code:
CurvySpline spline = GetComponentInParent<CurvySpline>();
CurvyGenerator cg = transform.parent.GetComponentInChildren<CurvyGenerator>();
CGDataReference m_Volume = new CGDataReference(cg.GetComponentInChildren<BuildShapeExtrusion>(), "Volume");
CGVolume m_VolumeData = m_Volume.GetData<CGVolume>();
Vector3 p = spline.Interpolate(tfPosition);
Vector3 up = spline.GetRotatedUp(tfPosition, 0);
Vector3 fwd = spline.GetTangent(tfPosition);
if(crossTfPosition != 0 && m_VolumeData != null)
{
m_VolumeData.InterpolateVolume(tfPosition, crossTfPosition, out p, out fwd, out up);
}
transform.localPosition = p;
transform.localRotation = Quaternion.LookRotation(fwd, up);
So basically when crossTfPosition > 0, I'm searching a position on the volume, else I'm just taking the position on the spline (as crossTF 0 is on my spline).
When tfPosition is 0 or 1, I get the same position distance on spline using spline.Interpolate() and volume.InterpolateVolume(). But for any values in between, the position distance is totally different. It's like the tfPosition is stretched or not normalized in one of that functions.
Can you tell me if my code is correct, if there is a better way to do it and what could be the issue with the TF calculation ?
Thanks for support !
regards,
Anthony