Пример #1
0
            public NumericValue Apply(NumericValue input)
            {
                NumericValue result;

                if (this.IntegerOperation != null &&
                    (input.ValueType == RpnValueType.Integer || input.ValueType == RpnValueType.Binary))
                {
                    double opResult = this.IntegerOperation(input.ToInteger());
                    result = new DoubleValue(opResult);
                }
                else if (this.DoubleOperation != null && input.ValueType != RpnValueType.Complex)
                {
                    double opResult = this.DoubleOperation(input.ToDouble());
                    result = new DoubleValue(opResult);
                }
                else
                {
                    Complex opResult = this.ComplexOperation(input.ToComplex());
                    result = new ComplexValue(opResult);
                }

                return(result);
            }
Пример #2
0
		public override void Prepare(DrawInfo info){
			
			// "Bake" surface property now, if we have one:
			if(SurfaceProperty==null){
				return;
			}
			
			PropertyValue value=SurfaceProperty.Value;
			
			// Numeric or colour?
			ColourValue col=value as ColourValue;
			
			if(col!=null){
				
				// It's a colour!
				Colour=col.Value;
				
				// Value is intensity:
				Value=(Colour.r + Colour.g + Colour.b) / 3.0;
				
			}else{
				
				// Try as numeric instead:
				NumericValue num=value as NumericValue;
				
				if(num!=null){
					
					// Get it as a double:
					Value=num.ToDouble();
					
					// Create a colour:
					float c=(float)Value;
					Colour=new Color(c,c,c,1f);
					
				}else{
					
					// White:
					Colour=new Color(1f,1f,1f,1f);
					Value=1.0;
					
				}
				
			}
			
			// Reset DrawStore:
			if(IsTexture){
				
				// Pull the texture:
				LiveStackNode lsn=(DrawStore as LiveStackNode);
				
				if(lsn!=null){
					
					// Set:
					lsn.Image=(SurfaceProperty.Value as TextureValue).Value;
					
					// We may now need to bump parent if we're in a Draw() call;
					// i.e. it needs to hook up this new image to its material.
					if(info.CurrentParent!=null && info.CurrentParent.DrawStore!=null){
						
						// Link away!
						Material material=info.CurrentParent.DrawStore.NodeMaterial;
						
						// Reset _srcX:
						material.SetTexture("_Src"+info.CurrentIndex,lsn.Image);
						
					}
					
				}
				
			}else{
				
				TextureStackNode tsn=(DrawStore as TextureStackNode);
				
				if(tsn!=null){
					
					// Bake:
					tsn.Bake();
					
				}
				
			}
			
		}