public IShapeConfiguration Run(IList <string> rootArgs, IDictionary <string, string> globalArgs) { if (string.IsNullOrEmpty(this.Axiom)) { throw new InvalidOperationException("The axiom symbol has not been set"); } var configuration = new ShapeConfiguration(this.Rules); configuration.AddRule(this.Rules [this.Axiom], rootArgs.Select(x => new Argument(x)).ToList()); configuration.AddGlobalArgs(this.DefaultArgs); configuration.AddGlobalArgs(globalArgs); var currentNode = configuration.RootNode; while (currentNode != null) { this.log.Trace("EVALUTE: {0}", currentNode.Value); // IMPORTANT: The scope stack must be reset when processing a new node so that // push/pop commands only apply to rule of the current node. //this.configuration.SetScope(new Scope(currentNode.Value.Matrix)); configuration.CurrentNode = currentNode; var currentRule = currentNode.Value.Rule; if (currentRule != null) { var successors = currentRule.PickSuccessors(); foreach (var successor in successors) { if (successor is CommandShapeSuccessor) { var cmdSuccessor = (CommandShapeSuccessor)successor; cmdSuccessor.Command.Execute(configuration); } else if (successor is SymbolShapeSuccessor) { var symbolSuccessor = (SymbolShapeSuccessor)successor; var resolvedArgs = configuration.ResolveArgs(symbolSuccessor.Symbol.UnresolvedArgs); var rule = this.Rules [symbolSuccessor.Symbol.Name]; configuration.AddRule(rule, resolvedArgs); } else { throw new InvalidOperationException(string.Format("Unknown successor type ", successor)); } } } // Mark current node as Inactive and pick next one. currentNode.Value.Status = ShapeStatus.Inactive; currentNode = PickNextNode(configuration.RootNode); } return(configuration); }
// CommandBuffer[] _command_buffer = null; void Start() { configuration = configuration == null?ScriptableObject.CreateInstance <ShapeConfiguration>() : configuration; _material = new Material(Shader.Find("Shape")); _camera = GameObject.FindObjectsOfType <Camera>(); _has_command_buffer = new bool[_camera.Length]; // _command_buffer = new CommandBuffer[_camera.Length]; for (int i = 0; i < _camera.Length; i++) { _has_command_buffer[i] = false; } CreateControlObjects(); }
public static void CreateAsset() { ShapeConfiguration asset = ScriptableObject.CreateInstance <ShapeConfiguration>(); ProjectWindowUtil.CreateAsset(asset, "New " + typeof(ShapeConfiguration).Name + ".asset"); }