/// <summary> /// Initializes a new instance of the <see cref="Model"/> class. /// </summary> /// <param name="availableAnimations"> /// The available animations. /// </param> /// <param name="rootBone"> /// The root bone, or null if there's no skeletal information. /// </param> /// <param name="vertexes"> /// The vertexes associated with this model. /// </param> /// <param name="indices"> /// The indices associated with the model. /// </param> public Model( IModelRenderConfiguration[] modelRenderConfigurations, IRenderBatcher renderBatcher, string name, IAnimationCollection availableAnimations, IMaterial material, IModelBone rootBone, ModelVertex[] vertexes, int[] indices) { Name = name; AvailableAnimations = availableAnimations; Root = rootBone; Vertexes = vertexes; Indices = indices; Material = material; _cachedVertexBuffers = new Dictionary <object, VertexBuffer>(); _modelRenderConfigurations = modelRenderConfigurations; _renderBatcher = renderBatcher; if (Root != null) { _flattenedBones = Root.Flatten(); Bones = _flattenedBones.ToDictionary(k => k.Name, v => v); } }
/// <summary> /// Initializes a new instance of the <see cref="Model"/> class. /// </summary> /// <param name="availableAnimations"> /// The available animations. /// </param> /// <param name="rootBone"> /// The root bone, or null if there's no skeletal information. /// </param> /// <param name="vertexes"> /// The vertexes associated with this model. /// </param> /// <param name="indices"> /// The indices associated with the model. /// </param> public Model( IModelRenderConfiguration[] modelRenderConfigurations, IRenderBatcher renderBatcher, string name, IAnimationCollection availableAnimations, IMaterial material, IModelBone rootBone, ModelVertex[] vertexes, int[] indices) { Name = name; AvailableAnimations = availableAnimations; Root = rootBone; Vertexes = vertexes; Indices = indices; Material = material; _cachedVertexBuffers = new Dictionary<object, VertexBuffer>(); _modelRenderConfigurations = modelRenderConfigurations; _renderBatcher = renderBatcher; if (Root != null) { _flattenedBones = Root.Flatten(); Bones = _flattenedBones.ToDictionary(k => k.Name, v => v); } }
/// <summary> /// Serializes a collection of animations to a binary stream. /// </summary> /// <param name="writer"> /// The binary writer to which the animations will be serialized. /// </param> /// <param name="availableAnimations"> /// The animations to serialize. /// </param> private void SerializeAnimations(BinaryWriter writer, IAnimationCollection availableAnimations) { writer.Write(availableAnimations.Count()); foreach (var animation in availableAnimations) { writer.Write(animation.Name); writer.Write(animation.TicksPerSecond); writer.Write(animation.DurationInTicks); this.SerializeStringFloatVector3DictionaryDictionary(writer, animation.TranslationKeys); this.SerializeStringFloatQuaternionDictionaryDictionary(writer, animation.RotationKeys); this.SerializeStringFloatVector3DictionaryDictionary(writer, animation.ScaleKeys); } }
/// <summary> /// Initializes a new instance of the <see cref="Model"/> class. /// </summary> /// <param name="availableAnimations"> /// The available animations. /// </param> /// <param name="rootBone"> /// The root bone, or null if there's no skeletal information. /// </param> /// <param name="vertexes"> /// The vertexes associated with this model. /// </param> /// <param name="indices"> /// The indices associated with the model. /// </param> public Model( IAnimationCollection availableAnimations, IModelBone rootBone, VertexPositionNormalTextureBlendable[] vertexes, int[] indices) { this.AvailableAnimations = availableAnimations; this.Root = rootBone; this.Vertexes = vertexes; this.Indices = indices; if (this.Root != null) { this.m_FlattenedBones = this.Root.Flatten(); this.Bones = this.m_FlattenedBones.ToDictionary(k => k.Name, v => v); } }