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
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
Question Volume Spots inter group distance Sacryn 1 3 02-27-2024, 04:08 PM
Last Post: _Aka_
  Line Renderer between two objects on a spline travellinggamedev 1 7 01-13-2024, 10:39 AM
Last Post: _Aka_
  Removing the objects behind an object alms94 6 6 12-06-2023, 09:31 PM
Last Post: _Aka_

Forum Jump: