Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Placing objects on volume
#1
Hi !
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
Reply


Messages In This Thread
Placing objects on volume - by Anthonyk - 12-31-2018, 02:14 AM
RE: Placing objects on volume - by _Aka_ - 12-31-2018, 10:34 AM
RE: Placing objects on volume - by _Aka_ - 12-31-2018, 11:10 AM
RE: Placing objects on volume - by Anthonyk - 12-31-2018, 02:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace deform mesh on volume spots Kokoriko49 1 2,313 06-09-2025, 06:49 PM
Last Post: _Aka_
Photo Volume Spots problem with spacing Bond007 3 2,536 01-20-2025, 12:27 PM
Last Post: _Aka_
  Method of scattering objects along spline joebain 1 1,385 11-26-2024, 03:20 PM
Last Post: _Aka_
  Duplicate Volume references become null joebain 5 3,232 11-18-2024, 10:46 AM
Last Post: joebain

Forum Jump: