public void StartDrawing(Vector3 position, Quaternion rotation) { startPosition = position; GameObject go = Instantiate(objectCursor, Vector3.zero, Quaternion.identity) as GameObject; objectCursor.SetActive(false); if (objectType == ObjectType.Shape) { shape = go.GetComponent <ProcShape>(); shape.ResetPoint(GridSnapTool.Snap(position), transform.rotation.eulerAngles.x); // checks if there is a mirror -> make a copy if (ms.gameObject.activeSelf) { ms.CreateReflection(go, scene.transform); ms.reflection.transform.position = go.transform.position; ms.reflection.GetComponent <ProcShape>().startPoint = ms.ReflectPoint(GridSnapTool.Snap(position)); } } if (objectType == ObjectType.Section) { section = go.GetComponent <ProcSection>(); section.ResetPoint(GridSnapTool.Snap(position), transform.rotation.eulerAngles.x); // checks if there is a mirror -> make a copy if (ms.gameObject.activeSelf) { ms.CreateReflection(go, scene.transform); ms.reflection.transform.position = go.transform.position; ms.reflection.GetComponent <ProcSection>().startPoint = ms.ReflectPoint(GridSnapTool.Snap(position)); } } if (objectType == ObjectType.Hair) { go = Instantiate(Resources.Load("HairSplineTrail"), new Vector3(0, 0, 0), Quaternion.identity) as GameObject; go.GetComponent <HairSplineTrail>().Init(hairObject); hair = go.GetComponent <ProcHair>(); hair.ResetPoint(GridSnapTool.Snap(position), transform.rotation.eulerAngles.x); // checks if there is a mirror -> make a copy if (ms.gameObject.activeSelf) { ms.CreateReflection(go, scene.transform); ms.reflection.transform.position = go.transform.position; ms.reflection.GetComponent <ProcHair>().startPoint = ms.ReflectPoint(GridSnapTool.Snap(position)); } } }
public void UpdateDrawing(Vector3 pos, Vector3 up, Vector3 forward, Vector3 right) { // set the collider and the mesh if (objectType == ObjectType.Shape) { shape = shapeObject.GetComponent <ProcShape>(); Vector3 actualPosition = pos; if (ConstrainX) { actualPosition.x = StartPoint.x; } if (ConstrainY) { actualPosition.y = StartPoint.y; } if (ConstrainZ) { actualPosition.z = StartPoint.z; } //shape.SetEndPoint(actualPosition); go.GetComponent <ShapeSplineTrail>().BuildMeshTrail(GridSnapTool.Snap(actualPosition), up, forward, right); // update reflection if (ms.gameObject.activeSelf) { ms.reflection.GetComponent <ShapeSplineTrail>().BuildMeshTrail(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)), ms.ReflectVector(up), ms.ReflectVector(forward), ms.ReflectVector(right)); } ToolTracker.net[1] = 1; ToolTracker.net[2] = 2; ToolTracker.net[3] = 1; //ToolTracker.net[4] = (int)shapeObject.GetComponent<ProcShape>().m_Radius; } else if (objectType == ObjectType.Section) { Vector3 actualPosition = pos; section = sectionObject.GetComponent <ProcSection>(); if (ConstrainX) { actualPosition.x = StartPoint.x; } if (ConstrainY) { actualPosition.y = StartPoint.y; } if (ConstrainZ) { actualPosition.z = StartPoint.z; } //section.SetEndPoint(actualPosition); go.GetComponent <SectionSplineTrail>().BuildMeshTrail(GridSnapTool.Snap(actualPosition), up, forward, right); // update reflection if (ms.gameObject.activeSelf) { ms.reflection.GetComponent <SectionSplineTrail>().BuildMeshTrail(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)), -ms.ReflectVector(up), -ms.ReflectVector(forward), -ms.ReflectVector(right)); } ToolTracker.net[1] = 2; ToolTracker.net[2] = 2; ToolTracker.net[3] = 1; //ToolTracker.net[4] = (int)sectionObject.GetComponent<ProcShape>().m_Radius; } else if (objectType == ObjectType.Hair) { Vector3 actualPosition = pos; hair = sectionObject.GetComponent <ProcHair>(); if (ConstrainX) { actualPosition.x = StartPoint.x; } if (ConstrainY) { actualPosition.y = StartPoint.y; } if (ConstrainZ) { actualPosition.z = StartPoint.z; } go.GetComponent <HairSplineTrail>().BuildMeshTrail(GridSnapTool.Snap(actualPosition), up, forward, right, false); // update reflection if (ms.gameObject.activeSelf) { ms.reflection.GetComponent <HairSplineTrail>().BuildMeshTrail(ms.ReflectPoint(GridSnapTool.Snap(actualPosition)), -ms.ReflectVector(up), -ms.ReflectVector(forward), -ms.ReflectVector(right), false); } } }