public StrokeRenderer GetStrokeRenderer(int index) { // Instantiate the renderer and return it StrokeRenderer renderer = Instantiate(m_AllStrokeRenderers[index]); return(renderer); }
public static Stroke GetNewStroke(StrokeRenderer sRend, int layer, float scale, Color col) { Stroke s = new GameObject("Stroke").AddComponent <Stroke>(); s.Init(sRend, layer, scale, col); return(s); }
// Sets the render being used by this stroke public void SetStrokeRenderer(StrokeRenderer strokeRend, int layer, Color col) { if (m_StrokeRenderer != null) { Destroy(m_StrokeRenderer.gameObject); } m_StrokeRenderer = strokeRend; m_StrokeRenderer.Initialize(this, layer, col); UpdateSpacedStrokeNodes(true); }
public void LoadCanvas(CanvasData c) { // Clear canvas before load Clear(); print("Loading canvas with stroke count of: " + c.m_StrokesData.Length); for (int i = 0; i < c.m_StrokesData.Length; i++) { // Get the stroke data StrokeData sData = c.m_StrokesData[i]; // Find an instantiate stroke renderer StrokeRenderer sRend = Painter3DResourceManager.Instance.GetStrokeRenderer(sData.m_RendererName); Color col = VectorExtensions.ParseVec4(sData.m_Color); // Create new stroke Stroke s = Stroke.GetNewStroke(sRend, Painter3DManager.Instance.m_PaintingLayer, float.Parse(sData.m_Scale), col); // Set stroke transform sData.m_TransformData.SetTransfrom(s.transform); /* * // Create new stroke * Stroke s = new GameObject("Stroke").AddComponent<Stroke>(); * * // Set stroke transform * sData.m_TransformData.SetTransfrom(s.transform); * * // Find an instantiate stroke renderer * StrokeRenderer sRend = Painter3DResourceManager.Instance.GetStrokeRenderer(sData.m_RendererName); * * // Initialize the stroke * s.Init(sRend, Painter3DManager.Instance.m_PaintingLayer, float.Parse(sData.m_Scale)); */ // Add stroke to canvas AddStroke(s); // Load stroke data s.LoadFromData(sData); } }
IEnumerator LoadCanvasOverTimeRoutine(CanvasData c, float duration) { // Clear canvas before load Clear(); float frameDuration = duration / c.m_StrokesData.Length; for (int i = 0; i < c.m_StrokesData.Length; i++) { // Get the stroke data StrokeData sData = c.m_StrokesData[i]; // Find an instantiate stroke renderer StrokeRenderer sRend = Painter3DResourceManager.Instance.GetStrokeRenderer(sData.m_RendererName); sRend = Instantiate(sRend); Color col = VectorExtensions.ParseVec4(sData.m_Color); // Create new stroke Stroke s = Stroke.GetNewStroke(sRend, Painter3DManager.Instance.m_PaintingLayer, float.Parse(sData.m_Scale), col); // Add stroke to canvas AddStroke(s); // Set stroke transform sData.m_TransformData.SetTransfrom(s.transform); // Load stroke data //s.LoadFromData(sData); // TESTING - loading over time s.LoadFromData(sData, frameDuration); // wait for end of frame yield return(new WaitForSeconds(frameDuration)); } }
void SetExampleStrokeRenderer(StrokeRenderer strokeRenderer) { //print("Setting sample stroke too: " + strokeRenderer); m_ExampleStroke.SetStrokeRenderer(strokeRenderer, 0, Color.gray); m_ExampleStroke.m_StrokeRenderer.DrawStroke(true); }
void Init(StrokeRenderer sRend, int layer, float scale, Color col) { SetStrokeRenderer(sRend, layer, col); m_Scale = scale; }