コード例 #1
0
 public Intersection(IPrimitive hitPrimitive, Point3D hitPoint, Vector3D normal, float tMin, float tMax,
                     bool hitFromInSide)
 {
     this.HitPoint                 = hitPoint;
     this.Normal                   = normal;
     this.TMin                     = tMin;
     this.TMax                     = tMax;
     this.HitPrimitive             = hitPrimitive;
     this.HitFromInSide            = hitFromInSide;
     this.CurrentTextureCoordinate = UVCoordinate.Zero;
 }
コード例 #2
0
 public override void Deserialize(Stream input)
 {
     this.Version       = input.ReadValueU32();
     this.Name          = input.ReadStringAlignedU8();
     this.BillboardMode = new FourCC(input);
     this.Rotation      = new Vector4(input);
     this.Colour        = input.ReadValueU32();
     this.Uv0           = new UVCoordinate(input);
     this.Uv1           = new UVCoordinate(input);
     this.Uv2           = new UVCoordinate(input);
     this.Uv3           = new UVCoordinate(input);
     this.Width         = input.ReadValueF32();
     this.Height        = input.ReadValueF32();
     this.Distance      = input.ReadValueF32();
     this.UVOffset      = new UVCoordinate(input);
 }
コード例 #3
0
        public static Vector3D BumpNormal(Texture bumpTexture, Intersection intersection)
        {
            const float  scale = 1;
            UVCoordinate uv    = intersection.CurrentTextureCoordinate;
            float        dx    = 1.0f / (bumpTexture.Width - 1);
            float        dy    = 1.0f / (bumpTexture.Height - 1);
            float        b0    = bumpTexture.GetPixel(uv).Luminance;
            float        bx    = bumpTexture.GetPixel(uv.U + dx, uv.V).Luminance;
            float        by    = bumpTexture.GetPixel(uv.U, uv.V + dy).Luminance;


            return((intersection.Normal + new Vector3D(scale * (bx - b0) / dx, scale * (by - b0) / dy, 1)).Normalized);


            //RGBColor color = bumpTexture.GetPixel(uv);
            //Vector3D tangent1, tangent2;
            //Vector3D.Orthonormalize(intersection.Normal, out tangent1, out tangent2);
        }
コード例 #4
0
ファイル: Sphere.cs プロジェクト: rameshteatacc/projectdemo
        public override bool TryCalculateIntersection(Ray ray, out Intersection intersection)
        {
            intersection = new Intersection();

            Vector3 rayToSphere = ray.Origin - this.Position;
            float   B           = Vector3.Dot(rayToSphere, ray.Direction);
            float   C           = Vector3.Dot(rayToSphere, rayToSphere) - (Radius * Radius);
            float   D           = B * B - C;

            if (D > 0)
            {
                var          distance    = -B - (float)Math.Sqrt(D);
                var          hitPosition = ray.Origin + (ray.Direction * new Vector3(distance));
                var          normal      = hitPosition - this.Position;
                UVCoordinate uv          = this.GetUVCoordinate(hitPosition);
                intersection = new Intersection(hitPosition, normal, ray.Direction, this, Material.GetDiffuseColorAtCoordinates(uv), distance);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
ファイル: Material.cs プロジェクト: cyrsis/C-SandBox
 /// <summary>
 /// Returns the specular color of a material at the given UV coordinates.
 /// </summary>
 public Color GetSpecularColorAtCoordinates(UVCoordinate uv)
 {
     return(GetSpecularColorAtCoordinates(uv.U, uv.V));
 }
コード例 #6
0
ファイル: Material.cs プロジェクト: cyrsis/C-SandBox
 /// <summary>
 /// Returns the specular color of a material at the given UV coordinates.
 /// </summary>
 public Color GetDiffuseColorAtCoordinates(UVCoordinate uv)
 {
     return(GetDiffuseColorAtCoordinates(uv.U, uv.V));
 }
コード例 #7
0
 //public static implicit operator Texture(Bitmap texture)
 //{
 //    return new Texture(texture);
 //}
 //public void ProcessTextureImage(Bitmap texture)
 //{
 //    textureMatrix = new RGBColor[texture.Width, texture.Height];
 //    for (int i = 0; i < texture.Width; i++)
 //    {
 //        for (int j = 0; j < texture.Height; j++)
 //        {
 //            textureMatrix[i, j] = RGBColor.FromColor(texture.GetPixel(i, j));
 //        }
 //    }
 //    texture.Dispose();
 //}
 public RGBColor GetPixel(UVCoordinate uv)
 {
     return(this.textureMatrix[(int)(uv.U * this.Width), (int)(uv.V * this.Height)]);
 }
コード例 #8
0
ファイル: Material.cs プロジェクト: h8null/csharpSIMD
 /// <summary>
 /// Returns the specular color of a material at the given UV coordinates.
 /// </summary>
 public Color GetSpecularColorAtCoordinates(UVCoordinate uv)
 {
     return GetSpecularColorAtCoordinates(uv.U, uv.V);
 }
コード例 #9
0
ファイル: Material.cs プロジェクト: h8null/csharpSIMD
 /// <summary>
 /// Returns the specular color of a material at the given UV coordinates.
 /// </summary>
 public Color GetDiffuseColorAtCoordinates(UVCoordinate uv)
 {
     return GetDiffuseColorAtCoordinates(uv.U, uv.V);
 }