Пример #1
0
 // Default Constructor
 public Light()
     : base()
 {
     red = green = blue = 255.0f;
     intensity = radius = 0.0f;
     type = LightType.Point;
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Light"/> class.
 /// </summary>
 public Light()
 {
     _CastShadows = true;
     _Enabled = true;
     _Range = 20;
     _Type = LightType.Point;
 }
        /// <summary>
        /// Constructor or added a new light to the scene
        /// </summary>
        /// <param name="type">the light type you wish to have or default of point</param>
        public LightClass(LightType type = LightType.Point)
        {
            if (type == LightType.Point)
            {
                light.Type = type;
                light.Diffuse = Color.White;
                light.Ambient = Color.White;
                light.Specular = Color.White;
                light.Position = Vector3.Zero;
                light.Range = 100.0f;

            }
            else if (type == LightType.Directional)
            {
                light.Type = type;
                light.Direction = Vector3.Zero;
                light.Ambient = Color.White;
                light.Diffuse = Color.White;
                light.Specular = Color.White;
                light.Range = 100.0f;
            }

            isLightEnabled = false;
            Type = type.ToString();
            Position = Vector3.Zero;
            Direction = Vector3.Zero;
            world = Matrix.Identity;
            mesh = Mesh.CreateSphere(DeviceManager.LocalDevice, .1f, 10, 10);

            material.Diffuse = Color.White;
            material.Ambient = Color.White;

            DeviceManager.LocalDevice.Material = material;
        }
Пример #4
0
        public Light(LightType type, Vector3D p1, Vector3D p2, Vector3D p3, Color3D color)
        {
            Type = type;
            Color = color;

            _grid = new Vector3D[16];
            _grid[0] = new Vector3D(1, 2, 0);
            _grid[1] = new Vector3D(3, 3, 0);
            _grid[2] = new Vector3D(2, 0, 0);
            _grid[3] = new Vector3D(0, 1, 0);
            _grid[4] = new Vector3D(2, 3, 0);
            _grid[5] = new Vector3D(0, 3, 0);
            _grid[6] = new Vector3D(0, 0, 0);
            _grid[7] = new Vector3D(2, 2, 0);
            _grid[8] = new Vector3D(3, 1, 0);
            _grid[9] = new Vector3D(1, 3, 0);
            _grid[10] = new Vector3D(1, 0, 0);
            _grid[11] = new Vector3D(3, 2, 0);
            _grid[12] = new Vector3D(2, 1, 0);
            _grid[13] = new Vector3D(3, 0, 0);
            _grid[14] = new Vector3D(1, 1, 0);
            _grid[15] = new Vector3D(0, 2, 0);

            CellX = (p2 - p1) * .25f;
            CellY = (p3 - p1) * .25f;

            for (int i = 0; i < 16; i++)
                _grid[i] = _grid[i][0] * CellX + _grid[i][1] * CellY + p1;

            Position = p1 + 2 * CellX + 2 * CellY;
        }
Пример #5
0
 public Light(Color _color, float _intensity, LightType _type, Point _position)
 {
     color = _color;
     intensity = _intensity;
     type = _type;
     position = _position;
 }
Пример #6
0
	/// <summary>
	/// Initializes a light, setting the light position. The
	/// diffuse color is set to white; specular and ambient are left as black.
	/// </summary>
	/// <param name="light">Which light to initialize</param>
	/// <param name="ltType">The type</param>
	public static void InitLight(Light light, LightType ltType, float x, float y, float z)
	{
		light.Type = ltType;
		light.Diffuse = System.Drawing.Color.White;
		light.Position = new Vector3(x, y, z);
		light.Direction = Vector3.Normalize(light.Position);
		light.Range = 1000.0f;
	}
Пример #7
0
 public Light(LightType type, Color color, Vector3 pos, Vector3 dir, float att)
 {
     Type = type;
     Color = color;
     Position = pos;
     Direction = dir;
     Attenuation = att;
 }
Пример #8
0
 public LightClass(LightType Type, Vector3 Position, Color Ambiant, Color Diffuse, Color Specular, float Range)
 {
     this.Type = Type;
     this.Position = Position;
     this.Ambiant = Ambiant;
     this.Diffuse = Diffuse;
     this.Specular = Specular;
     this.Range = Range;
 }
Пример #9
0
		public static void CreateApproachLight( int x, int y, int z, int off, int on, LightType light )
		{
			if ( FindMorphItem( x, y, z, off, on ) )
				return;

			MorphItem item = new MorphItem( off, on, 2, 3 );
			item.Light = light;

			item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
			m_Count++;
		}
Пример #10
0
    public static Light create(float x, float y, float size, float intensity, float r, float g, float b, float a, LightType type = LightType.VERTEX)
    {
        Light l = new Light();
        l.set_colour(r, g, b, a);
        l.attrib_size = size;
        l.set_pos(x, y);
        l.set_attribs(size, intensity);
        l.set_type(type);

        return l;
    }
Пример #11
0
 // Constructor
 public Light(float _x, float _y, float _z, float _red, float _green, float _blue, float _intensity, float _radius, 
     LightType _type, string _name)
     : base(_x, _y, _z, _name)
 {
     red = _red;
     green = _green;
     blue = _blue;
     intensity = _intensity;
     radius = _radius;
     type = _type;
 }
Пример #12
0
 public LightVO(LightVO vo)
     : base(vo)
 {
     type = vo.type;
     rays = vo.rays;
     distance = vo.distance;
     directionDegree = vo.directionDegree;
     coneDegree = vo.coneDegree;
     isStatic = vo.isStatic;
     isXRay = vo.isXRay;
     softnessLength = vo.softnessLength;
 }
Пример #13
0
		static extern void LightSceneNode_GetLight(IntPtr light, [MarshalAs(UnmanagedType.LPArray)] float[] ambient, 
                                        [MarshalAs(UnmanagedType.LPArray)] float[] diffuse, 
                                        [MarshalAs(UnmanagedType.LPArray)] float[] specular, 
                                        [MarshalAs(UnmanagedType.LPArray)] float[] pos, 
                                        [MarshalAs(UnmanagedType.LPArray)] float[] dir,
		                                [MarshalAs(UnmanagedType.LPArray)] float[] att, 
                                        ref float falloff, 
                                        ref float innercone,
                                        ref float outercone,
                                        ref float radius, 
                                        ref bool castshadows, 
                                        ref LightType type);		
Пример #14
0
 public Light(LightType lightType, Vector3 color, Vector3 position, bool castsShadows)
     : base()
 {
     this.type = lightType;
     this.Color = color;
     this.Transformation.SetPosition(position);
     this.castsShadows = castsShadows;
     if (castsShadows)
     {
         CreateCascadeShadows(1024);
     }
 }
Пример #15
0
        public int GetLight(LightType type, int x, int y, int z)
        {
            if (!IsValid(x, y, z))
                return 0;

            int chunkX = x >> 4;
            int chunkY = z >> 4;
            if (!IsChunkLoaded(chunkX, chunkY))
                return 0;

            var chunk = GetChunk(chunkX, chunkY);
            return chunk.GetLight(type, x & 0xF, y, z & 0xF);
        }
Пример #16
0
        public Light(LightType aType)
        {
            fLightType = aType;

            fConstant = 1.0f;
            fLinear = 0.0f;
            fQuadratic = 0.0f;
            fIntensity = 1.0f;
        
            // Setting up spotlight stuff
            fAngle = (float)Math.PI;
            fCosAngle = -1;
            fSinAngle = 0.0f;
            fExponent = 1.0f;

        }
Пример #17
0
        protected Light(LightType lightType)
        {
            LightType = lightType;

            Texture2D LightTexture = LightTextureBuilder.CreatePointLight(Renderer.GD, 512);

            KryptonLight = new Light2D()
            {
                Texture = LightTexture,
                Range = (float)(1.5f),
                Color = new Color(0.8f, 0.8f, 0.8f, 1f),
                Intensity = 1f,
                Angle = MathHelper.TwoPi * 0.5f,
                X = (float)(0),
                Y = (float)(0),
            };
        }
Пример #18
0
        public LightType type; //read

        #endregion Fields

        #region Constructors

        public LightData(ConfigNode node, Part part)
        {
            name = node.GetStringValue("name");
            intensity = node.GetFloatValue("intensity");
            range = node.GetFloatValue("range");
            angle = node.GetFloatValue("angle");
            type = (LightType)Enum.Parse(typeof(LightType), node.GetStringValue("type", LightType.Point.ToString()));

            transform = part.transform.FindRecursive(name);
            light = transform.GetComponent<Light>();
            if (light == null)
            {
                light = transform.gameObject.AddComponent<Light>();//add it if it does not exist
            }

            light.intensity = intensity;
            light.range = range;
            light.spotAngle = angle;
            light.type = type;
        }
Пример #19
0
        public LightSource(float[] RGB, Vector2 worldPos, LightType type, int range, GraphicsDevice graphicsDevice)
        {
            this.RGB = RGB;
            this.worldPos = worldPos;
            this.type = type;
            this.range = range;
            area = new RenderTarget2D(graphicsDevice, range*2, range*2);
            output.Add(new RenderTarget2D(graphicsDevice, range * 2, range * 2));
            output.Add(new RenderTarget2D(graphicsDevice, range * 2, range * 2));
            int order = 2;
            while(Math.Pow(2,order)<=range*2)
            {
                output.Add(new RenderTarget2D(graphicsDevice, (range * 2) / (int)Math.Pow(2, order), (range * 2)));
                order++;
            }

            RenderArea.X = 0;
            RenderArea.Y = 0;
            RenderArea.Width = 2*range;
            RenderArea.Height = 2*range;
        }
        LightSource FetchLight(LightType type, Color color, float intensity, float range, float spotAngle = 0.0f)
        {
            LightSource light = null;

            if (activeHeadlights.Count == 0)
            {
                light = Singleton<RenderManager>.instance.ObtainLightSource();
            }
            else
            {
                light = activeHeadlights[0];
                activeHeadlights.RemoveAt(0);
            }

            light.m_light.intensity = intensity*fadingHeadlightsFactor;
            light.m_light.type = type;
            light.m_light.color = color;
            light.m_light.range = range;
            light.m_light.spotAngle = spotAngle;
            light.m_light.shadows = LightShadows.None;
            light.enabled = true;

            return light;
        }
Пример #21
0
		/// <summary>
		///    Default constructor.
		/// </summary>
		/// <param name="parent">Technique that owns this Pass.</param>
		/// <param name="index">Index of this pass.</param>
		public Pass( Technique parent, int index )
		{
			this._parent = parent;
			this._index = index;

			lock ( passLock )
			{
				this.passId = nextPassId++;
			}

			// color defaults
			_ambient = ColorEx.White;
			_diffuse = ColorEx.White;
			_specular = ColorEx.Black;
			_emissive = ColorEx.Black;

			// by default, don't override the scene's fog settings
			_fogOverride = false;
			_fogMode = FogMode.None;
			_fogColor = ColorEx.White;
			_fogStart = 0;
			_fogEnd = 1;
			_fogDensity = 0.001f;

			// default blending (overwrite)
			_sourceBlendFactor = SceneBlendFactor.One;
			_destinationBlendFactor = SceneBlendFactor.Zero;



			// depth buffer settings
			_depthCheck = true;
			_depthWrite = true;
			_colorWriteEnabled = true;
			_depthFunction = CompareFunction.LessEqual;

			// cull settings
			_cullingMode = CullingMode.Clockwise;
			_manualCullingMode = ManualCullingMode.Back;

			// light settings
			_lightingEnabled = true;
			_runOnlyForOneLightType = true;
			_onlyLightType = LightType.Point;
			_shadingMode = Shading.Gouraud;

			// Default max lights to the global max
			_maxSimultaneousLights = Config.MaxSimultaneousLights;

			_name = index.ToString();

            IterationCount = 1;

			DirtyHash();
		}
Пример #22
0
        /// <summary>
        /// Method allowing to add a MenuItem to quickly build GameObjects with the component assigned
        /// </summary>
        /// <param name="menuCommand">Stuff that Unity automatically fills with some editor's contextual infos</param>
        /// <param name="name">The name of the new GameObject</param>
        /// <param name="type">The desired light's type</param>
        /// <returns>The created AuraLight gameObject</returns>
        private static GameObject CreateGameObject(MenuCommand menuCommand, string name, LightType type)
        {
            GameObject newGameObject = new GameObject(name);

            GameObjectUtility.SetParentAndAlign(newGameObject, menuCommand.context as GameObject);
            Undo.RegisterCreatedObjectUndo(newGameObject, "Create " + newGameObject.name);
            Selection.activeObject = newGameObject;

            newGameObject.AddComponent <Light>();
            newGameObject.GetComponent <Light>().type    = type;
            newGameObject.GetComponent <Light>().shadows = LightShadows.Soft;
            newGameObject.AddComponent <AuraLight>();

            return(newGameObject);
        }
Пример #23
0
 /// <summary>
 ///		General purpose method to get any of the program sources.
 /// </summary>
 /// <param name="lightType">Type of light to get the source for.</param>
 /// <param name="syntax">Syntax code of interest.</param>
 /// <param name="finite">Is this for finite volume extrusion?</param>
 /// <param name="debug">Should the shadow volumes be visible?</param>
 /// <returns>Source of the specified program.</returns>
 public static string GetProgramSource(LightType lightType, string syntax, bool finite, bool debug)
 {
     if (lightType == LightType.Directional)
     {
         if (syntax == "arbvp1")
         {
             if (finite)
             {
                 if (debug)
                 {
                     return(dirArbvp1FiniteDebug);
                 }
                 else
                 {
                     return(dirArbvp1Finite);
                 }
             }
             else
             {
                 if (debug)
                 {
                     return(dirArbvp1Debug);
                 }
                 else
                 {
                     return(dirArbvp1);
                 }
             }
         }
         else
         {
             if (finite)
             {
                 if (debug)
                 {
                     return(dirVs_1_1FiniteDebug);
                 }
                 else
                 {
                     return(dirVs_1_1Finite);
                 }
             }
             else
             {
                 if (debug)
                 {
                     return(dirVs_1_1Debug);
                 }
                 else
                 {
                     return(dirVs_1_1);
                 }
             }
         }
     }
     else
     {
         if (syntax == "arbvp1")
         {
             if (finite)
             {
                 if (debug)
                 {
                     return(pointArbvp1FiniteDebug);
                 }
                 else
                 {
                     return(pointArbvp1Finite);
                 }
             }
             else
             {
                 if (debug)
                 {
                     return(pointArbvp1Debug);
                 }
                 else
                 {
                     return(pointArbvp1);
                 }
             }
         }
         else
         {
             if (finite)
             {
                 if (debug)
                 {
                     return(pointVs_1_1FiniteDebug);
                 }
                 else
                 {
                     return(pointVs_1_1Finite);
                 }
             }
             else
             {
                 if (debug)
                 {
                     return(pointVs_1_1Debug);
                 }
                 else
                 {
                     return(pointVs_1_1);
                 }
             }
         }
     }
 }
Пример #24
0
 public Light(LightType type, float intens, Vector3 pos = default(Vector3))
 {
     LightType = type;
     Intensity = intens;
     Position  = pos;
 }
Пример #25
0
        /// <summary>
        /// Initializes the component (command buffers, registrations, events, managed members ...)
        /// </summary>
        private void Initialize()
        {
            AuraCamera.OnRegisteredAuraCamerasListChanged += AuraCamera_OnRegistredAuraCamerasListChanged;

            IsActive = AuraCamera.HasRegisteredAuraCameras;
            if (!IsActive)
            {
                return;
            }

            InitializeResources();

            _lightComponent    = GetComponent <Light>();
            _previousLightType = Type;

            if (CastsShadows)
            {
                Vector2Int shadowMapSize = new Vector2Int(0, 0);
                switch (Type)
                {
                case LightType.Directional:
                {
                    shadowMapSize = DirectionalLightsManager.ShadowMapSize;
                }
                break;

                case LightType.Spot:
                {
                    shadowMapSize = SpotLightsManager.shadowMapSize;
                }
                break;

                case LightType.Point:
                {
                    shadowMapSize = PointLightsManager.shadowMapSize;
                }
                break;
                }

                shadowMapRenderTexture      = new RenderTexture(shadowMapSize.x, shadowMapSize.y, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
                shadowMapRenderTexture.name = gameObject.name + " : Shadow Map Render Texture";
                shadowMapRenderTexture.Create();
                RenderTargetIdentifier shadowMapRenderTextureIdentifier = BuiltinRenderTextureType.CurrentActive;
                _copyShadowmapCommandBuffer      = new CommandBuffer();
                _copyShadowmapCommandBuffer.name = "Aura 2 : Store shadowmap";
                _copyShadowmapCommandBuffer.SetShadowSamplingMode(shadowMapRenderTextureIdentifier, ShadowSamplingMode.RawDepth);
                _copyShadowmapCommandBuffer.Blit(shadowMapRenderTextureIdentifier, new RenderTargetIdentifier(shadowMapRenderTexture));
                LightComponent.AddCommandBuffer(LightEvent.AfterShadowMap, _copyShadowmapCommandBuffer);

                switch (Type)
                {
                case LightType.Point:
                {
                    _storePointLightShadowMapMaterial = new Material(_storePointLightShadowMapShader);
                }
                break;

                case LightType.Directional:
                {
                    if (shadowDataRenderTexture == null)
                    {
                        shadowDataRenderTexture      = new RenderTexture(32, 1, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
                        shadowDataRenderTexture.name = gameObject.name + " : Shadow Data Render Texture";
                    }

                    _storeShadowDataCommandBuffer      = new CommandBuffer();
                    _storeShadowDataCommandBuffer.name = "Aura 2 : Store directional shadow data";

                    _storeShadowDataMaterial = new Material(_storeDirectionalShadowDataShader);

                    LightComponent.AddCommandBuffer(LightEvent.BeforeScreenspaceMask, _storeShadowDataCommandBuffer);

                    _storeShadowDataCommandBuffer.Blit(null, new RenderTargetIdentifier(shadowDataRenderTexture), _storeShadowDataMaterial);

                    AuraCamera.CommonDataManager.LightsCommonDataManager.OnShadowsSettingsChanged += LightsCommonDataManager_OnCascadesCountChanged;
                }
                break;
                }
            }

            _previousUseShadow = CastsShadows;

            if (CastsCookie)
            {
                Vector2Int cookieMapSize = Vector2Int.zero;
                switch (Type)
                {
                case LightType.Directional:
                {
                    cookieMapSize = DirectionalLightsManager.cookieMapSize;
                }
                break;

                case LightType.Spot:
                {
                    cookieMapSize = SpotLightsManager.cookieMapSize;
                }
                break;

                case LightType.Point:
                {
                    cookieMapSize = PointLightsManager.cookieMapSize;
                }
                break;
                }

                cookieMapRenderTexture      = new RenderTexture(cookieMapSize.x, cookieMapSize.y, 0, RenderTextureFormat.R8);
                cookieMapRenderTexture.name = gameObject.name + " : Cookie Map Render Texture";

                switch (Type)
                {
                case LightType.Point:
                {
                    _storeCookieMapMaterial = new Material(_storePointLightCookieMapShader);
                }
                break;

                default:
                {
                    _storeCookieMapMaterial = new Material(_storeDirectionalSpotCookieMapShader);
                }
                break;
                }
            }

            _previousUseCookie = CastsCookie;

            AuraCamera.CommonDataManager.LightsCommonDataManager.RegisterLight(this);

            Camera.onPreCull   += Camera_onPreCull;
            Camera.onPreRender += Camera_onPreRender;

            _isInitialized = true;
        }
Пример #26
0
 private static extern void Internal_SetType(IntPtr instance, LightType value);
Пример #27
0
        /// <summary>
        /// Initializes the component (command buffers, registrations, events, managed members ...)
        /// </summary>
        private void Initialize()
        {
            _lightComponent    = GetComponent <Light>();
            _previousLightType = Type;

            if (CastsShadows)
            {
                Vector2Int shadowMapSize = new Vector2Int(0, 0);
                switch (Type)
                {
                case LightType.Directional:
                {
                    shadowMapSize = DirectionalLightsManager.ShadowMapSize;
                }
                break;

                case LightType.Spot:
                {
                    shadowMapSize = SpotLightsManager.shadowMapSize;
                }
                break;

                case LightType.Point:
                {
                    shadowMapSize = PointLightsManager.shadowMapSize;
                }
                break;
                }

                shadowMapRenderTexture = new RenderTexture(shadowMapSize.x, shadowMapSize.y, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
                shadowMapRenderTexture.Create();
                RenderTargetIdentifier shadowMapRenderTextureIdentifier = BuiltinRenderTextureType.CurrentActive;
                _copyShadowmapCommandBuffer = new CommandBuffer
                {
                    name = "Aura : Copy light's shadowmap"
                };
                _copyShadowmapCommandBuffer.SetShadowSamplingMode(shadowMapRenderTextureIdentifier, ShadowSamplingMode.RawDepth);
                _copyShadowmapCommandBuffer.Blit(shadowMapRenderTextureIdentifier, new RenderTargetIdentifier(shadowMapRenderTexture));
                _lightComponent.AddCommandBuffer(LightEvent.AfterShadowMap, _copyShadowmapCommandBuffer);

                switch (Type)
                {
                case LightType.Point:
                {
                    _storePointLightShadowMapMaterial = new Material(storePointLightShadowMapShader);
                }
                break;

                case LightType.Directional:
                {
                    if (shadowDataRenderTexture == null)
                    {
                        shadowDataRenderTexture = new RenderTexture(32, 1, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
                    }

                    _storeShadowDataCommandBuffer = new CommandBuffer
                    {
                        name = "Aura : Store directional light's shadow data"
                    };

                    _storeShadowDataMaterial = new Material(storeShadowDataShader);

                    _lightComponent.AddCommandBuffer(LightEvent.BeforeScreenspaceMask, _storeShadowDataCommandBuffer);

                    _storeShadowDataCommandBuffer.Blit(null, new RenderTargetIdentifier(shadowDataRenderTexture), _storeShadowDataMaterial);

                    Aura.LightsManager.DirectionalLightsManager.OnCascadesCountChanged += DirectionalLightsManager_onCascadesCountChanged;
                }
                break;
                }
            }

            _previousUseShadow = CastsShadows;

            if (CastsCookie)
            {
                Vector2Int cookieMapSize = Vector2Int.zero;
                switch (Type)
                {
                case LightType.Directional:
                {
                    cookieMapSize = DirectionalLightsManager.cookieMapSize;
                }
                break;

                case LightType.Spot:
                {
                    cookieMapSize = SpotLightsManager.cookieMapSize;
                }
                break;

                case LightType.Point:
                {
                    cookieMapSize = PointLightsManager.cookieMapSize;
                }
                break;
                }

                cookieMapRenderTexture = new RenderTexture(cookieMapSize.x, cookieMapSize.y, 0, RenderTextureFormat.R8);

                switch (Type)
                {
                case LightType.Point:
                {
                    _storeCookieMapMaterial = new Material(storePointLightCookieMapShader);
                }
                break;

                default:
                {
                    _storeCookieMapMaterial = new Material(storeDirectionalSpotLightCookieMapShader);
                }
                break;
                }
            }

            _previousUseCookie = CastsCookie;

            Aura.LightsManager.Register(this, CastsShadows, CastsCookie);
            if (_isRegistered)
            {
                Debug.Log("");//this is just here to remove not used error from console
            }
            _isRegistered = true;

            Aura.OnPreCullEvent   += Aura_onPreCullEvent;
            Aura.OnPreRenderEvent += Aura_onPreRenderEvent;

            _isInitialized = true;
        }
Пример #28
0
 public void set_type(LightType t)
 {
     type = t;
     set_attribs(attrib_size, attrib_intensity);
     set_pos(v_pos.x, v_pos.z);
 }
Пример #29
0
 public static List <Light> GetLights(LightType type, int layer)
 {
     return(null);
 }
Пример #30
0
 public LightClusterLinkedNode(LightType lightType, int lightIndex, int nextNode)
 {
     LightType  = lightType;
     LightIndex = lightIndex;
     NextNode   = nextNode;
 }
Пример #31
0
            private void AddLightToCluster(Dictionary <LightClusterLinkedNode, int> movedClusters, LightType lightType, int lightIndex, int clusterIndex)
            {
                var nextNode = -1;

                if (lightNodes.Items[clusterIndex].LightIndex != -1)
                {
                    var movedCluster = lightNodes.Items[clusterIndex];

                    // Try to check if same linked-list doesn't already exist
                    if (!movedClusters.TryGetValue(movedCluster, out nextNode))
                    {
                        // First time, let's add it
                        nextNode = lightNodes.Count;
                        movedClusters.Add(movedCluster, nextNode);
                        lightNodes.Add(movedCluster);
                    }
                }

                // Replace new linked-list head
                lightNodes.Items[clusterIndex] = new LightClusterLinkedNode(lightType, lightIndex, nextNode);
            }
Пример #32
0
 private void LightType_SelectedIndexChanged(object sender, EventArgs e)
 {
     _lightType           = (LightType)lstLightType.SelectedIndex;
     _eventArgs.LightType = _lightType;
     OnLightTypeChanged();
 }
Пример #33
0
 public void Setup(int exposureTime, int gain, LightType lightType)
 {
     this.tbrExposure.Value     = MathUtils.Limit(exposureTime, this.tbrExposure.Minimum, this.tbrExposure.Maximum);
     this.tbrGain.Value         = MathUtils.Limit(gain, this.tbrGain.Minimum, this.tbrGain.Maximum);
     this.cbxLight.SelectedItem = lightType;
 }
 internal void IncrementLightTypeCount( LightType lightType )
 {
     lightTypeCount[ (uint)lightType ]++;
 }
Пример #35
0
    public void UpdateLightType()
    {
        if (m_Light == null)
            m_Light = GetComponent<Light>();

        m_LightType = m_Light.type;
    }
Пример #36
0
    public static Light create(float x, float y, float size, float intensity, float r, float g, float b, float a, LightType type = LightType.VERTEX)
    {
        Light l = new Light();

        l.set_colour(r, g, b, a);
        l.attrib_size = size;
        l.set_pos(x, y);
        l.set_attribs(size, intensity);
        l.set_type(type);

        return(l);
    }
Пример #37
0
		public static extern Light[] GetLights(LightType type, int layer);
 public UseLightModeRule(string name, LightType type, LightmapBakeType[] unusableBakeTypes) : base(name)
 {
     this.type = type;
     this.unusableBakeTypes = unusableBakeTypes;
 }
Пример #39
0
 public LightEntry(LightType light, params int[] itemIDs)
 {
     m_Light   = light;
     m_ItemIDs = itemIDs;
 }
Пример #40
0
		private static int smethod_6(LightType lightType_0, LightType lightType_1)
		{
			return lightType_0.Name.CompareTo(lightType_1.Name);
		}
Пример #41
0
        public EmergencyLights(float distance, float angleDifference, LightType redLightType, LightType blueLightType, int timingIndex)
        {
            redLightLocalRotation  = 0 - (angleDifference / 2);
            blueLightLocalRotation = 0 + (angleDifference / 2);

            redLightSpriteRotation  = 0;
            blueLightSpriteRotation = 0;

            redLightLocalDistance  = distance;
            blueLightLocalDistance = distance;
            this.redLight          = GraphicsManager.GetLight(redLightType);
            this.blueLight         = GraphicsManager.GetLight(blueLightType);
            this.timingIndex       = timingIndex;
        }
Пример #42
0
 /// <summary>
 /// Deserializes this PointLight.
 /// </summary>
 /// <param name="input">Input to read from</param>
 public override void Read(Content.ISavableReader input)
 {
     base.Read(input);
     _lightType = (LightType)input.ReadInt();
     _position  = input.ReadVector3();
 }
Пример #43
0
        /// <summary>
        ///		Initialize the creation of these core vertex programs.
        /// </summary>
        public static void Initialize()
        {
            // only need to initialize once
            if (!isInitialized)
            {
                var syntax = "";

                // flags for which of the programs use finite extrusion
                var vertexProgramFinite = new bool[]
                {
                    false, false, false, false, true, true, true, true
                };

                // flags for which of the programs use debug rendering
                var vertexProgramDebug = new bool[]
                {
                    false, true, false, true, false, true, false, true
                };

                // types of lights that each of the programs target
                var vertexProgramLightTypes = new LightType[]
                {
                    LightType.Point, LightType.Point, LightType.Directional, LightType.Directional,
                    LightType.Point, LightType.Point, LightType.Directional, LightType.Directional
                };

                // load hardware extrusion programs for point & dir lights
                if (GpuProgramManager.Instance.IsSyntaxSupported("arbvp1"))
                {
                    syntax = "arbvp1";
                }
                else if (GpuProgramManager.Instance.IsSyntaxSupported("vs_1_1"))
                {
                    syntax = "vs_1_1";
                }
                else
                {
                    throw new AxiomException(
                              "Vertex programs are supposedly supported, but neither arbvp1 nor vs_1_1 syntaxes are supported.");
                }

                // create the programs
                for (var i = 0; i < programNames.Length; i++)
                {
                    // sanity check to make sure it doesn't already exist
                    if (GpuProgramManager.Instance.GetByName(programNames[i]) == null)
                    {
                        var source = ShadowVolumeExtrudeProgram.GetProgramSource(vertexProgramLightTypes[i], syntax,
                                                                                 vertexProgramFinite[i], vertexProgramDebug[i]);

                        // create the program from the static source
                        var program = GpuProgramManager.Instance.CreateProgramFromString(programNames[i],
                                                                                         ResourceGroupManager.InternalResourceGroupName,
                                                                                         source, GpuProgramType.Vertex, syntax);

                        // load the program
                        program.Load();
                    }
                }

                isInitialized = true;
            }
        }
Пример #44
0
 public Light(LightType type, IVector position, IRGBColor color)
 {
     this.Type     = type;
     this.Position = position;
     this.Color    = color;
 }
Пример #45
0
 public void SetType(LightType type)
 {
     Description.Type = ( int )type;
 }
Пример #46
0
 public Light(LightType type) : this(type, null, null)
 {
 }
Пример #47
0
 /// <summary>
 /// Method allowing to add a MenuItem to quickly build GameObjects with the component assigned
 /// </summary>
 /// <param name="name">The name of the new GameObject</param>
 /// <param name="type">The desired light's type</param>
 /// <returns>The created AuraLight gameObject</returns>
 public static GameObject CreateGameObject(string name, LightType type)
 {
     return(CreateGameObject(new MenuCommand(null), name, type));
 }
Пример #48
0
 private static extern void Internal_setType(IntPtr thisPtr, LightType type);
Пример #49
0
		/// <summary>
		///    Sets whether or not this pass should be run once per light which 
		///    can affect the object being rendered.
		/// </summary>
		/// <remarks>
		///    The default behavior for a pass (when this option is 'false'), is 
		///    for a pass to be rendered only once, with all the lights which could 
		///    affect this object set at the same time (up to the maximum lights 
		///    allowed in the render system, which is typically 8). 
		///    <p/>
		///    Setting this option to 'true' changes this behavior, such that 
		///    instead of trying to issue render this pass once per object, it 
		///    is run once <b>per light</b> which can affect this object. In 
		///    this case, only light index 0 is ever used, and is a different light 
		///    every time the pass is issued, up to the total number of lights 
		///    which is affecting this object. This has 2 advantages: 
		///    <ul><li>There is no limit on the number of lights which can be 
		///    supported</li> 
		///    <li>It's easier to write vertex / fragment programs for this because 
		///    a single program can be used for any number of lights</li> 
		///    </ul> 
		///    However, this technique is a lot more expensive, and typically you 
		///    will want an additional ambient pass, because if no lights are 
		///    affecting the object it will not be rendered at all, which will look 
		///    odd even if ambient light is zero (imagine if there are lit objects 
		///    behind it - the objects silhouette would not show up). Therefore, 
		///    use this option with care, and you would be well advised to provide 
		///    a less expensive fallback technique for use in the distance. 
		///    <p/>
		///    Note: The number of times this pass runs is still limited by the maximum 
		///    number of lights allowed as set in MaxLights, so 
		///    you will never get more passes than this. 
		/// </remarks>
		/// <param name="enabled">Whether this feature is enabled.</param>
		/// <param name="onlyForOneLightType">
		///    If true, the pass will only be run for a single type of light, other light types will be ignored. 
		/// </param>
		/// <param name="lightType">The single light type which will be considered for this pass.</param>
		public void SetRunOncePerLight( bool enabled, bool onlyForOneLightType, LightType lightType )
		{
			_iteratePerLight = enabled;
			_runOnlyForOneLightType = onlyForOneLightType;
			_onlyLightType = lightType;
		}
Пример #50
0
 public static extern Light[] GetLights(LightType type, int layer);
Пример #51
0
		/// <summary>
		///		Normal constructor. Should not be called directly, but rather the SceneManager.CreateLight method should be used.
		/// </summary>
		/// <param name="name"></param>
		public Light( string name )
			: base( name )
		{
			// Default to point light, white diffuse light, linear attenuation, fair range
			this.type = LightType.Point;
			this.diffuse = ColorEx.White;
			this.specular = ColorEx.Black;
			this.range = 100000;
			this.attenuationConst = 1.0f;
			this.attenuationLinear = 0.0f;
			this.attenuationQuad = 0.0f;

			// Center in world, direction irrelevant but set anyway
			this.position = Vector3.Zero;
			this.direction = Vector3.UnitZ;

			// Default some spot values
			this.spotInner = 30.0f;
			this.spotOuter = 40.0f;
			this.spotFalloff = 1.0f;

			this.localTransformDirty = false;
		}
Пример #52
0
 internal static extern void Light_SetLightType(IntPtr handle, LightType type);
Пример #53
0
 public void UpdateLightType()
 {
     m_LightType = light.type;
 }
Пример #54
0
 /// <summary>
 /// Set light type.
 /// </summary>
 private void SetLightType(LightType type)
 {
     Runtime.ValidateRefCounted(this);
     Light_SetLightType(handle, type);
 }
 public override void Reset()
 {
     gameObject = null;
     lightType = LightType.Point;
 }
Пример #56
0
        private static bool FindItem(int x, int y, int z, Map map, Item srcItem)
        {
            int itemID = srcItem.ItemID;

            bool res = false;

            IPooledEnumerable eable;

            if (srcItem is BaseDoor)
            {
                eable = map.GetItemsInRange(new Point3D(x, y, z), 1);

                foreach (Item item in eable)
                {
                    if (!(item is BaseDoor))
                    {
                        continue;
                    }

                    BaseDoor bd = (BaseDoor)item;
                    Point3D  p;
                    int      bdItemID;

                    if (bd.Open)
                    {
                        p        = new Point3D(bd.X - bd.Offset.X, bd.Y - bd.Offset.Y, bd.Z - bd.Offset.Z);
                        bdItemID = bd.ClosedID;
                    }
                    else
                    {
                        p        = bd.Location;
                        bdItemID = bd.ItemID;
                    }

                    if (p.X != x || p.Y != y)
                    {
                        continue;
                    }

                    if (item.Z == z && bdItemID == itemID)
                    {
                        res = true;
                    }
                    else if (Math.Abs(item.Z - z) < 8)
                    {
                        m_DeleteQueue.Enqueue(item);
                    }
                }
            }
            else if ((TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.LightSource) != 0)
            {
                eable = map.GetItemsInRange(new Point3D(x, y, z), 0);

                LightType lt      = srcItem.Light;
                string    srcName = srcItem.ItemData.Name;

                foreach (Item item in eable)
                {
                    if (item.Z == z)
                    {
                        if (item.ItemID == itemID)
                        {
                            if (item.Light != lt)
                            {
                                m_DeleteQueue.Enqueue(item);
                            }
                            else
                            {
                                res = true;
                            }
                        }
                        else if ((item.ItemData.Flags & TileFlag.LightSource) != 0 && item.ItemData.Name == srcName)
                        {
                            m_DeleteQueue.Enqueue(item);
                        }
                    }
                }
            }
            else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook)
            {
                eable = map.GetItemsInRange(new Point3D(x, y, z), 0);

                Type type = srcItem.GetType();

                foreach (Item item in eable)
                {
                    if (item.Z == z && item.ItemID == itemID)
                    {
                        if (item.GetType() != type)
                        {
                            m_DeleteQueue.Enqueue(item);
                        }
                        else
                        {
                            res = true;
                        }
                    }
                }
            }
            else
            {
                eable = map.GetItemsInRange(new Point3D(x, y, z), 0);

                foreach (Item item in eable)
                {
                    if (item.Z == z && item.ItemID == itemID)
                    {
                        eable.Free();
                        return(true);
                    }
                }
            }

            eable.Free();

            while (m_DeleteQueue.Count > 0)
            {
                ((Item)m_DeleteQueue.Dequeue()).Delete();
            }

            return(res);
        }
 private bool IsSupportedShadowType(LightType type)
 {
     return(type == LightType.Directional || type == LightType.Spot);
 }
Пример #58
0
        public static void LoadMap(string MapName = "")
        {
            try
            {
                XmlDocument XML = new XmlDocument();
                XmlNode     xmlNode;
                XmlNodeList xmlNodeList;

                XML.Load(MapsList[MapName]);

                Maps.Name = XML.DocumentElement.SelectSingleNode("Name").InnerText;

                Log.WriteLine("Loading map: \"{0}\"", MapName);

                if (XML.DocumentElement.SelectNodes("Description").Count > 0)
                {
                    Maps.Description = XML.DocumentElement.SelectSingleNode("Description").InnerText;
                }

                #region PlayerStart
                if (XML.DocumentElement.SelectNodes("PlayerStart").Count > 0)
                {
                    xmlNode = XML.DocumentElement.SelectSingleNode("PlayerStart");

                    if (xmlNode.SelectNodes("Position").Count > 0)
                    {
                        string[] Position = xmlNode.SelectSingleNode("Position").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        Game.MainCamera.Position = new Vector3(float.Parse(Position[0]), float.Parse(Position[1]), float.Parse(Position[2]));
                        PlayerStartPos           = Game.MainCamera.Position;
                    }

                    if (xmlNode.SelectNodes("Rotation").Count > 0)
                    {
                        string[] Rotation = xmlNode.SelectSingleNode("Rotation").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        float    Yaw      = float.Parse(Rotation[0]);
                        float    Pitch    = float.Parse(Rotation[1]);
                        Game.MainCamera.YawPitch = new Vector2(
                            MathHelper.DegreesToRadians(-Yaw),
                            MathHelper.DegreesToRadians(Pitch));
                        PlayerStartRot = new Vector2(Yaw, Pitch);
                    }
                }
                #endregion

                #region Camera
                if (XML.DocumentElement.SelectNodes("Camera").Count > 0)
                {
                    xmlNode = XML.DocumentElement.SelectSingleNode("Camera");

                    if (xmlNode.SelectNodes("Near").Count > 0)
                    {
                        Game.MainCamera.zNear = float.Parse(xmlNode.SelectSingleNode("Near").InnerText);
                    }
                    if (xmlNode.SelectNodes("Far").Count > 0)
                    {
                        Game.MainCamera.zFar = float.Parse(xmlNode.SelectSingleNode("Far").InnerText);
                    }
                    if (xmlNode.SelectNodes("FOV").Count > 0)
                    {
                        Game.MainCamera.FOV = float.Parse(xmlNode.SelectSingleNode("FOV").InnerText);
                    }
                    if (xmlNode.SelectNodes("MoveSpeed").Count > 0)
                    {
                        Game.MainCamera.MoveSpeed = float.Parse(xmlNode.SelectSingleNode("MoveSpeed").InnerText);
                    }
                }
                #endregion

                #region SkyBox
                if (XML.DocumentElement.SelectNodes("Skybox").Count > 0)
                {
                    string SkyBox = XML.DocumentElement.SelectSingleNode("Skybox").InnerText;

                    if (SkyBox != null && SkyBox != String.Empty)
                    {
                        Game.SkyBox = new Mesh();
                        MeshPart MPart = MeshPart.MakeBox(Game.MainCamera.zFar * 2.0f / (float)Math.Sqrt(3.0), true); // Cube diagonal = side / sqrt(3)
                        MPart.Material = Materials.Load(SkyBox);
                        Game.SkyBox.Parts.Add(MPart);
                        Game.SkyBox.CalcBoundingObjects();
                    }
                }
                #endregion

                #region Fog
                if (XML.DocumentElement.SelectNodes("Fog").Count > 0)
                {
                    xmlNode = XML.DocumentElement.SelectSingleNode("Fog");

                    if (xmlNode.SelectNodes("Enabled").Count > 0)
                    {
                        Settings.Graphics.Fog.UseFogOnMap = Convert.ToBoolean(xmlNode.SelectSingleNode("Enabled").InnerText);
                    }

                    if (xmlNode.SelectNodes("Color").Count > 0)
                    {
                        try
                        {
                            string[] Color = xmlNode.SelectSingleNode("Color").InnerText.Split(
                                new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);

                            float R, G, B;
                            switch (Color.Length)
                            {
                            case 1:
                                R = float.Parse(Color[0]);
                                Settings.Graphics.Fog.Color = new Vector3(R, R, R);
                                break;

                            case 3:
                                R = float.Parse(Color[0]);
                                G = float.Parse(Color[1]);
                                B = float.Parse(Color[2]);
                                Settings.Graphics.Fog.Color = new Vector3(R, G, B);
                                break;

                            default:
                                break;
                            }
                        }
                        catch { }
                    }

                    if (xmlNode.SelectNodes("DistanceMin").Count > 0)
                    {
                        Settings.Graphics.Fog.MinDistance = float.Parse(xmlNode.SelectSingleNode("DistanceMin").InnerText);
                    }

                    if (xmlNode.SelectNodes("DistanceMax").Count > 0)
                    {
                        Settings.Graphics.Fog.MaxDistance = float.Parse(xmlNode.SelectSingleNode("DistanceMax").InnerText);
                    }
                }

                #endregion

                #region Models
                foreach (XmlNode xmlNodeModel in XML.DocumentElement.SelectNodes("Model"))
                {
                    Model model = new Model();
                    model.Name = xmlNodeModel.SelectSingleNode("Name").InnerText;

                    if (xmlNodeModel.SelectNodes("Visible").Count > 0)
                    {
                        model.Visible = Convert.ToBoolean(xmlNodeModel.SelectSingleNode("Visible").InnerText);
                    }

                    foreach (XmlNode xmlNodeMesh in xmlNodeModel.SelectNodes("Mesh"))
                    {
                        Mesh   mesh = new Mesh();
                        string Name = xmlNodeMesh.SelectSingleNode("Name").InnerText;

                        MeshType meshType = MeshType.Mesh;

                        if (xmlNodeMesh.SelectNodes("Type").Count > 0)
                        {
                            string meshTypeStr = xmlNodeMesh.SelectSingleNode("Type").InnerText;

                            try
                            {
                                meshType = (MeshType)Enum.Parse(typeof(MeshType), meshTypeStr, true);
                            }
                            catch
                            {
                                meshType = MeshType.Mesh;
                            }
                        }

                        float    SideA, SideB, SideC;
                        MeshPart mp;
                        bool     FlipPolygons = false;
                        switch (meshType)
                        {
                        case MeshType.Plain:
                            mesh.Name     = Name;
                            mesh.MeshName = meshType.ToString();
                            SideA         = float.Parse(xmlNodeMesh.SelectSingleNode("SideA").InnerText);
                            SideB         = float.Parse(xmlNodeMesh.SelectSingleNode("SideB").InnerText);
                            mp            = MeshPart.MakePlain(SideA, SideB);
                            mesh.Parts.Add(mp);
                            mesh.CalcBoundingObjects();
                            break;

                        case MeshType.Box:
                            mesh.Name     = Name;
                            mesh.MeshName = meshType.ToString();
                            SideA         = float.Parse(xmlNodeMesh.SelectSingleNode("SideA").InnerText);
                            SideB         = float.Parse(xmlNodeMesh.SelectSingleNode("SideB").InnerText);
                            SideC         = float.Parse(xmlNodeMesh.SelectSingleNode("SideC").InnerText);

                            if (xmlNodeMesh.SelectNodes("FlipPolygons").Count > 0)
                            {
                                FlipPolygons = Convert.ToBoolean(xmlNodeMesh.SelectSingleNode("FlipPolygons").InnerText);
                            }

                            mp = MeshPart.MakeBox(SideA, SideB, SideC, FlipPolygons);
                            mesh.Parts.Add(mp);
                            mesh.CalcBoundingObjects();
                            break;

                        case MeshType.Mesh:
                        default:
                            string MeshName = xmlNodeMesh.SelectSingleNode("Mesh").InnerText;
                            mesh = Meshes.Load(Name, MeshName);
                            break;
                        }

                        string[] Pos = xmlNodeMesh.SelectSingleNode("Position").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        mesh.Position = new Vector3(float.Parse(Pos[0]), float.Parse(Pos[1]), float.Parse(Pos[2]));

                        string[] Rot = xmlNodeMesh.SelectSingleNode("Rotation").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        mesh.Rotation = new Vector3(MathHelper.DegreesToRadians(float.Parse(Rot[0])),
                                                    MathHelper.DegreesToRadians(float.Parse(Rot[1])), MathHelper.DegreesToRadians(float.Parse(Rot[2])));

                        string[] Scl = xmlNodeMesh.SelectSingleNode("Scale").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        mesh.Scale = new Vector3(float.Parse(Scl[0]), float.Parse(Scl[1]), float.Parse(Scl[2]));

                        XmlNodeList xmlMaterials = xmlNodeMesh.SelectSingleNode("Materials").SelectNodes("Material");
                        int         Count        = Math.Min(xmlMaterials.Count, mesh.Parts.Count);
                        for (int i = 0; i < Count; i++)
                        {
                            mesh.Parts[i].Material = Materials.Load(xmlMaterials[i].InnerText);
                        }

                        if (Count < mesh.Parts.Count && Count > 0)
                        {
                            for (int i = Count; i < mesh.Parts.Count; i++)
                            {
                                mesh.Parts[i].Material = mesh.Parts[0].Material;
                            }
                        }

                        model.Meshes.Add(mesh);
                    }

                    Models.MODELS.Add(model);
                }
                #endregion

                #region Light
                foreach (XmlNode xmlNodeLight in XML.DocumentElement.SelectNodes("Light"))
                {
                    Light light = new Light();
                    light.Name = xmlNodeLight.SelectSingleNode("Name").InnerText;

                    if (xmlNodeLight.SelectNodes("Enabled").Count > 0)
                    {
                        light.Enabled = Convert.ToBoolean(xmlNodeLight.SelectSingleNode("Enabled").InnerText);
                    }

                    LightType lightType = LightType.Point;
                    if (xmlNodeLight.SelectNodes("Type").Count > 0)
                    {
                        string meshTypeStr = xmlNodeLight.SelectSingleNode("Type").InnerText;

                        try
                        {
                            lightType = (LightType)Enum.Parse(typeof(LightType), meshTypeStr, true);
                        }
                        catch
                        {
                            lightType = LightType.Point;
                        }

                        light.Type = lightType;
                    }

                    #region Diffuse Light
                    xmlNodeList = xmlNodeLight.SelectNodes("Diffuse");
                    if (xmlNodeList.Count > 0)
                    {
                        try
                        {
                            string[] Diffuse = xmlNodeList.Item(0).InnerText.Split(
                                new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            float R, G, B;
                            switch (Diffuse.Length)
                            {
                            case 1:
                                R             = float.Parse(Diffuse[0]);
                                light.Diffuse = new Vector3(R, R, R);
                                break;

                            case 3:
                                R             = float.Parse(Diffuse[0]);
                                G             = float.Parse(Diffuse[1]);
                                B             = float.Parse(Diffuse[2]);
                                light.Diffuse = new Vector3(R, G, B);
                                break;
                            }
                        }
                        catch { }
                    }
                    #endregion

                    #region Specular Light
                    xmlNodeList = xmlNodeLight.SelectNodes("Specular");
                    if (xmlNodeList.Count > 0)
                    {
                        string[] Specular = xmlNodeList.Item(0).InnerText.Split(
                            new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                        float R, G, B;
                        switch (Specular.Length)
                        {
                        case 1:
                            R = float.Parse(Specular[0]);
                            light.Specular = new Vector3(R, R, R);
                            break;

                        case 3:
                            R = float.Parse(Specular[0]);
                            G = float.Parse(Specular[1]);
                            B = float.Parse(Specular[2]);
                            light.Specular = new Vector3(R, G, B);
                            break;
                        }
                    }
                    #endregion

                    #region Position
                    xmlNodeList = xmlNodeLight.SelectNodes("Position");
                    if (xmlNodeList.Count > 0)
                    {
                        string[] Pos = xmlNodeList.Item(0).InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        light.Position = new Vector3(float.Parse(Pos[0]), float.Parse(Pos[1]), float.Parse(Pos[2]));
                    }
                    #endregion

                    #region Direction
                    xmlNodeList = xmlNodeLight.SelectNodes("Direction");
                    if (xmlNodeList.Count > 0)
                    {
                        string[] Direct = xmlNodeList.Item(0).InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                        light.Direction = Vector3.FromYawPitch(
                            MathHelper.DegreesToRadians(float.Parse(Direct[0])),
                            MathHelper.DegreesToRadians(float.Parse(Direct[1])));
                    }
                    #endregion

                    #region Attenuation
                    xmlNodeList = xmlNodeLight.SelectNodes("Attenuation");
                    if (xmlNodeList.Count > 0)
                    {
                        string[] Atten = xmlNodeList.Item(0).InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        light.Attenuation = new Vector3(float.Parse(Atten[0]), float.Parse(Atten[1]), float.Parse(Atten[2]));
                    }
                    #endregion

                    if (xmlNodeLight.SelectNodes("CutOFF").Count > 0)
                    {
                        light.CutOFF = float.Parse(xmlNodeLight.SelectSingleNode("CutOFF").InnerText);
                    }

                    if (xmlNodeLight.SelectNodes("Exponent").Count > 0)
                    {
                        light.Exponent = float.Parse(xmlNodeLight.SelectSingleNode("Exponent").InnerText);
                    }

                    Lights.LIGHTS.Add(light);
                }
                #endregion

                #region Sounds
                //xmlNodeList = XML.DocumentElement.SelectSingleNode("Sounds").SelectNodes("Sound");

                //foreach (XmlNode xmlNodeSound in xmlNodeList)
                //{
                //    string SndName = xmlNodeSound.SelectSingleNode("Name").InnerText;
                //    bool SndEnabled = Convert.ToBoolean(xmlNodeSound.SelectSingleNode("Enabled").InnerText);
                //    string SndFile = xmlNodeSound.SelectSingleNode("File").InnerText;
                //    int SndVolume = Convert.ToInt32(xmlNodeSound.SelectSingleNode("Volume").InnerText);
                //    int SndRadius = Convert.ToInt32(xmlNodeSound.SelectSingleNode("Radius").InnerText);

                //    string[] SndPos = xmlNodeSound.SelectSingleNode("Position").InnerText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                //    Vector3 SndPosition = new Vector3(
                //        float.Parse(SndPos[0]),
                //        float.Parse(SndPos[1]),
                //        float.Parse(SndPos[2]));
                //}
                #endregion

                Log.WriteLineGreen("Done.");
            }
            catch
            {
                Log.WriteLineRed("Map \"{0}\" loading Error!\n\t", MapName);
            }
        }
Пример #59
0
		public LightWrapper(IEnumerable results, BfCache cache)
		{
			if (results == null)
			{
				Console.WriteLine("no results");
			}
			else
			{
				object obj = results.OfType<object>().FirstOrDefault<object>();
				if (obj == null)
				{
					Console.WriteLine("results are empty");
				}
				else
				{
					IEnumerable<PropertyInfo> arg_A8_0 = obj.GetType().GetProperties();
					if (LightWrapper.func_0 == null)
					{
						LightWrapper.func_0 = new Func<PropertyInfo, bool>(LightWrapper.smethod_0);
					}
					PropertyInfo propertyInfo = arg_A8_0.FirstOrDefault(LightWrapper.func_0);
					if (propertyInfo != null)
					{
						Dictionary<int, object> idToLeaf = new Dictionary<int, object>();
						foreach (object current in results)
						{
							int key = (int)propertyInfo.GetGetMethod().Invoke(current, null);
							if (!idToLeaf.ContainsKey(key))
							{
								idToLeaf.Add(key, current);
							}
						}
						if (string.Compare(propertyInfo.Name, "MethodId", true) == 0)
						{
							var enumerable = from method in cache.Methods
							where idToLeaf.ContainsKey(method.MethodId)
							select new
							{
								Type = method.Type,
								Assembly = method.Type.Assembly,
								Namespace = method.Type.Namespace,
								Leaf = idToLeaf[method.MethodId]
							};
							string childType = "Method";
							foreach (var current2 in enumerable)
							{
								LightAssembly lightAssembly = new LightAssembly(current2.Assembly, childType);
								lightAssembly = this.Assemblies.method_2(lightAssembly);
								LightNamespace lightNamespace = new LightNamespace(current2.Namespace, childType);
								lightNamespace = lightAssembly.Namespaces.method_2(lightNamespace);
								LightNamespace lightNamespace2 = new LightNamespace(current2.Namespace, childType);
								lightNamespace2 = this.Namespaces.method_2(lightNamespace2);
								LightType lightType = new LightType(current2.Type, childType);
								lightType = this.Types.method_2(lightType);
								lightNamespace.Types.method_2(lightType);
								lightNamespace2.Types.method_2(lightType);
								lightType.Children.method_2(current2.Leaf);
								this.TypesChildren.method_2(current2.Leaf);
							}
						}
						if (string.Compare(propertyInfo.Name, "FieldId", true) == 0)
						{
							var enumerable = from field in cache.Fields
							where idToLeaf.ContainsKey(field.FieldId)
							select new
							{
								Type = field.Type,
								Assembly = field.Type.Assembly,
								Namespace = field.Type.Namespace,
								Leaf = idToLeaf[field.FieldId]
							};
							string childType = "Field";
							foreach (var current2 in enumerable)
							{
								LightAssembly lightAssembly = new LightAssembly(current2.Assembly, childType);
								lightAssembly = this.Assemblies.method_2(lightAssembly);
								LightNamespace lightNamespace = new LightNamespace(current2.Namespace, childType);
								lightNamespace = lightAssembly.Namespaces.method_2(lightNamespace);
								LightNamespace lightNamespace2 = new LightNamespace(current2.Namespace, childType);
								lightNamespace2 = this.Namespaces.method_2(lightNamespace2);
								LightType lightType = new LightType(current2.Type, childType);
								lightType = this.Types.method_2(lightType);
								lightNamespace.Types.method_2(lightType);
								lightNamespace2.Types.method_2(lightType);
								lightType.Children.method_2(current2.Leaf);
								this.TypesChildren.method_2(current2.Leaf);
							}
						}
						if (string.Compare(propertyInfo.Name, "EventId", true) == 0)
						{
							var enumerable = from ev in cache.Events
							where idToLeaf.ContainsKey(ev.EventId)
							select new
							{
								Type = ev.Type,
								Assembly = ev.Type.Assembly,
								Namespace = ev.Type.Namespace,
								Leaf = idToLeaf[ev.EventId]
							};
							string childType = "Event";
							foreach (var current2 in enumerable)
							{
								LightAssembly lightAssembly = new LightAssembly(current2.Assembly, childType);
								lightAssembly = this.Assemblies.method_2(lightAssembly);
								LightNamespace lightNamespace = new LightNamespace(current2.Namespace, childType);
								lightNamespace = lightAssembly.Namespaces.method_2(lightNamespace);
								LightNamespace lightNamespace2 = new LightNamespace(current2.Namespace, childType);
								lightNamespace2 = this.Namespaces.method_2(lightNamespace2);
								LightType lightType = new LightType(current2.Type, childType);
								lightType = this.Types.method_2(lightType);
								lightNamespace.Types.method_2(lightType);
								lightNamespace2.Types.method_2(lightType);
								lightType.Children.method_2(current2.Leaf);
								this.TypesChildren.method_2(current2.Leaf);
							}
						}
						if (string.Compare(propertyInfo.Name, "TypeId", true) == 0)
						{
							var enumerable2 = from type in cache.Types
							where idToLeaf.ContainsKey(type.TypeId)
							select new
							{
								type = type,
								Assembly = type.Assembly,
								Namespace = type.Namespace,
								Leaf = idToLeaf[type.TypeId]
							};
							string childType = "Type";
							foreach (var current3 in enumerable2)
							{
								LightAssembly lightAssembly = new LightAssembly(current3.Assembly, childType);
								lightAssembly = this.Assemblies.method_2(lightAssembly);
								LightNamespace lightNamespace = new LightNamespace(current3.Namespace, childType);
								lightNamespace = lightAssembly.Namespaces.method_2(lightNamespace);
								LightNamespace lightNamespace2 = new LightNamespace(current3.Namespace, childType);
								lightNamespace2 = this.Namespaces.method_2(lightNamespace2);
								LightType lightType = new LightType(current3.type, childType);
								lightType = this.Types.method_2(lightType);
								lightNamespace.Types.method_2(lightType);
								lightNamespace2.Types.method_2(lightType);
								lightNamespace.Children.method_2(current3.Leaf);
								lightNamespace2.Children.method_2(current3.Leaf);
								this.TypesChildren.method_2(current3.Leaf);
							}
						}
						if (string.Compare(propertyInfo.Name, "NamespaceId", true) == 0)
						{
							var enumerable3 = from nspace in cache.Namespaces
							where idToLeaf.ContainsKey(nspace.NamespaceId)
							select new
							{
								nspace = nspace,
								Leaf = idToLeaf[nspace.NamespaceId]
							};
							string childType = "GeneralNamespace";
							foreach (var current4 in enumerable3)
							{
								LightNamespace lightNamespace2 = new LightNamespace(current4.nspace, childType);
								lightNamespace2 = this.Namespaces.method_2(lightNamespace2);
								lightNamespace2.Children.method_2(current4.Leaf);
							}
						}
						if (string.Compare(propertyInfo.Name, "AssemblyId", true) == 0)
						{
							var enumerable4 = from assembly in cache.Assemblies
							where idToLeaf.ContainsKey(assembly.AssemblyId)
							select new
							{
								assembly = assembly,
								Leaf = idToLeaf[assembly.AssemblyId]
							};
							string childType = "Assembly";
							foreach (var current5 in enumerable4)
							{
								LightAssembly lightAssembly2 = new LightAssembly(current5.assembly, childType);
								this.Assemblies.method_2(lightAssembly2);
								lightAssembly2.Children.method_2(current5.Leaf);
							}
						}
					}
					LightCollection<LightAssembly> arg_863_0 = this.lightCollection_0;
					if (LightWrapper.comparison_0 == null)
					{
						LightWrapper.comparison_0 = new Comparison<LightAssembly>(LightWrapper.smethod_1);
					}
					arg_863_0.method_1(LightWrapper.comparison_0);
					foreach (LightAssembly lightAssembly in ((IEnumerable<LightAssembly>)this.lightCollection_0))
					{
						LightAssembly lightAssembly;
						LightCollection<LightNamespace> arg_8A8_0 = lightAssembly.Namespaces;
						if (LightWrapper.comparison_1 == null)
						{
							LightWrapper.comparison_1 = new Comparison<LightNamespace>(LightWrapper.smethod_2);
						}
						arg_8A8_0.method_1(LightWrapper.comparison_1);
						foreach (LightNamespace current6 in ((IEnumerable<LightNamespace>)lightAssembly.Namespaces))
						{
							LightCollection<LightType> arg_8EB_0 = current6.Types;
							if (LightWrapper.comparison_2 == null)
							{
								LightWrapper.comparison_2 = new Comparison<LightType>(LightWrapper.smethod_3);
							}
							arg_8EB_0.method_1(LightWrapper.comparison_2);
						}
					}
					LightCollection<LightNamespace> arg_94A_0 = this.lightCollection_1;
					if (LightWrapper.comparison_3 == null)
					{
						LightWrapper.comparison_3 = new Comparison<LightNamespace>(LightWrapper.smethod_4);
					}
					arg_94A_0.method_1(LightWrapper.comparison_3);
					foreach (LightNamespace current6 in ((IEnumerable<LightNamespace>)this.lightCollection_1))
					{
						LightCollection<LightType> arg_98C_0 = current6.Types;
						if (LightWrapper.comparison_4 == null)
						{
							LightWrapper.comparison_4 = new Comparison<LightType>(LightWrapper.smethod_5);
						}
						arg_98C_0.method_1(LightWrapper.comparison_4);
					}
					LightCollection<LightType> arg_9CE_0 = this.lightCollection_2;
					if (LightWrapper.comparison_5 == null)
					{
						LightWrapper.comparison_5 = new Comparison<LightType>(LightWrapper.smethod_6);
					}
					arg_9CE_0.method_1(LightWrapper.comparison_5);
				}
			}
		}
Пример #60
0
 public static bool IsSupportedCookieType(LightType lightType)
 {
     return(lightType == LightType.Directional || lightType == LightType.Spot);
 }