Axiom.Samples.VolumeTexture.Julia.Eval C# (CSharp) Method

Eval() public method

public Eval ( float x, float y, float z ) : float
x float
y float
z float
return float
		public float Eval( float x, float y, float z )
		{
			Quat q = new Quat(), tmp = new Quat();

			int i = 0;

			q.R = x;
			q.I = y;
			q.J = z;
			q.K = 0;

			for (i = 30; i > 0; i-- )
			{
				QSqr( ref tmp, q );
				QMult( ref q, emio, tmp );
				QAdd( ref q, c );

				if ( q.R * q.R + q.I * q.I + q.J * q.J + q.K * q.K > 8.0 )
					break;
			}

			return (float)i;
		}
	}

Usage Example

Example #1
0
        protected void Generate()
        {
            var   julia  = new Julia(this.globalReal, this.globalImag, this.globalTheta);
            float scale  = 2.5f;
            float vcut   = 29.0f;
            float vscale = 1.0f / vcut;

            HardwarePixelBuffer buffer = this.ptex.GetBuffer(0, 0);

            LogManager.Instance.Write("Volume Texture Sample [info]: HardwarePixelBuffer " + buffer.Width + "x" + buffer.Height);

            buffer.Lock(BufferLocking.Normal);
            PixelBox pb = buffer.CurrentLock;

            LogManager.Instance.Write("Volume Texture Sample [info]: PixelBox " + pb.Width + "x" + pb.Height + "x" + pb.Depth);

            unsafe
            {
                var pbptr = (BufferBase)pb.Data.Clone();
                for (int z = pb.Front; z < pb.Back; z++)
                {
                    for (int y = pb.Top; y < pb.Bottom; y++)
                    {
                        pbptr += pb.Left * sizeof(uint);
                        for (int x = pb.Left; x < pb.Right; x++)
                        {
                            if (z == pb.Front || z == (pb.Back - 1) || y == pb.Top || y == (pb.Bottom - 1) || x == pb.Left ||
                                x == (pb.Right - 1))
                            {
                                pbptr.ToUIntPointer()[0] = 0;
                            }
                            else
                            {
                                float val = julia.Eval(((float)x / pb.Width - 0.5f) * scale, ((float)y / pb.Height - 0.5f) * scale,
                                                       ((float)z / pb.Depth - 0.5f) * scale);
                                if (val > vcut)
                                {
                                    val = vcut;
                                }

                                PixelConverter.PackColor((float)x / pb.Width, (float)y / pb.Height, (float)z / pb.Depth,
                                                         (1.0f - (val * vscale)) * 0.7f, PixelFormat.A8R8G8B8, pbptr);
                            }
                            pbptr++;
                        }
                        pbptr += (pb.RowPitch - pb.Right) * sizeof(uint);
                    }
                    pbptr += pb.SliceSkip * sizeof(uint);
                }
                buffer.Unlock();
            }
        }
All Usage Examples Of Axiom.Samples.VolumeTexture.Julia::Eval