Example #1
0
        public override void TryAndProcess()
        {
            if (!string.IsNullOrEmpty(inputName))
            {
                if (ParentGraph != null && ParentGraph is FunctionGraph)
                {
                    FunctionGraph g = ParentGraph as FunctionGraph;

                    object temp = 0;

                    if (inputType == NodeType.Float)
                    {
                        temp = 0;
                    }
                    else if (inputType == NodeType.Bool)
                    {
                        temp = false;
                    }
                    else if (inputType == NodeType.Matrix)
                    {
                        temp = Math3D.Matrix4.Identity;
                    }
                    else
                    {
                        temp = new MathHelpers.MVector();
                    }

                    g.SetVar(inputName, temp, inputType);
                }
            }
        }
Example #2
0
        void GetQuadParams(float i, float imax, float x, float y, ref MVector trans,
                           ref MVector scale, ref float rot,
                           ref FXPivot pivot, ref FXBlend blend,
                           ref float luminosity, ref float luminosityRandomness)
        {
            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Blending"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "Blending"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "Blending").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();
                    blend = (FXBlend)Convert.ToInt32(g.Result);
                }
                else
                {
                    blend = (FXBlend)Convert.ToInt32(ParentGraph.GetParameterValue(Id, "Blending"));
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Luminosity"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "Luminosity"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "Luminosity").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();
                    luminosity = Convert.ToSingle(g.Result);
                }
                else
                {
                    luminosity = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Luminosity"));
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "LuminosityRandomness"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "LuminosityRandomness"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "LuminosityRandomness").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();
                    luminosityRandomness = Convert.ToSingle(g.Result);
                }
                else
                {
                    luminosityRandomness = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "LuminosityRandomness"));
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "PatternPivot"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "PatternPivot"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "PatternPivot").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();
                    pivot = (FXPivot)Convert.ToInt32(g.Result);
                }
                else
                {
                    pivot = (FXPivot)Convert.ToInt32(ParentGraph.GetParameterValue(Id, "PatternPivot"));
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Translation"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "Translation"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "Translation").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();

                    object o = g.Result;
                    if (o != null && o is MVector)
                    {
                        trans = (MVector)o;
                    }
                }
                else
                {
                    object o = ParentGraph.GetParameterValue(Id, "Translation");
                    if (o != null && o is MVector)
                    {
                        trans = (MVector)o;
                    }
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Scale"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "Scale"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "Scale").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();

                    object o = g.Result;
                    if (o != null && o is MVector)
                    {
                        scale = (MVector)o;
                    }
                }
                else
                {
                    object o = ParentGraph.GetParameterValue(Id, "Scale");
                    if (o != null && o is MVector)
                    {
                        scale = (MVector)o;
                    }
                }
            }

            if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Rotation"))
            {
                if (ParentGraph.IsParameterValueFunction(Id, "Rotation"))
                {
                    FunctionGraph g = ParentGraph.GetParameterRaw(Id, "Rotation").Value as FunctionGraph;
                    g.SetVar("pos", new MVector(x, y), NodeType.Float2);
                    g.SetVar("iteration", i, NodeType.Float);
                    g.SetVar("maxIterations", imax, NodeType.Float);
                    g.TryAndProcess();
                    rot = Convert.ToSingle(g.Result);
                }
                else
                {
                    rot = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Rotation"));
                }
            }
        }
Example #3
0
        private void GetTransforms()
        {
            transforms.Clear();
            if (map == null || map.Count == 0)
            {
                return;
            }

            adjustments.Clear();

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                float  alignmentAdjustment = 0;
                for (int j = 0; j < line.Length; j++)
                {
                    string ch = line.Substring(j, 1);
                    FontManager.CharData data = null;

                    MVector pPos          = position;
                    float   pcharRotation = rotation;
                    MVector pScale        = scale;

                    if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Rotation"))
                    {
                        if (ParentGraph.IsParameterValueFunction(Id, "Rotation"))
                        {
                            FunctionGraph func = ParentGraph.GetParameterRaw(Id, "Rotation").Value as FunctionGraph;
                            func.SetVar("character", j, NodeType.Float);
                            func.SetVar("maxCharacters", line.Length, NodeType.Float);
                            func.SetVar("line", i, NodeType.Float);
                            func.SetVar("maxLines", lines.Length, NodeType.Float);
                        }

                        pcharRotation = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Rotation"));
                    }

                    if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Scale"))
                    {
                        if (ParentGraph.IsParameterValueFunction(Id, "Scale"))
                        {
                            FunctionGraph func = ParentGraph.GetParameterRaw(Id, "Scale").Value as FunctionGraph;
                            func.SetVar("character", j, NodeType.Float);
                            func.SetVar("maxCharacters", line.Length, NodeType.Float);
                            func.SetVar("line", i, NodeType.Float);
                            func.SetVar("maxLines", lines.Length, NodeType.Float);
                        }

                        pScale = ParentGraph.GetParameterValue <MVector>(Id, "Position");
                    }

                    if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Position"))
                    {
                        if (ParentGraph.IsParameterValueFunction(Id, "Position"))
                        {
                            FunctionGraph func = ParentGraph.GetParameterRaw(Id, "Position").Value as FunctionGraph;
                            func.SetVar("character", j, NodeType.Float);
                            func.SetVar("maxCharacters", line.Length, NodeType.Float);
                            func.SetVar("line", i, NodeType.Float);
                            func.SetVar("maxLines", lines.Length, NodeType.Float);
                        }

                        pPos = ParentGraph.GetParameterValue <MVector>(Id, "Position");
                    }

                    CharacterTransform ct = new CharacterTransform(pcharRotation * (float)(Math.PI / 180.0f), pPos, pScale);
                    transforms.Add(ct);

                    //for these two alignments we need to calculate the
                    //actual full line width first before we do final
                    //positing and rendering
                    //to apply the proper adjustment
                    //for right alignment all we need is the total
                    //for center we need the halfway point
                    if (palignment == TextAlignment.Center || palignment == TextAlignment.Right)
                    {
                        if (map.TryGetValue(ch, out data))
                        {
                            alignmentAdjustment += data.size.X + pspacing;
                        }
                    }
                }

                if (palignment == TextAlignment.Center)
                {
                    alignmentAdjustment *= 0.5f;
                }

                adjustments.Add(alignmentAdjustment);
            }
        }