public override void Initialize()
 {
     Contract.Requires <InvalidOperationException>(NormalMapKey != null);
     base.Initialize();
     NormalMap = Content.Load <Texture>(NormalMapKey);
     if (!NormalMap.IsInited)
     {
         NormalMap.Initialize();
     }
     TextureMap.Add(TextureReference.NormalMap.ToString(), NormalMap);
 }
示例#2
0
        /// <summary>
        /// Registers one intersection of ray
        /// </summary>
        /// <param name="level">To differentiate between primary and all rays</param>
        /// <param name="rayOrigin">Origin of ray / Centre of camera</param>
        /// <param name="firstIntersection">First element of array of Intersections</param>
        public void Register(int level, Vector3d rayOrigin, Intersection firstIntersection)
        {
            if (!collectDataCheckBox.Checked)
            {
                return;
            }

            // Initial check for null references
            if (primaryRaysMap == null || allRaysMap == null || depthMap == null || normalMapRelative == null)
            {
                Initialize();
            }

            if (primaryRaysMap.mapArray == null)
            {
                primaryRaysMap.Initialize();
            }

            if (allRaysMap.mapArray == null)
            {
                allRaysMap.Initialize();
            }

            if (depthMap.mapArray == null)
            {
                depthMap.Initialize();
            }

            if (normalMapRelative.mapArray == null ||
                normalMapRelative.intersectionMapArray == null ||
                normalMapAbsolute.mapArray == null)
            {
                normalMapRelative.Initialize();
                normalMapRelative.rayOrigin = rayOrigin;

                normalMapAbsolute.Initialize();
                normalMapAbsolute.rayOrigin = rayOrigin;
            }


            double depth = Vector3d.Distance(rayOrigin, firstIntersection.CoordWorld);

            // actual registering - increasing/writing to desired arrays
            if (level == 0)
            {
                // register depth
                depthMap.mapArray [MT.x, MT.y] += depth;

                // register primary rays (those with level 0)
                primaryRaysMap.mapArray [MT.x, MT.y] += 1; // do not use ++ instead - causes problems with strong type T in Map<T>

                // register normal vector
                normalMapRelative.intersectionMapArray[MT.x, MT.y] += firstIntersection.CoordWorld;
                normalMapRelative.mapArray[MT.x, MT.y]             += firstIntersection.Normal;
            }

            // register all rays
            allRaysMap.mapArray [MT.x, MT.y] += 1;

            mapsEmpty = false;
        }