public void SetSouces(IModule3D target, IModule3D sourceModule, FloatList controlFloats, ControlPointList controlPoints)
 {
     (target as ModifierModule).SourceModule = sourceModule;
     if (modifyType == ModifyType.Curve)
     {
         Curve curve = target as Curve;
         curve.ClearControlPoints();
         List <ControlPoint> controls = controlPoints.GetControls();
         foreach (ControlPoint item in controls)
         {
             curve.AddControlPoint(item);
         }
     }
     else if (modifyType == ModifyType.Terrace)
     {
         Terrace terrace = target as Terrace;
         terrace.ClearControlPoints();
         foreach (float point in controlFloats.points)
         {
             float input = point;
             terrace.AddControlPoint(input);
         }
     }
 }
示例#2
0
        public IModule3D BuildFinalModule(int globalSeed)
        {
            IModule3D module3D = null;

            primitiveLookup.Clear();
            filterLookup.Clear();
            modifierLookup.Clear();
            selectorLookup.Clear();
            transformerLookup.Clear();
            combinerLookup.Clear();
            foreach (KeyValuePair <string, Primitive> primitive in primitives)
            {
                primitiveLookup.Add(primitive.Key, primitive.Value.CreateModule(globalSeed));
            }
            foreach (KeyValuePair <string, Filter> filter in filters)
            {
                filterLookup.Add(filter.Key, filter.Value.CreateModule());
            }
            foreach (KeyValuePair <string, Modifier> modifier in modifiers)
            {
                modifierLookup.Add(modifier.Key, modifier.Value.CreateModule());
            }
            foreach (KeyValuePair <string, Selector> selector in selectors)
            {
                selectorLookup.Add(selector.Key, selector.Value.CreateModule());
            }
            foreach (KeyValuePair <string, Transformer> transformer in transformers)
            {
                transformerLookup.Add(transformer.Key, transformer.Value.CreateModule());
            }
            foreach (KeyValuePair <string, Combiner> combiner in combiners)
            {
                combinerLookup.Add(combiner.Key, combiner.Value.CreateModule());
            }
            for (int i = 0; i < links.Count; i++)
            {
                NodeLink  nodeLink       = links[i];
                IModule3D moduleFromLink = GetModuleFromLink(nodeLink.target);
                if (nodeLink.target.type == Link.Type.Terminator)
                {
                    module3D = GetModuleFromLink(nodeLink.source0);
                }
                else
                {
                    IModule3D module3D2 = null;
                    IModule3D module3D3 = null;
                    IModule3D module3D4 = null;
                    IModule3D module3D5 = null;
                    switch (nodeLink.target.type)
                    {
                    case Link.Type.Filter:
                        module3D2 = GetModuleFromLink(nodeLink.source0);
                        filters[nodeLink.target.name].SetSouces(moduleFromLink, module3D2);
                        ((FilterModule)moduleFromLink).Primitive3D = module3D2;
                        break;

                    case Link.Type.Modifier:
                    {
                        module3D2 = GetModuleFromLink(nodeLink.source0);
                        ControlPointList controlPoints = null;
                        if (nodeLink.source1 != null && nodeLink.source1.type == Link.Type.ControlPoints && controlpoints.ContainsKey(nodeLink.source1.name))
                        {
                            controlPoints = controlpoints[nodeLink.source1.name];
                        }
                        FloatList controlFloats = null;
                        if (nodeLink.source2 != null && nodeLink.source2.type == Link.Type.FloatPoints && controlpoints.ContainsKey(nodeLink.source2.name))
                        {
                            controlFloats = floats[nodeLink.source2.name];
                        }
                        modifiers[nodeLink.target.name].SetSouces(moduleFromLink, module3D2, controlFloats, controlPoints);
                        break;
                    }

                    case Link.Type.Selector:
                        module3D2 = GetModuleFromLink(nodeLink.source0);
                        module3D3 = GetModuleFromLink(nodeLink.source1);
                        module3D4 = GetModuleFromLink(nodeLink.source2);
                        selectors[nodeLink.target.name].SetSouces(moduleFromLink, module3D2, module3D3, module3D4);
                        break;

                    case Link.Type.Transformer:
                        module3D2 = GetModuleFromLink(nodeLink.source0);
                        module3D3 = GetModuleFromLink(nodeLink.source1);
                        module3D4 = GetModuleFromLink(nodeLink.source2);
                        module3D5 = GetModuleFromLink(nodeLink.source3);
                        transformers[nodeLink.target.name].SetSouces(moduleFromLink, module3D2, module3D3, module3D4, module3D5);
                        break;

                    case Link.Type.Combiner:
                        module3D2 = GetModuleFromLink(nodeLink.source0);
                        module3D3 = GetModuleFromLink(nodeLink.source1);
                        combiners[nodeLink.target.name].SetSouces(moduleFromLink, module3D2, module3D3);
                        break;
                    }
                }
            }
            Debug.Assert(module3D != null, "Missing Terminus module");
            return(module3D);
        }