01-14-2014, 06:49 AM
(01-12-2014, 11:31 AM)'Jake' Wrote: Yeah, nice. But I need the actual settings (from the Inspector, so UV settings, Extrusion mode etc...)...I created a DynamicPath obj which has a component of Curvy Spline.
This is the set up.
http://oi44.tinypic.com/2z670if.jpg
In this picture I have a high amount of splines (each yellow dot is a dot in the spline)
http://oi41.tinypic.com/2a7hr0i.jpg
As soon a dot is being created, I assign a CurvyMeshPath and only at the end of the drawing (when the player starts the game) I add a mesh collider.
I have this MakeAPoint function which is quite long, it also gives stacks a location and info about every point (for an Undo button).
Code:
void MakeAPoint()
{
if (cut && !afterCut) //cut point
{
afterCut = true;
cut = false;
wasCut = true;
CurvySpline newCS = CurvySpline.Create();
newCS.name = "DynamicPath" + index;
index++;
newCS.tag = "Track"; //Delete this track also
newCS.InitialUpVector = CurvyInitialUpDefinition.ControlPoint;
current_spline = newCS;
CreateMeshBuilder();
splineStack.Push(current_spline);
}
else if (afterCut)
{
cutButton.SetActive(true);
afterCut = false;
}
point = current_spline.Add(newDotPosition);
Transform dot = point[0].transform;
segmentStack.Push(point[0].gameObject);
dot.tag = "Track";
CreateTempPoint();
if (first) //First point
{
first = false;
second = true;
firstDot = dot.position;
CreateMeshBuilder();
splineStack.Push(current_spline);
}
else if(second) //Second point
{
if (heightChanged)
{
heightChanged = false;
dirVector = newDotPosition - lastDotPosition; //This is the direction vector
dirVector.y = 0;
CurvySplineSegment css = current_spline.PreviousControlPoint(point[0]);
point[0] = current_spline.Add(true, css);
css.transform.position = lastDotPosition + dirVector * 0.2f;
dot = point[0].transform;
dot.tag = "Track";
}
second = false;
secondDot = newDotPosition;
hideButtons.SetActive(true);
cutButton.SetActive(true);
}
AllowedDraw();
lastHeight = currentHeight;
noClick.SetActive(true);
lastDirVector = dirVector;
lastDotPosition = newDotPosition;
pointsLinkedList.AddLast(newDotPosition);
toggleLinkedList.AddLast(currentToggle);
heightsLinkedList.AddLast(currentHeight);
distancesStack.Push(cur_Distance);
dirVectorsStack.Push(dirVector);
cuttedPointStack.Push(wasCut);
lastPointExists = true;
wasCut = false; //important here
undoCut = false; //important here
}
This is the code for the CurvyMeshPath creation:
Code:
void CreateMeshBuilder()
{
meshBuilder = SplinePathMeshBuilder.Create();
meshBuilder.tag = "MeshTrack";
meshBuilder.name = "CurvyMeshPath";
meshBuilder.Spline = current_spline;
meshBuilder.UV = SplinePathMeshBuilder.MeshUV.Absolute;
meshBuilder.CapShape = SplinePathMeshBuilder.MeshCapShape.Rectangle;
meshBuilder.Extrusion = SplinePathMeshBuilder.MeshExtrusion.FixedDistance;
meshBuilder.ExtrusionParameter = 1;
meshBuilder.CapHeight = 0.1f;
meshBuilder.CapWidth = 2;
meshBuilder.GetComponent<MeshRenderer>;().material = roadMat;
}
I currently can't show the CurvyMeshPath in the inspector, since every time I click on the object Unity simply crashes from unknown reason, I'll check it later and will post an image, if you need it.