Example #1
0
        /// <summary>
        ///     The moral equivalent of a copy constructor
        /// </summary>
        /// <param name="parent">The animation state set parent</param>
        /// <param name="source">An animation state to copy from</param>
        public AnimationState(AnimationStateSet parent, AnimationState source)
        {
            this.parent = parent;
            CopyFrom(source);

            parent.NotifyDirty();
        }
Example #2
0
        /// <summary>
        ///     Copy the state of any matching animation states from this to another
        /// </summary>
        public void CopyMatchingState(AnimationStateSet target)
        {
            foreach (var pair in target.AllAnimationStates)
            {
                AnimationState result;
                if (!this.stateSet.TryGetValue(pair.Key, out result))
                {
                    throw new Exception("No animation entry found named '" + pair.Key + "', in " +
                                        "AnimationStateSet.CopyMatchingState");
                }
                else
                {
                    pair.Value.CopyFrom(result);
                }
            }

            // Copy matching enabled animation state list
            target.EnabledAnimationStates.Clear();
            foreach (var state in this.enabledAnimationStates)
            {
                target.EnabledAnimationStates.Add(target.AllAnimationStates[state.Name]);
            }

            target.DirtyFrameNumber = this.dirtyFrameNumber;
        }
        /// <summary>
        ///     Copy the state of any matching animation states from this to another
        /// </summary>
        public void CopyMatchingState(AnimationStateSet target)
        {
            foreach (KeyValuePair <string, AnimationState> pair in target.AllAnimationStates)
            {
                AnimationState result;
                if (!stateSet.TryGetValue(pair.Key, out result))
                {
                    throw new Exception("No animation entry found named '" + pair.Key + "', in " +
                                        "AnimationStateSet.CopyMatchingState");
                }
                else
                {
                    result.CopyTo(pair.Value);
                }
            }

            // Copy matching enabled animation state list
            target.EnabledAnimationStates.Clear();
            foreach (AnimationState state in enabledAnimationStates)
            {
                target.EnabledAnimationStates.Add(target.AllAnimationStates[state.Name]);
            }

            target.DirtyFrameNumber = dirtyFrameNumber;
        }
Example #4
0
 /// <summary>
 ///    Initialize an animation set suitable for use with this mesh.
 /// </summary>
 /// <remarks>
 ///    Only recommended for use inside the engine, not by applications.
 /// </remarks>
 /// <param name="animSet"></param>
 public virtual void InitAnimationState(AnimationStateSet animSet)
 {
     animSet.RemoveAllAnimationStates();
     foreach (var anim in this.animationList.Values)
     {
         animSet.CreateAnimationState(anim.Name, 0, anim.Length);
     }
 }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="animationName"></param>
 /// <param name="parent">The animation state set parent</param>
 /// <param name="time"></param>
 /// <param name="length"></param>
 public AnimationState(string animationName, AnimationStateSet animationStates, float time, float length)
 {
     this.animationName = animationName;
     this.parent        = animationStates;
     this.time          = time;
     this.length        = length;
     this.weight        = 1.0f;
     this.isEnabled     = false;
 }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="animationName"></param>
        /// <param name="parent">The animation state set parent</param>
        /// <param name="time"></param>
        /// <param name="length"></param>
        /// <param name="weight"></param>
        /// <param name="isEnabled"></param>
        public AnimationState(string animationName, AnimationStateSet parent, float time, float length, float weight, bool isEnabled)
        {
            this.animationName = animationName;
            this.parent        = parent;
            this.time          = time;
            this.weight        = weight;
            this.isEnabled     = isEnabled;

            // set using the Length property
            this.Length = length;
        }
Example #7
0
        /// <summary>
        ///    Initialise an animation set suitable for use with this mesh.
        /// </summary>
        /// <remarks>
        ///    Only recommended for use inside the engine, not by applications.
        /// </remarks>
        /// <param name="animSet"></param>
        public virtual void InitAnimationState(AnimationStateSet animSet)
        {
            animSet.RemoveAllAnimationStates();

            // loop through all the internal animations and add new animation states to the passed in
            // collection
            for (int i = 0; i < animationList.Count; i++)
            {
                Animation anim = animationList[i];

                animSet.CreateAnimationState(anim.Name, 0, anim.Length);
            }
        }
Example #8
0
        /// <summary>
        ///     Create a copy of the AnimationStateSet instance.
        /// </summary>
        public AnimationStateSet Clone()
        {
            var newSet = new AnimationStateSet();

            foreach (var animationState in this.stateSet.Values)
            {
                new AnimationState(newSet, animationState);
            }

            // Clone enabled animation state list
            foreach (var animationState in this.enabledAnimationStates)
            {
                newSet.EnabledAnimationStates.Add(newSet.GetAnimationState(animationState.Name));
            }
            return(newSet);
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="animationName"></param>
        /// <param name="parent">The animation state set parent</param>
        /// <param name="time"></param>
        /// <param name="length"></param>
        /// <param name="weight"></param>
        /// <param name="isEnabled"></param>
        public AnimationState(string animationName, AnimationStateSet parent, float time, float length, float weight,
                              bool isEnabled)
        {
            this.animationName = animationName;
            this.parent        = parent;
            this.time          = time;
            this.weight        = weight;

            // Set using Property
            IsEnabled = isEnabled;

            // set using the Length property
            Length    = length;
            this.loop = true;

            parent.NotifyDirty();
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="animSet"></param>
        public virtual void SetAnimationState(AnimationStateSet animSet)
        {
            /*
             * Algorithm:
             * 1. Reset all bone positions
             * 2. Iterate per AnimationState, if enabled get Animation and call Animation::apply
             */

            // reset bones
            Reset();

            // per animation state
            foreach (var animState in animSet.EnabledAnimationStates)
            {
                var anim = GetAnimation(animState.Name);
                // tolerate state entries for animations we're not aware of
                if (anim != null)
                {
                    anim.Apply(this, animState.Time, animState.Weight, this._blendMode == SkeletalAnimBlendMode.Cumulative, 1.0f);
                }
            }             // foreach
        }
        /// <summary>
        ///     Copy the state of any matching animation states from this to another
        /// </summary>
        public void CopyMatchingState(AnimationStateSet target)
        {
            foreach(KeyValuePair<string, AnimationState> pair in target.AllAnimationStates) {
                AnimationState result;
                if (!stateSet.TryGetValue(pair.Key, out result))
                    throw new Exception("No animation entry found named '" + pair.Key + "', in " +
                                        "AnimationStateSet.CopyMatchingState");
                else
                    result.CopyTo(pair.Value);
            }

            // Copy matching enabled animation state list
            target.EnabledAnimationStates.Clear();
            foreach(AnimationState state in enabledAnimationStates)
                target.EnabledAnimationStates.Add(target.AllAnimationStates[state.Name]);

            target.DirtyFrameNumber = dirtyFrameNumber;
        }
        /// <summary>
        ///     Create a copy of the AnimationStateSet instance. 
        /// </summary>
        public AnimationStateSet Clone()
        {
            AnimationStateSet newSet = new AnimationStateSet();

            foreach(AnimationState animationState in stateSet.Values)
                new AnimationState(newSet, animationState);

            // Clone enabled animation state list
            foreach (AnimationState animationState in enabledAnimationStates)
                newSet.EnabledAnimationStates.Add(newSet.GetAnimationState(animationState.Name));
            return newSet;
        }
        /// <summary>
        ///    Initialise an animation set suitable for use with this mesh. 
        /// </summary>
        /// <remarks>
        ///    Only recommended for use inside the engine, not by applications.
        /// </remarks>
        /// <param name="animSet"></param>
        public virtual void InitAnimationState(AnimationStateSet animSet)
        {
            animSet.RemoveAllAnimationStates();

            // loop through all the internal animations and add new animation states to the passed in
            // collection
            for(int i = 0; i < animationList.Count; i++) {
                Animation anim = animationList[i];

                animSet.CreateAnimationState(anim.Name, 0, anim.Length);
            }
        }
Example #14
0
		public void StopSharingSkeletonInstance()
		{
			if ( this.sharedSkeletonInstances == null )
			{
				throw new AxiomException( "This entity is not sharing it's skeletoninstance." );
			}

			// Are we the last to stop sharing?
			if ( this.sharedSkeletonInstances.Count == 1 )
			{
				this.sharedSkeletonInstances = null;
			}
			else
			{
				this.skeletonInstance = new SkeletonInstance( this.mesh.Skeleton );
				this.skeletonInstance.Load();
				this.animationState = new AnimationStateSet();
				this.mesh.InitAnimationState( this.animationState );
				this.frameBonesLastUpdated = new ulong[ulong.MaxValue];
				this.numBoneMatrices = this.skeletonInstance.BoneCount;
				this.boneMatrices = new Matrix4[this.numBoneMatrices];

				this.sharedSkeletonInstances.Remove( this );
				if ( this.sharedSkeletonInstances.Count == 1 )
				{
					this.sharedSkeletonInstances[ 0 ].StopSharingSkeletonInstance();
				}
				this.sharedSkeletonInstances = null;
			}
		}
Example #15
0
        public SceneManager( string name )
			: base()
		{
			this.cameraList = new CameraCollection();
			this.sceneNodeList = new SceneNodeCollection();
			this.animationList = new AnimationCollection();
			this.animationStateList = new AnimationStateSet();
			this.regionList = new List<StaticGeometry.Region>();

			this.shadowCasterQueryListener = new ShadowCasterSceneQueryListener( this );

			// create the root scene node
			this.rootSceneNode = new SceneNode( this, "Root" );
			this.rootSceneNode.SetAsRootNode();
			this.defaultRootNode = this.rootSceneNode;

			this.name = name;

			// default to no fog
			this.fogMode = FogMode.None;

			// no shadows by default
			this.shadowTechnique = ShadowTechnique.None;

			// setup default shadow camera setup
			this._defaultShadowCameraSetup = new DefaultShadowCameraSetup();

			this.illuminationStage = IlluminationRenderStage.None;
			this.renderingNoShadowQueue = false;
			this.renderingMainGroup = false;
			this.shadowColor.a = this.shadowColor.r = this.shadowColor.g = this.shadowColor.b = 0.25f;
			this.shadowDirLightExtrudeDist = 10000;
			this.shadowIndexBufferSize = 51200;
			this.shadowTextureOffset = 0.6f;
			this.shadowTextureFadeStart = 0.7f;
			this.shadowTextureFadeEnd = 0.9f;
			this.shadowTextureSize = 512;
			this.shadowTextureCount = 1;
			this.findVisibleObjects = true;
			this.suppressRenderStateChanges = false;
			this.suppressShadows = false;
			this.shadowUseInfiniteFarPlane = true;
		}
Example #16
0
 /// <summary>
 ///     The moral equivalent of a copy constructor
 /// </summary>
 /// <param name="parent">The animation state set parent</param>
 /// <param name="source">An animation state to copy from</param>
 public AnimationState(AnimationStateSet parent, AnimationState source)
 {
     this.parent = parent;
     source.CopyTo(this);
 }
Example #17
0
		/// <summary>
		///
		/// </summary>
		/// <param name="animSet"></param>
		public virtual void SetAnimationState( AnimationStateSet animSet )
		{
			/*
			Algorithm:
			  1. Reset all bone positions
			  2. Iterate per AnimationState, if enabled get Animation and call Animation::apply
			*/

			// reset bones
			Reset();

			// per animation state
			foreach ( var animState in animSet.EnabledAnimationStates )
			{
				var anim = GetAnimation( animState.Name );
				// tolerate state entries for animations we're not aware of
				if ( anim != null )
				{
					anim.Apply( this, animState.Time, animState.Weight, this._blendMode == SkeletalAnimBlendMode.Cumulative, 1.0f );
				}
			} // foreach
		}
Example #18
0
		/// <summary>
		///    Initialize an animation set suitable for use with this mesh.
		/// </summary>
		/// <remarks>
		///    Only recommended for use inside the engine, not by applications.
		/// </remarks>
		/// <param name="animSet"></param>
		public virtual void InitAnimationState( AnimationStateSet animSet )
		{
			animSet.RemoveAllAnimationStates();
			foreach ( var anim in this.animationList.Values )
			{
				animSet.CreateAnimationState( anim.Name, 0, anim.Length );
			}
		}
Example #19
0
		///<summary>
		///  Adds an Entity to the static geometry.
		///  <remarks>
		///    This method takes an existing Entity and adds its details to the list of elements to include when building. Note that the Entity itself is not copied or referenced in this method; an Entity is passed simply so that you can change the materials of attached SubEntity objects if you want. You can add the same Entity instance multiple times with different material settings completely safely, and destroy the Entity before destroying this InstancedGeometry if you like. The Entity passed in is simply Must be called before 'Build'.
		///  </remarks>
		///</summary>
		///<param name="ent"> The Entity to use as a definition (the Mesh and Materials referenced will be recorded for the build call). </param>
		///<param name="position"> The world position at which to add this Entity </param>
		///<param name="orientation"> The world orientation at which to add this Entity </param>
		///<param name="scale"> </param>
		public virtual void AddEntity( Entity ent, Vector3 position, Quaternion orientation, Vector3 scale )
		{
			Mesh msh = ent.Mesh;

			// Validate
			if ( msh.IsLodManual )
			{
				LogManager.Instance.Write(
					"(InstancedGeometry): Manual LOD is not supported. Using only highest LOD level for mesh " + msh.Name );
			}

			//get the skeleton of the entity, if that's not already done
			if ( ent.Mesh.Skeleton != null && mBaseSkeleton == null )
			{
				mBaseSkeleton = ent.Mesh.Skeleton;
				mSkeletonInstance = new SkeletonInstance( mBaseSkeleton );
				mSkeletonInstance.Load();
				mAnimationState = ent.GetAllAnimationStates();
			}

			BoundingBox sharedWorldBounds;
			// queue this entities submeshes and choice of material
			// also build the lists of geometry to be used for the source of lods


			for ( int i = 0; i < ent.SubEntityCount; ++i )
			{
				SubEntity se = ent.GetSubEntity( i );
				var q = new QueuedSubMesh();

				// Get the geometry for this SubMesh
				q.submesh = se.SubMesh;
				q.geometryLodList = DetermineGeometry( q.submesh );
				q.materialName = se.MaterialName;
				q.orientation = orientation;
				q.position = position;
				q.scale = scale;
				q.ID = mObjectCount;
			}

			mObjectCount++;
		}
 public void UpdateFields()
 {
     boneNameLabel.Text = selectedBone;
     if (skeleton.ContainsBone(boneNameLabel.Text)) {
         Bone bone = skeleton.GetBone(boneNameLabel.Text);
         Quaternion q = ModelViewer.GetRotation(bone.FullTransform);
         boneNameLabel.Text = bone.Name;
         bonePosition.Text = bone.FullTransform.Translation.ToString();
         boneRotation.Text = q.ToString();
         boneRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
         q = bone.Orientation;
         relPosition.Text = bone.Position.ToString();
         relRotation.Text = q.ToString();
         relRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
         Bone bindBone = skeleton.GetBone(boneNameLabel.Text);
         Matrix4 bindBoneFullTransform = bindBone.BindDerivedInverseTransform.Inverse();
         q = ModelViewer.GetRotation(bindBoneFullTransform);
         bindPosition.Text = bindBoneFullTransform.Translation.ToString();
         bindRotation.Text = q.ToString();
         bindRotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
         AnimationState currentAnimation = modelViewer.CurrentAnimation;
         if (currentAnimation != null) {
             animationName.Text = "Animation: " + currentAnimation.Name;
             float currentTime = currentAnimation.Time;
             animationTime.Text = "Time: " + currentTime.ToString();
             Animation anim = skeleton.GetAnimation(currentAnimation.Name);
             NodeAnimationTrack animTrack = anim.NodeTracks[bone.Handle];
             KeyFrame keyFrame1, keyFrame2;
             ushort dummy;
             animTrack.GetKeyFramesAtTime(currentTime, out keyFrame1, out keyFrame2, out dummy);
             AnimationStateSet helperAnimSet = new AnimationStateSet();
             helperSkeleton.InitAnimationState(helperAnimSet);
             AnimationState helperAnimation = helperAnimSet.GetAnimationState(currentAnimation.Name);
             helperAnimation.IsEnabled = true;
             helperAnimation.Time = keyFrame1.Time;
             helperSkeleton.SetAnimationState(helperAnimSet);
             Bone helperBone = helperSkeleton.GetBone(bone.Handle);
             // currentAnimation.Time;
             keyFrame1Time.Text = helperAnimation.Time.ToString();
             q = ModelViewer.GetRotation(helperBone.FullTransform);
             keyFrame1Position.Text = helperBone.FullTransform.Translation.ToString();
             keyFrame1Rotation.Text = q.ToString();
             keyFrame1Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
             helperAnimation.Time = keyFrame2.Time;
             helperSkeleton.SetAnimationState(helperAnimSet);
             keyFrame2Time.Text = helperAnimation.Time.ToString();
             q = ModelViewer.GetRotation(helperBone.FullTransform);
             keyFrame2Position.Text = helperBone.FullTransform.Translation.ToString();
             keyFrame2Rotation.Text = q.ToString();
             keyFrame2Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
     #if NOT
             keyFrame1Time.Text = keyFrame1.Time.ToString();
             q = keyFrame1.Rotation;
             keyFrame1Position.Text = helperBone.Translate.ToString();
             keyFrame1Rotation.Text = q.ToString();
             keyFrame1Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
             keyFrame2Time.Text = keyFrame2.Time.ToString();
             q = keyFrame2.Rotation;
             keyFrame2Position.Text = keyFrame2.Translate.ToString();
             keyFrame2Rotation.Text = q.ToString();
             keyFrame2Rotation2.Text = string.Format("X:{0} Y:{1} Z:{2}", q.PitchInDegrees, q.YawInDegrees, q.RollInDegrees);
     #endif
         } else {
             animationName.Text = "No animation selected";
         }
         bonePosition.Show();
         boneRotation.Show();
         boneRotation2.Show();
         relPosition.Show();
         relRotation.Show();
         relRotation2.Show();
         bindPosition.Show();
         bindRotation.Show();
         bindRotation2.Show();
         if (currentAnimation != null) {
             prevKeyframeLabel.Show();
             keyFrame1TimeLabel.Show();
             keyFrame1PositionLabel.Show();
             keyFrame1RotationLabel.Show();
             keyFrame1Time.Show();
             keyFrame1Position.Show();
             keyFrame1Rotation.Show();
             keyFrame1Rotation2.Show();
             nextKeyframeLabel.Show();
             keyFrame2TimeLabel.Show();
             keyFrame2PositionLabel.Show();
             keyFrame2RotationLabel.Show();
             keyFrame2Time.Show();
             keyFrame2Position.Show();
             keyFrame2Rotation.Show();
             keyFrame2Rotation2.Show();
         } else {
             prevKeyframeLabel.Hide();
             keyFrame1TimeLabel.Hide();
             keyFrame1PositionLabel.Hide();
             keyFrame1RotationLabel.Hide();
             keyFrame1Time.Hide();
             keyFrame1Position.Hide();
             keyFrame1Rotation.Hide();
             keyFrame1Rotation2.Hide();
             nextKeyframeLabel.Hide();
             keyFrame2TimeLabel.Hide();
             keyFrame2PositionLabel.Hide();
             keyFrame2RotationLabel.Hide();
             keyFrame2Time.Hide();
             keyFrame2Position.Hide();
             keyFrame2Rotation.Hide();
             keyFrame2Rotation2.Hide();
         }
     } else {
         boneNameLabel.Text = "Invalid Bone Selected";
         bonePosition.Hide();
         boneRotation.Hide();
         boneRotation2.Hide();
         relPosition.Hide();
         relRotation.Hide();
         relRotation2.Hide();
         bindPosition.Hide();
         bindRotation.Hide();
         bindRotation2.Hide();
         prevKeyframeLabel.Hide();
         keyFrame1TimeLabel.Hide();
         keyFrame1PositionLabel.Hide();
         keyFrame1RotationLabel.Hide();
         keyFrame1Time.Hide();
         keyFrame1Position.Hide();
         keyFrame1Rotation.Hide();
         keyFrame1Rotation2.Hide();
         nextKeyframeLabel.Hide();
         keyFrame2TimeLabel.Hide();
         keyFrame2PositionLabel.Hide();
         keyFrame2RotationLabel.Hide();
         keyFrame2Time.Hide();
         keyFrame2Position.Hide();
         keyFrame2Rotation.Hide();
         keyFrame2Rotation2.Hide();
     }
 }
        public SceneManager(string smName)
        {
            this.smName = smName;
            cameraList = new Dictionary<string, Camera>();
            //lightList = new LightList();
            //entityList = new EntityList();
            movableObjectCollectionMap = new Dictionary<string, Dictionary<string, MovableObject>>();
            sceneNodeList = new Dictionary<string, SceneNode>();
            //billboardSetList = new Dictionary<string, BillboardSet>();
            animationList = new Dictionary<string, Animation>();
            animationStateList = new AnimationStateSet();
            regionList = new List<Region>();

            // create the root scene node
            rootSceneNode = new SceneNode(this, "Root");
            defaultRootNode = rootSceneNode;

            // default to no fog
            fogMode = FogMode.None;

            // no shadows by default
            shadowTechnique = ShadowTechnique.None;

            illuminationStage = IlluminationRenderStage.None;
            renderingNoShadowQueue = false;
            renderingMainGroup = false;
            shadowColor = new ColorEx(0.25f, 0.25f, 0.25f);
            shadowDirLightExtrudeDist = 10000;
            shadowIndexBufferSize = 51200;
            shadowTextureOffset = 0.6f;
            shadowTextureFadeStart = 0.7f;
            shadowTextureFadeEnd = 0.9f;
            shadowTextureSize = 512;
            shadowTextureConfigDirty = true;
            ShadowTextureCount = 1;
            findVisibleObjects = true;
            suppressRenderStateChanges = false;
            suppressShadows = false;
            shadowUseInfiniteFarPlane = true;
            shadowCasterRenderBackFaces = true;
            defaultShadowCameraSetup = new DefaultShadowCameraSetup();
        }
Example #22
0
		/// <summary>
		///    Initialize an animation set suitable for use with this mesh.
		/// </summary>
		/// <remarks>
		///    Only recommended for use inside the engine, not by applications.
		/// </remarks>
		/// <param name="animSet"></param>
		public void InitAnimationState( AnimationStateSet animSet )
		{
			//             Debug.Assert(skeleton != null, "Skeleton not present.");

			if ( HasSkeleton )
			{
				// delegate the animation set to the skeleton
				this._skeleton.InitAnimationState( animSet );

				// Take the opportunity to update the compiled bone assignments
				if ( this.boneAssignmentsOutOfDate )
				{
					CompileBoneAssignments();
				}

				// compile bone assignments for each sub mesh
				for ( var i = 0; i < this._subMeshList.Count; i++ )
				{
					var subMesh = this._subMeshList[ i ];

					if ( subMesh.boneAssignmentsOutOfDate )
					{
						subMesh.CompileBoneAssignments();
					}
				} // for
			}

			// Animation states for vertex animation
			foreach ( var animation in this._animationsList.Values )
			{
				// Only create a new animation state if it doesn't exist
				// We can have the same named animation in both skeletal and vertex
				// with a shared animation state affecting both, for combined effects
				// The animations should be the same length if this feature is used!
				if ( !HasAnimationState( animSet, animation.Name ) )
				{
					animSet.CreateAnimationState( animation.Name, 0.0f, animation.Length );
				}
			}
		}
Example #23
0
		public void ShareSkeletonInstanceWith( Entity entity )
		{
			if ( entity.Mesh.Skeleton != Mesh.Skeleton )
			{
				throw new AxiomException( "The supplied entity has a different skeleton." );
			}
			if ( this.skeletonInstance == null )
			{
				throw new AxiomException( "This entity has no skeleton." );
			}
			if ( this.sharedSkeletonInstances != null && entity.sharedSkeletonInstances != null )
			{
				throw new AxiomException(
					"Both entities already share their SkeletonInstances! At least one of the instances must not share it's instance." );
			}

			//check if we already share our skeletoninstance, we don't want to delete it if so
			if ( this.sharedSkeletonInstances != null )
			{
				entity.ShareSkeletonInstanceWith( this );
			}
			else
			{
				// Clear current skeleton
				this.skeletonInstance.Dispose();
				this.skeletonInstance = null;
				this.animationState = null;
				this.frameBonesLastUpdated = null;

				//copy Skeleton from sharer
				this.skeletonInstance = entity.skeletonInstance;
				this.animationState = entity.animationState;
				this.frameBonesLastUpdated = entity.frameBonesLastUpdated;

				// notify of shareing
				if ( entity.sharedSkeletonInstances == null )
				{
					entity.sharedSkeletonInstances = new EntityList();
					entity.sharedSkeletonInstances.Add( entity );
				}
				this.sharedSkeletonInstances = entity.sharedSkeletonInstances;
				this.sharedSkeletonInstances.Add( this );
			}
		}
Example #24
0
		/// <summary>Returns whether or not this mesh has some kind of vertex animation.</summary>
		public bool HasAnimationState( AnimationStateSet animSet, string name )
		{
			return animSet.HasAnimationState( name );
		}
Example #25
0
		/// <summary>
		///     Copies a subset of animation states from source to target.
		/// </summary>
		/// <remarks>
		///     This routine assume target is a subset of source, it will copy all animation state
		///     of the target with the settings from source.
		/// </remarks>
		/// <param name="target">Reference to animation state set which will receive the states.</param>
		/// <param name="source">Reference to animation state set which will use as source.</param>
		public void CopyAnimationStateSubset( AnimationStateSet target, AnimationStateSet source )
		{
			foreach ( var targetState in target.Values )
			{
				var sourceState = source.GetAnimationState( targetState.Name );

				if ( sourceState == null )
				{
					throw new AxiomException( "No animation entry found named '{0}'.", targetState.Name );
				}
				else
				{
					targetState.CopyFrom( sourceState );
				}
			}
		}
Example #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="animationName"></param>
 /// <param name="animationStates">The animation state set parent</param>
 /// <param name="time"></param>
 /// <param name="length"></param>
 public AnimationState(string animationName, AnimationStateSet animationStates, float time, float length)
     : this(animationName, animationStates, time, length, 1.0f, false)
 {
 }