Axiom.Core.Entity.NotifyCurrentCamera C# (CSharp) Метод

NotifyCurrentCamera() публичный Метод

public NotifyCurrentCamera ( Camera camera ) : void
camera Camera
Результат void
		public override void NotifyCurrentCamera( Camera camera )
		{
			if ( this.parentNode != null )
			{
				// Get mesh lod strategy
				LodStrategy meshStrategy = mesh.LodStrategy;
				// Get the appropriate lod value
				Real lodValue = meshStrategy.GetValue( this, camera );
				// Bias the lod value
				Real biasedMeshLodValue = lodValue * this.meshLodFactorTransformed;

				// Get the index at this biased depth
				int newMeshLodIndex = this.mesh.GetLodIndex( biasedMeshLodValue );

				// Apply maximum detail restriction (remember lower = higher detail)
				this.meshLodIndex = (int)Utility.Max( this.maxMeshLodIndex, this.meshLodIndex );

				// Apply minimum detail restriction (remember higher = lower detail)
				this.meshLodIndex = (int)Utility.Min( this.minMeshLodIndex, this.meshLodIndex );

				// Construct event object
				EntityMeshLodChangedEvent evt;
				evt.Entity = this;
				evt.Camera = camera;
				evt.LodValue = biasedMeshLodValue;
				evt.PreviousLodIndex = this.meshLodIndex;
				evt.NewLodIndex = newMeshLodIndex;

				// Notify lod event listeners
				//camera.SceneManager.NotifyEntityMeshLodChanged( evt );

				// Change lod index
				this.meshLodIndex = evt.NewLodIndex;

				// Now do material LOD
				lodValue *= this.materialLodFactorTransformed;

				// apply the material LOD to all sub entities
				foreach ( SubEntity subEntity in subEntityList )
				{
					// Get sub-entity material
					Material material = subEntity.Material;

					// Get material lod strategy
					LodStrategy materialStrategy = material.LodStrategy;

					// Recalculate lod value if strategies do not match
					Real biasedMaterialLodValue;
					if ( meshStrategy == materialStrategy )
						biasedMaterialLodValue = lodValue;
					else
						biasedMaterialLodValue = materialStrategy.GetValue( this, camera ) * materialStrategy.TransformBias( this.materialLodFactor );

					// Get the index at this biased depth
					int idx = material.GetLodIndex( biasedMaterialLodValue );
					// Apply maximum detail restriction (remember lower = higher detail)
					idx = (int)Utility.Max( this.maxMaterialLodIndex, idx );
					// Apply minimum detail restriction (remember higher = lower detail)
					idx = (int)Utility.Min( this.minMaterialLodIndex, idx );

					// Construct event object
					EntityMaterialLodChangedEvent materialLodEvent;
					materialLodEvent.SubEntity = subEntity;
					materialLodEvent.Camera = camera;
					materialLodEvent.LodValue = biasedMaterialLodValue;
					materialLodEvent.PreviousLodIndex = subEntity.MaterialLodIndex;
					materialLodEvent.NewLodIndex = idx;

					// Notify lod event listeners
					//camera.SceneManager.NotifyEntityMaterialLodChanged( materialLodEvent );

					// Change lod index
					subEntity.MaterialLodIndex = materialLodEvent.NewLodIndex;

					// Also invalidate any camera distance cache
					//subEntity.InvalidateCameraCache();
				}
			}

			// Notify child objects (tag points)
			foreach ( MovableObject child in this.childObjectList.Values )
			{
				child.NotifyCurrentCamera( camera );
			}
		}