Ejemplo n.º 1
0
        public bool Process(List <string> addressList, ArrayList values, Matrix4x4 transform)
        {
            this.Address = addressList[0];

            var localAddress = new List <string>(addressList);

            localAddress.RemoveAt(0);

            if (localAddress.Count > 0)
            {
                switch (localAddress[0])
                {
                case "begin":
                    this.inputBuffer         = new Spline(false);
                    this.inputBuffer.Address = this.Address;
                    break;

                case "end":
                    this.Position = new Vector3D(this.inputBuffer.Position);
                    this.Vertices = new List <Vector3D>(this.inputBuffer.Vertices);
                    this.Color    = new RGBAColor();
                    this.Color.R  = this.inputBuffer.Color.R;
                    this.Color.G  = this.inputBuffer.Color.G;
                    this.Color.B  = this.inputBuffer.Color.B;
                    this.Color.A  = this.inputBuffer.Color.A;
                    this.UserData = new List <UserDataEntry>(inputBuffer.UserData);
                    this.Children = new Dictionary <string, Spline>(this.inputBuffer.Children);
                    return(true);

                case "position":
                    if (values.Count >= 3)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            this.inputBuffer.Position[i] = (double)(float)values[i];
                        }
                        if (transform != null)
                        {
                            this.inputBuffer.Position = transform * this.inputBuffer.Position;
                        }
                    }
                    break;

                case "displayColor":
                    if (values.Count >= 3)
                    {
                        this.inputBuffer.Color.R = (double)(float)values[0];
                        this.inputBuffer.Color.G = (double)(float)values[1];
                        this.inputBuffer.Color.B = (double)(float)values[2];
                    }
                    break;

                case "childCount":
                    break;

                case "userData":
                    localAddress.RemoveAt(0);
                    string propertyName = "";
                    foreach (var level in localAddress)
                    {
                        if (propertyName != "")
                        {
                            propertyName += "/";
                        }
                        propertyName += level;
                    }
                    var userDataEntry = new UserDataEntry();
                    userDataEntry.Name = propertyName;

                    foreach (var value in values)
                    {
                        if (value is int)
                        {
                            userDataEntry.Values.Add((double)(int)value);
                        }
                        else if (value is float)
                        {
                            userDataEntry.Values.Add((double)(float)value);
                        }
                    }

                    this.inputBuffer.UserData.Add(userDataEntry);
                    break;

                case "spline":
                    this.inputBuffer.Vertices.Clear();
                    for (int i = 0; i < values.Count / 3; i++)
                    {
                        var vertex = new Vector3D();
                        for (int j = 0; j < 3; j++)
                        {
                            vertex[j] = (double)(float)values[i * 3 + j];
                        }

                        if (transform != null)
                        {
                            this.inputBuffer.Vertices.Add(transform * vertex);
                        }
                        else
                        {
                            this.inputBuffer.Vertices.Add(vertex);
                        }
                    }

                    break;

                default:
                    var childName = localAddress[0];
                    if (!inputBuffer.Children.ContainsKey(childName))
                    {
                        inputBuffer.Children.Add(childName, new Spline(true));
                    }
                    inputBuffer.Children[childName].Process(localAddress, values, transform);
                    break;
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool Process(List<string> addressList, ArrayList values, Matrix4x4 transform)
        {
            this.Address = addressList[0];

            var localAddress = new List<string>(addressList);
            localAddress.RemoveAt(0);

            if (localAddress.Count > 0)
            {
                switch (localAddress[0])
                {
                    case "begin":
                        this.inputBuffer = new Spline(false);
						this.inputBuffer.Address = this.Address;
                        break;
                    case "end":
                        this.Position = new Vector3D(this.inputBuffer.Position);
                        this.Vertices = new List<Vector3D>(this.inputBuffer.Vertices);
                        this.Color = new RGBAColor();
						this.Color.R = this.inputBuffer.Color.R;
						this.Color.G = this.inputBuffer.Color.G;
						this.Color.B = this.inputBuffer.Color.B;
						this.Color.A = this.inputBuffer.Color.A;
						this.UserData = new List<UserDataEntry>(inputBuffer.UserData);
                        this.Children = new Dictionary<string,Spline>(this.inputBuffer.Children);
						return true;
					case "position":
						if (values.Count >= 3)
						{
							for(int i=0; i<3; i++) {
								this.inputBuffer.Position[i] = (double) (float) values[i];
							}
							if (transform != null)
							{
								this.inputBuffer.Position = transform * this.inputBuffer.Position;
							}
						}
						break;
					case "displayColor":
						if (values.Count >= 3)
						{
							this.inputBuffer.Color.R = (double) (float) values[0];
							this.inputBuffer.Color.G = (double) (float) values[1];
							this.inputBuffer.Color.B = (double) (float) values[2];
						}
						break;
					case "childCount":
						break;
					case "userData":
						localAddress.RemoveAt(0);
						string propertyName = "";
						foreach (var level in localAddress)
						{
							if (propertyName != "")
							{
								propertyName += "/";
							}
							propertyName += level;
						}
						var userDataEntry = new UserDataEntry();
						userDataEntry.Name = propertyName;

						foreach (var value in values)
						{
							if (value is int)
							{
								userDataEntry.Values.Add((double)(int)value);
							}
							else if (value is float)
							{
								userDataEntry.Values.Add((double)(float)value);
							}
						}

						this.inputBuffer.UserData.Add(userDataEntry);
						break;
					case "spline":
						this.inputBuffer.Vertices.Clear();
						for (int i = 0;  i < values.Count / 3; i++)
						{
							var vertex = new Vector3D();
							for(int j=0; j<3; j++)
							{
								vertex[j] = (double)(float)values[i * 3 + j];
							}

							if (transform != null)
							{
								this.inputBuffer.Vertices.Add(transform * vertex);
							}
							else
							{
								this.inputBuffer.Vertices.Add(vertex);
							}
						}

						break;
					default:
						var childName = localAddress[0];
						if (!inputBuffer.Children.ContainsKey(childName)) {
							inputBuffer.Children.Add(childName, new Spline(true));
						}
						inputBuffer.Children[childName].Process(localAddress, values, transform);
						break;
                }
            }

			return false;
        }