public void ExtractMovableObject( MovableObject m ) { this.ExtractMovableObject( m.Name, m.MovableType ); }
/// <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 ); }
public void DestroyMovableObject( MovableObject m ) { this.DestroyMovableObject( m.Name, m.MovableType ); }
/// <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 ); } }
/// <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); }
/// <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; } } }
/// <summary> /// Internal method for telling the node that a movable intersects it. /// </summary> /// <param name="?"></param> public void AddObject(MovableObject obj) { objectList.Add(obj); }
/// <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; }
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; }
/// <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; }
/// <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); }
/// <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);
/// <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)); }
/// <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 ); }
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; }
/// <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; }
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; }
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); }
/// <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 ); }
/// <summary> /// Internal method for telling the node that a movable no longer intersects it. /// </summary> public void RemoveObject(MovableObject obj) { objectList.Remove(obj); }
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 ); }
/// <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; }
/// <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 ); }
/// <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); }
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; }
/// <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); }
public void InjectMovableObject( MovableObject m ) { MovableObjectCollection objectMap = this.GetMovableObjectCollection( m.MovableType ); { lock ( objectMap ) { if ( !objectMap.ContainsKey( m.Name ) ) { objectMap.Add( m ); } } } }
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); } } }
public override void DestroyInstance( ref MovableObject obj ) { ( (Entity)obj ).Dispose(); obj = null; }
public override void DestroyInstance( ref MovableObject obj ) { obj = null; }
/// <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 ); }
public void SetAutoTracking( bool enabled, MovableObject target ) { SetAutoTracking( enabled, (SceneNode)target.ParentNode, Vector3.Zero ); }
/// <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 ); }
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(); } } }
/// <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 ); }
public override void DestroyInstance(ref MovableObject obj) { ((MovableText)obj).Dispose(); obj = null; }