Exemplo n.º 1
0
		public void ExtractMovableObject( MovableObject m )
		{
			this.ExtractMovableObject( m.Name, m.MovableType );
		}
Exemplo n.º 2
0
		/// <summary>
		///		Internal method for notifying the level that an object has been detached from a node.
		/// </summary>
		internal void NotifyObjectDetached( MovableObject obj )
		{
			this.level.NotifyObjectDetached( obj );
		}
Exemplo n.º 3
0
		public void DestroyMovableObject( MovableObject m )
		{
			this.DestroyMovableObject( m.Name, m.MovableType );
		}
Exemplo n.º 4
0
		/// <summary>
		/// Private method that adds any object not currently selected into the selection list
		/// </summary>
		/// <param name="obj">MovableObject</param>
		private void SelectObject( MovableObject obj )
		{
			if ( !Selection.Contains( obj ) )
			{

				Log( "MouseSelector: " + _name + " selecting object " + obj.Name );
				obj.ParentSceneNode.ShowBoundingBox = true;
				Selection.Add( obj );
			}
		}
Exemplo n.º 5
0
 /// <summary>
 ///		Adds a named object to the collection.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="item"></param>
 public void Add(K key, T item)
 {
     base.Add(key, item);
 }
Exemplo n.º 6
0
		/// <summary>
		/// Detaches an object by reference.
		/// </summary>
		/// <param name="obj"></param>
		/// <remarks>
		/// Use this method to destroy a MovableObject which is attached to a bone of belonging this entity.
		/// But sometimes the object may be not in the child object list because it is a lod entity,
		/// this method can safely detect and ignore in this case and won't raise an exception.
		/// </remarks>
		public void DetachObjectFromBone( MovableObject obj )
		{
			foreach ( var child in this.childObjectList.Values )
			{
				if ( child == obj )
				{
					DetachObjectImpl( obj );
					this.childObjectList.Remove( obj.Name );

					// Trigger update of bounding box if necessary
					if ( parentNode != null )
					{
						parentNode.NeedUpdate();
					}
					break;
				}
			}
		}
Exemplo n.º 7
0
 /// <summary>
 ///		Internal method for telling the node that a movable intersects it.
 /// </summary>
 /// <param name="?"></param>
 public void AddObject(MovableObject obj)
 {
     objectList.Add(obj);
 }
Exemplo n.º 8
0
		/// <summary>
		///		Self-callback in order to deal with execute which returns collection.
		/// </summary>
		/// <param name="sceneObject"></param>
		/// <returns></returns>
		public bool OnQueryResult( MovableObject sceneObject )
		{
			this.lastResult.objects.Add( sceneObject );

			// continue
			return true;
		}
Exemplo n.º 9
0
		public bool OnQueryResult( MovableObject sceneObject, float distance )
		{
			// create an entry and add it to the cached result list
			var entry = new RaySceneQueryResultEntry();
			entry.Distance = distance;
			entry.SceneObject = sceneObject;
			entry.worldFragment = null;
			this.lastResults.Add( entry );

			// continue gathering results
			return true;
		}
Exemplo n.º 10
0
 /// <summary>
 /// Rekeys the scene object using its new Name
 /// </summary>
 /// <param name="obj"></param>
 public virtual void NotifyAttachedObjectNameChanged(MovableObject obj)
 {
     this.objectList.Remove(obj.Name);
     this.objectList.Add(obj);
 }
 public SceneQueryMovableObjectWorldFragmentPair(MovableObject obj, SceneQuery.WorldFragment fragment)
 {
     this.obj = obj;
     this.fragment = fragment;
 }
Exemplo n.º 12
0
 /// <summary>
 ///		Enables / disables automatic tracking of a SceneObject.
 /// </summary>
 /// <remarks>
 ///		If you enable auto-tracking, this Camera will automatically rotate to
 ///		look at the target SceneNode every frame, no matter how
 ///		it or SceneNode move. This is handy if you want a Camera to be focused on a
 ///		single object or group of objects. Note that by default the Camera looks at the
 ///		origin of the SceneNode, if you want to tweak this, e.g. if the object which is
 ///		attached to this target node is quite big and you want to point the camera at
 ///		a specific point on it, provide a vector in the 'offset' parameter and the
 ///		camera's target point will be adjusted.
 /// </remarks>
 /// <param name="enabled">If true, the Camera will track the SceneNode supplied as the next
 ///		parameter (cannot be null). If false the camera will cease tracking and will
 ///		remain in it's current orientation.
 ///	 </param>
 /// <param name="target">The SceneObject which this Camera will track.</param>
 public void SetAutoTracking(bool enabled, MovableObject target)
 {
     SetAutoTracking(enabled, (SceneNode)target.ParentNode, Vector3.Zero);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Compute the lod value for a given movable object relative to a given camera.
 /// </summary>
 /// <param name="movableObject"></param>
 /// <param name="camera"></param>
 /// <returns></returns>
 protected abstract Real getValue(MovableObject movableObject, Camera camera);
Exemplo n.º 14
0
 /// <summary>
 /// Compute the lod value for a given movable object relative to a given camera.
 /// </summary>
 /// <param name="movableObject"></param>
 /// <param name="cam"></param>
 /// <returns></returns>
 public float GetValue(MovableObject movableObject, Camera cam)
 {
     // Just return implementation with lod camera
     return(getValue(movableObject, cam));
 }
Exemplo n.º 15
0
		/// <summary>
		///		Attaches another object to a certain bone of the skeleton which this entity uses.
		/// </summary>
		/// <remarks>
		///		This method can be used to attach another object to an animated part of this entity,
		///		by attaching it to a bone in the skeleton (with an offset if required). As this entity
		///		is animated, the attached object will move relative to the bone to which it is attached.
		/// </remarks>
		/// <param name="boneName">The name of the bone (in the skeleton) to attach this object.</param>
		/// <param name="sceneObject">Reference to the object to attach.</param>
		public TagPoint AttachObjectToBone( string boneName, MovableObject sceneObject )
		{
			return AttachObjectToBone( boneName, sceneObject, Quaternion.Identity );
		}
Exemplo n.º 16
0
		bool Axiom.Core.IIntersectionSceneQueryListener.OnQueryResult( MovableObject first, MovableObject second )
		{
			// create an entry and add it to the cached result list
			this.lastResults.Objects2Objects.Add( new SceneQueryMovableObjectPair( first, second ) );

			// continue gathering results
			return true;
		}
Exemplo n.º 17
0
		/// <summary>
		///		Attaches another object to a certain bone of the skeleton which this entity uses.
		/// </summary>
		/// <param name="boneName">The name of the bone (in the skeleton) to attach this object.</param>
		/// <param name="sceneObject">Reference to the object to attach.</param>
		/// <param name="offsetOrientation">An adjustment to the orientation of the attached object, relative to the bone.</param>
		/// <param name="offsetPosition">An adjustment to the position of the attached object, relative to the bone.</param>
		public TagPoint AttachObjectToBone( string boneName, MovableObject sceneObject, Quaternion offsetOrientation,
		                                    Vector3 offsetPosition )
		{
			if ( this.childObjectList.ContainsKey( sceneObject.Name ) )
			{
				throw new AxiomException( "An object with the name {0} is already attached.", sceneObject.Name );
			}

			if ( sceneObject.IsAttached )
			{
				throw new AxiomException( "MovableObject '{0}' is already attached to '{1}'", sceneObject.Name,
				                          sceneObject.ParentNode.Name );
			}

			if ( !HasSkeleton )
			{
				throw new AxiomException( "Entity '{0}' has no skeleton to attach an object to.", name );
			}

			var bone = this.skeletonInstance.GetBone( boneName );
			if ( bone == null )
			{
				throw new AxiomException( "Entity '{0}' does not have a skeleton with a bone named '{1}'.", name, boneName );
			}

			var tagPoint = this.skeletonInstance.CreateTagPointOnBone( bone, offsetOrientation, offsetPosition );

			tagPoint.ParentEntity = this;
			tagPoint.ChildObject = sceneObject;

			AttachObjectImpl( sceneObject, tagPoint );

			// Trigger update of bounding box if necessary
			if ( parentNode != null )
			{
				parentNode.NeedUpdate();
			}

			return tagPoint;
		}
Exemplo n.º 18
0
		bool Axiom.Core.IIntersectionSceneQueryListener.OnQueryResult( MovableObject obj, SceneQuery.WorldFragment fragment )
		{
			// create an entry and add it to the cached result list
			this.lastResults.Objects2World.Add( new SceneQueryMovableObjectWorldFragmentPair( obj, fragment ) );

			// continue gathering results
			return true;
		}
Exemplo n.º 19
0
        bool Axiom.Core.IIntersectionSceneQueryListener.OnQueryResult(MovableObject first, MovableObject second)
        {
            // create an entry and add it to the cached result list
            lastResults.Objects2Objects.Add(new SceneQueryMovableObjectPair(first, second));

            // continue gathering results
            return(true);
        }
Exemplo n.º 20
0
		/// <summary>
		///		Internal method for telling the node that a movable no longer intersects it.
		///	</summary>
		public void RemoveObject( MovableObject obj )
		{
			this.objectList.Remove( obj.Name );
		}
Exemplo n.º 21
0
 /// <summary>
 ///		Internal method for telling the node that a movable no longer intersects it.
 ///	</summary>
 public void RemoveObject(MovableObject obj)
 {
     objectList.Remove(obj);
 }
Exemplo n.º 22
0
		public override void DetachObject( MovableObject obj )
		{
			// TextureLights are detached only when removed at the BspSceneManager
			if ( !( obj is TextureLight ) )
			{
				( (BspSceneManager)Creator ).NotifyObjectDetached( obj );
			}

			base.DetachObject( obj );
		}
Exemplo n.º 23
0
 /// <summary>
 ///		Adds an object to the collection.
 /// </summary>
 /// <param name="item"></param>
 public void Add(T item)
 {
     Add(item.Name, item);
 }
 public SceneQueryMovableObjectPair(MovableObject first, MovableObject second)
 {
     this.first = first;
     this.second = second;
 }
Exemplo n.º 25
0
		/// <summary>
		///		Internal method for tagging <see cref="Plugin_BSPSceneManager.BspNode"/>'s with objects which intersect them.
		/// </summary>
		internal void NotifyObjectMoved( MovableObject obj, Vector3 pos )
		{
			this.level.NotifyObjectMoved( obj, pos );
		}
Exemplo n.º 26
0
        /// <summary>
        ///		Internal method, makes sure an object is removed from the leaves when detached from a node.
        /// </summary>
        internal void NotifyObjectDetached(MovableObject obj)
        {
            IEnumerator objnodes = objectToNodeMap.Find(obj);

            if(objnodes == null)
                return;

            while(objnodes.MoveNext())
                ((BspNode) objnodes.Current).RemoveObject(obj);

            objectToNodeMap.Clear(obj);
        }
Exemplo n.º 27
0
			public bool OnQueryResult( MovableObject sceneObject )
			{
				if ( sceneObject.CastShadows && sceneObject.IsVisible
					&& sceneManager.SpecialCaseRenderQueueList.IsRenderQueueToBeProcessed( sceneObject.RenderQueueGroup ) )
				{
					if ( this.farDistSquared > 0 )
					{
						// Check object is within the shadow far distance
						Vector3 toObj = sceneObject.ParentNode.DerivedPosition - this.camera.DerivedPosition;
						float radius = sceneObject.GetWorldBoundingSphere().Radius;
						float dist = toObj.LengthSquared;

						if ( dist - ( radius * radius ) > this.farDistSquared )
						{
							// skip, beyond max range
							return true;
						}
					}

					// If the object is in the frustum, we can always see the shadow
					if ( this.camera.IsObjectVisible( sceneObject.GetWorldBoundingBox() ) )
					{
						this.casterList.Add( sceneObject );
						return true;
					}

					// Otherwise, object can only be casting a shadow into our view if
					// the light is outside the frustum (or it's a directional light,
					// which are always outside), and the object is intersecting
					// on of the volumes formed between the edges of the frustum and the
					// light
					if ( !this.isLightInFrustum || this.light.Type == LightType.Directional )
					{
						// Iterate over volumes
						for ( int i = 0; i < this.lightClipVolumeList.Count; i++ )
						{
							PlaneBoundedVolume pbv = (PlaneBoundedVolume)this.lightClipVolumeList[ i ];

							if ( pbv.Intersects( sceneObject.GetWorldBoundingBox() ) )
							{
								this.casterList.Add( sceneObject );
								return true;
							}
						}
					}
				}

				return true;
			}
Exemplo n.º 28
0
        /// <summary>
        ///		Ensures that the <see cref="Axiom.Core.MovableObject"/> is attached to the right leaves of the BSP tree.
        /// </summary>
        internal void NotifyObjectMoved(MovableObject obj, Vector3 pos)
        {
            IEnumerator objnodes = objectToNodeMap.Find(obj);

            if(objnodes != null)
            {
                while(objnodes.MoveNext())
                    ((BspNode) objnodes.Current).RemoveObject(obj);

                objectToNodeMap.Clear(obj);
            }

            TagNodesWithObject(this.RootNode, obj, pos);
        }
Exemplo n.º 29
0
		public void InjectMovableObject( MovableObject m )
		{
			MovableObjectCollection objectMap = this.GetMovableObjectCollection( m.MovableType );
			{
				lock ( objectMap )
				{
					if ( !objectMap.ContainsKey( m.Name ) )
					{
						objectMap.Add( m );
					}
				}
			}
		}
Exemplo n.º 30
0
        protected void TagNodesWithObject(BspNode node, MovableObject obj, Vector3 pos)
        {
            if(node.IsLeaf)
            {
                // Add to movable->node map
                // Insert all the time, will get current if already there
                objectToNodeMap.Insert(obj, node);
                node.AddObject(obj);
            }
            else
            {
                // Find distance to dividing plane
                float dist = node.GetDistance(pos);

                //CHECK: treat obj as bounding box?
                if(MathUtil.Abs(dist) < obj.BoundingRadius)
                {
                    // Bounding sphere crosses the plane, do both.
                    TagNodesWithObject(node.BackNode, obj, pos);
                    TagNodesWithObject(node.FrontNode, obj, pos);
                }
                else if(dist < 0)
                {
                    // Do back.
                    TagNodesWithObject(node.BackNode, obj, pos);
                }
                else
                {
                    // Do front.
                    TagNodesWithObject(node.FrontNode, obj, pos);
                }
            }
        }
Exemplo n.º 31
0
		public override void DestroyInstance( ref MovableObject obj )
		{
			( (Entity)obj ).Dispose();
			obj = null;
		}
Exemplo n.º 32
0
		public override void DestroyInstance( ref MovableObject obj )
		{
			obj = null;
		}
Exemplo n.º 33
0
		/// <summary>
		///		Attaches another object to a certain bone of the skeleton which this entity uses.
		/// </summary>
		/// <param name="boneName">The name of the bone (in the skeleton) to attach this object.</param>
		/// <param name="sceneObject">Reference to the object to attach.</param>
		/// <param name="offsetOrientation">An adjustment to the orientation of the attached object, relative to the bone.</param>
		public TagPoint AttachObjectToBone( string boneName, MovableObject sceneObject, Quaternion offsetOrientation )
		{
			return AttachObjectToBone( boneName, sceneObject, Quaternion.Identity, Vector3.Zero );
		}
Exemplo n.º 34
0
		public void SetAutoTracking( bool enabled, MovableObject target )
		{
			SetAutoTracking( enabled, (SceneNode)target.ParentNode, Vector3.Zero );
		}
Exemplo n.º 35
0
		/// <summary>
		///		Internal implementation of attaching a 'child' object to this entity and assign
		///		the parent node to the child entity.
		/// </summary>
		/// <param name="sceneObject">Object to attach.</param>
		/// <param name="tagPoint">TagPoint to attach the object to.</param>
		protected void AttachObjectImpl( MovableObject sceneObject, TagPoint tagPoint )
		{
			this.childObjectList.Add( sceneObject.Name, sceneObject );
			sceneObject.NotifyAttached( tagPoint, true );
		}
Exemplo n.º 36
0
		protected override Real getValue( MovableObject movableObject, Camera camera )
		{
			// Get viewport
			var viewport = camera.Viewport;

			// Get viewport area
			float viewportArea = viewport.ActualWidth*viewport.ActualHeight;

			// Get area of unprojected circle with object bounding radius
			float boundingArea = MathHelper.PI*MathHelper.Sqr( movableObject.BoundingRadius );

			// Base computation on projection type
			switch ( camera.ProjectionType )
			{
				case Projection.Perspective:
				{
					// Get camera distance
					var distanceSquared = movableObject.ParentNode.GetSquaredViewDepth( camera );

					// Check for 0 distance
					if ( distanceSquared <= float.Epsilon )
					{
						return BaseValue;
					}

					// Get projection matrix (this is done to avoid computation of tan(fov / 2))
					var projectionMatrix = camera.ProjectionMatrix;

					//estimate pixel count
					return ( boundingArea*viewportArea*projectionMatrix[ 0, 0 ]*projectionMatrix[ 1, 1 ] )/distanceSquared;
				}
					// break;
				case Projection.Orthographic:
				{
					// Compute orthographic area
					var orthoArea = camera.OrthoWindowHeight*camera.OrthoWindowWidth;

					// Check for 0 orthographic area
					if ( orthoArea <= float.Epsilon )
					{
						return BaseValue;
					}

					// Estimate pixel count
					return ( boundingArea*viewportArea )/orthoArea;
				}
					// break;
				default:
				{
					// This case is not covered for obvious reasons
					throw new NotSupportedException();
				}
			}
		}
Exemplo n.º 37
0
		/// <summary>
		///		Internal implementation of detaching a 'child' object from this entity and
		///		clearing the assignment of the parent node to the child entity.
		/// </summary>
		/// <param name="pObject">Object to detach.</param>
		protected void DetachObjectImpl( MovableObject pObject )
		{
			var tagPoint = (TagPoint)pObject.ParentNode;

			// free the TagPoint so we can reuse it later
			//TODO: NO idea what this does!
			this.skeletonInstance.FreeTagPoint( tagPoint );

			pObject.NotifyAttached( null, true );
		}
Exemplo n.º 38
0
 public override void DestroyInstance(ref MovableObject obj)
 {
     ((MovableText)obj).Dispose();
     obj = null;
 }