/// <summary> /// Saves sprite sheet data into an XNB file. /// </summary> protected override void Write(ContentWriter aOutput, SharedResourceDictionary <TKey, TValue> aValue) { int nbElement = 0; nbElement = aValue.Keys.Count; aOutput.WriteObject(nbElement); foreach (TKey key in aValue.Keys) { if (default(TKey) is ValueType) { aOutput.WriteObject(key); } else { aOutput.WriteSharedResource(key); } if (default(TValue) is ValueType) { aOutput.WriteObject(aValue[key]); } else { aOutput.WriteSharedResource(aValue[key]); } } }
protected override void Write(ContentWriter output, CompressedAabbTree value) { bool isEmpty = (value.Count == 0); output.Write(isEmpty); if (isEmpty) { // ----- AABB tree is empty: Serialize only relevant properties. output.Write(value.EnableSelfOverlaps); output.Write(value.BottomUpBuildThreshold); output.WriteSharedResource(value.Filter); } else { // ----- AABB tree has content: Serialize internal structure. // Ensure that spatial partition is up-to-date. value.Update(false); dynamic internals = value.Internals; int state = internals.State; int numberOfItems = internals.NumberOfItems; object items = internals.Items; int numberOfNodes = internals.NumberOfNodes; int[] data = internals.Data; Vector3F quantizationFactor = internals.QuantizationFactor; Vector3F dequantizationFactor = internals.DequantizationFactor; output.Write(state); output.Write(numberOfItems); // _items is null because tree is up-to-date. Debug.Assert(items == null); // _nodes output.Write(numberOfNodes); for (int i = 0; i < numberOfNodes; i++) { output.Write((ushort)data[i * 7 + 0]); // MinimumX output.Write((ushort)data[i * 7 + 1]); // MinimumY output.Write((ushort)data[i * 7 + 2]); // MinimumZ output.Write((ushort)data[i * 7 + 3]); // MaximumX output.Write((ushort)data[i * 7 + 4]); // MaximumY output.Write((ushort)data[i * 7 + 5]); // MaximumZ output.Write((int)data[i * 7 + 6]); // EscapeOffsetOrItem } output.WriteRawObject(value.Aabb); output.WriteRawObject(quantizationFactor); output.WriteRawObject(dequantizationFactor); output.Write(value.EnableSelfOverlaps); output.Write(value.BottomUpBuildThreshold); output.WriteSharedResource(value.Filter); } }
public override void Write(ContentWriter writer, ModelMeshPartContent value) { writer.Write(value.StartVertex); writer.Write(value.NumVertices); writer.Write(value.NumIndicies); writer.Write(value.StartIndex); writer.Write(value.PrimitiveCount); writer.WriteSharedResource(value.Tag); writer.WriteSharedResource(value.VertexBuffer); writer.WriteSharedResource(value.IndexBuffer); writer.WriteSharedResource(value.Material); }
protected override void Write(ContentWriter output, DRMeshContent value) { output.WriteObject(value.BoundingShape); if (value.Submeshes != null) { output.Write(value.Submeshes.Count); foreach (var submesh in value.Submeshes) { output.WriteObject(submesh); } } else { output.Write(0); } output.Write(value.Name ?? string.Empty); bool hasOccluder = (value.Occluder != null); output.Write(hasOccluder); if (hasOccluder) { output.WriteSharedResource(value.Occluder); } #if ANIMATION bool hasSkeleton = (value.Skeleton != null); output.Write(hasSkeleton); if (hasSkeleton) { output.WriteSharedResource(value.Skeleton); } var hasAnimations = (value.Animations != null && value.Animations.Count > 0); output.Write(hasAnimations); if (hasAnimations) { output.WriteSharedResource(value.Animations); } #else output.Write(false); // hasSkeleton = false output.Write(false); // hasAnimations = false #endif output.WriteSharedResource(value.UserData); }
private void WriteAnimationClips(ContentWriter output) { output.Write(animationClips.Count); foreach (AnimationClipContent animationClipContent in animationClips.Values) { output.WriteSharedResource(animationClipContent); } /* * foreach (AnimationClipContent animationTrack in animationClips.Values) * { * output.Write(animationTrack.Name); * output.WriteObject<TimeSpan>(animationTrack.Duration); * * output.Write(animationTrack.Channels.Count); * foreach (KeyValuePair<string, AnimationChannelContent> pairKeyChannel in * animationTrack.Channels) * { * output.Write(pairKeyChannel.Key); * output.Write(pairKeyChannel.Value.Count); * foreach (AnimationKeyframeContent keyframe in pairKeyChannel.Value) * { * output.WriteObject<TimeSpan>(keyframe.Time); * output.Write(keyframe.Transform); * } * } * } */ }
protected override void Write(ContentWriter output, MyreMeshContent value) { //output.WriteObject(value.Parent); //output.Write(value.Parts.Length); //foreach (var item in value.Parts) //{ // output.WriteObject(item); //} output.Write(value.Name); output.Write(value.VertexCount); output.Write(value.TriangleCount); output.WriteObject(value.VertexBuffer); output.WriteObject(value.IndexBuffer); // manually write out the dictionary, as the dictionary reader class DOES NOT EXIST output.Write(value.Materials.Count); foreach (var item in value.Materials) { output.WriteObject(item.Key); output.WriteSharedResource(item.Value); } output.WriteObject(value.BoundingSphere); }
public override void Write(ContentWriter writer, ModelContent value) { writer.Write((uint)value.Bones.Count); foreach (BoneContent bone in value.Bones) { writer.Write(bone.Name); writer.WriteRawObject(bone.Transform); writer.WriteRawObject(bone.InverseAbsoluteTransform); } foreach (BoneContent bone in value.Bones) { writer.Write(bone.Parent != null ? bone.Parent.Index + 1 : 0); writer.WriteRawObject((uint)bone.Children.Count); foreach (BoneContent child in bone.Children) { writer.Write(child != null ? child.Index + 1 : 0); } } writer.Write((uint)value.Meshes.Count); ModelMeshWriter meshWriter = new ModelMeshWriter(); foreach (ModelMeshContent mesh in value.Meshes) { meshWriter.Write(writer, mesh); } writer.Write(value.RootBone != null ? value.RootBone.Index + 1 : 0); writer.WriteSharedResource(value.Tag); writer.Write((uint)value.Animations.Count); // animation count foreach (var item in value.Animations) { writer.WriteRawObject(item); } }
private void WriteAnimationClips(ContentWriter output) { output.Write(animationClips.Count); foreach (AnimationClipContent animationClipContent in animationClips.Values) output.WriteSharedResource(animationClipContent); /* foreach (AnimationClipContent animationTrack in animationClips.Values) { output.Write(animationTrack.Name); output.WriteObject<TimeSpan>(animationTrack.Duration); output.Write(animationTrack.Channels.Count); foreach (KeyValuePair<string, AnimationChannelContent> pairKeyChannel in animationTrack.Channels) { output.Write(pairKeyChannel.Key); output.Write(pairKeyChannel.Value.Count); foreach (AnimationKeyframeContent keyframe in pairKeyChannel.Value) { output.WriteObject<TimeSpan>(keyframe.Time); output.Write(keyframe.Transform); } } } */ }
protected override void Write(ContentWriter output, TriangleMeshShape value) { dynamic internals = value.Internals; Aabb aabbLocal = internals.AabbLocal; List <int> triangleNeighbors = internals.TriangleNeighbors; output.WriteRawObject(aabbLocal); output.WriteObject(value.Partition); output.WriteSharedResource(value.Mesh); bool enableContactWelding = value.EnableContactWelding; output.Write(enableContactWelding); if (enableContactWelding) { Debug.Assert(triangleNeighbors != null); int count = triangleNeighbors.Count; output.Write(count); for (int i = 0; i < count; i++) { output.Write(triangleNeighbors[i]); } } }
protected override void Write(ContentWriter output, CpuSkinnedModelPartContent value) { output.Write(value.TriangleCount); output.WriteObject(value.Vertices); output.WriteObject(value.IndexCollection); output.WriteSharedResource(value.Material); }
private void WriteBones(ContentWriter output) { output.Write(skeleton.Count); foreach (SkinnedModelBoneContent bone in skeleton) { output.WriteSharedResource(bone); } }
private void WriteAnimationClips(ContentWriter output) { output.Write(animationClips.Count); foreach (AnimationClipContent animationClipContent in animationClips.Values) { output.WriteSharedResource(animationClipContent); } }
protected override void Write(ContentWriter output, DRMeshNodeContent value) { // SceneNode properties (base class). output.WriteRawObject <DRSceneNodeContent>(value); // MeshNode properties. output.WriteSharedResource(value.Mesh); }
private static void WriteParts(ContentWriter output, DynamicModelContent model, List <DynamicModelMeshPartContent> parts) { output.Write((uint)parts.Count); foreach (var part in parts) { output.Write((uint)part.VertexOffset); output.Write((uint)part.NumVertices); output.Write((uint)part.StartIndex); output.Write((uint)part.PrimitiveCount); output.WriteObject(part.Tag); output.WriteSharedResource(part.VertexBuffer); output.WriteSharedResource(part.IndexBuffer); output.WriteSharedResource(part.Material); } }
protected override void Write(ContentWriter output, AlignedBox3TreeNode value) { output.Write(value.NumTriangles); output.Write(value.BaseIndex); output.WriteSharedResource <UInt16[]>(value.Indices); output.WriteObject <AlignedBox3>(value.BoundingBox); output.WriteObject <AlignedBox3TreeNode>(value.Left); output.WriteObject <AlignedBox3TreeNode>(value.Right); }
protected override void Write(ContentWriter output, ConvexHullOfShapes value) { int numberOfShapes = value.Children.Count; output.Write(numberOfShapes); for (int i = 0; i < numberOfShapes; i++) { output.WriteSharedResource(value.Children[i]); } }
internal void Write(ContentWriter output) { output.Write(index); output.Write(name); // Write bind pose output.Write(bindPose.Translation); output.Write(bindPose.Orientation); output.Write(bindPose.Scale); output.Write(inverseBindPoseTransform); // Write parent and children output.WriteSharedResource(parent); output.Write(children.Count); foreach (SkinnedModelBoneContent childBone in children) { output.WriteSharedResource(childBone); } }
private void WriteBones(ContentWriter output) { output.Write(skeleton.Count); foreach (SkinnedModelBoneContent bone in skeleton) { //{ output.WriteSharedResource(bone); } /* * output.Write(skeleton[i].Name); * output.Write(skeleton[i].BindPoseTransform); * output.Write(skeleton[i].InverseBindPoseTransform); * * output.WriteSharedResource(skeleton[i].Parent); * * // Write children * output.Write(skeleton[i].Children.Count); * for (int j = 0; j < skeleton.Count; j++) * { * output.WriteSharedResource(skeleton[i].Children[j]); * } */ //} /* * // Write root bone * output.Write(rootBoneContent.Name); * * // Write each bone * output.Write(skinnedModelBoneContentDictionary.Values.Count); * foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values) * { * output.Write(bone.Name); * output.Write(bone.Transform); * output.Write(bone.AbsoluteTransform); * output.Write(bone.InverseBindPoseTransform); * } * * // Write the parent and children of each bone * foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values) * { * string parentBoneName = null; * if (bone.Parent != null) * parentBoneName = bone.Parent.Name; * output.WriteObject<string>(parentBoneName); * * // Children * output.Write(bone.Children.Count); * foreach (SkinnedModelBoneContent childBbone in bone.Children) * output.Write(childBbone.Name); * } */ }
protected override void Write(ContentWriter output, CompositeShape value) { int numberOfChildren = value.Children.Count; output.Write(numberOfChildren); output.WriteObject(value.Partition); for (int i = 0; i < numberOfChildren; i++) { output.WriteSharedResource(value.Children[i]); } }
protected override void Write(ContentWriter output, DualPartition <T> value) { dynamic internals = value.Internals; ISpatialPartition <T> staticPartition = internals.StaticPartition; ISpatialPartition <T> dynamicPartition = internals.DynamicPartition; output.Write(value.EnableSelfOverlaps); output.WriteSharedResource(value.Filter); output.WriteObject(staticPartition); output.WriteObject(dynamicPartition); }
protected override void Write(ContentWriter output, DynamicAabbTree <T> value) { // BasePartition<T> output.Write(value.EnableSelfOverlaps); output.WriteSharedResource(value.Filter); // DynamicAabbTree<T> output.Write(value.BottomUpBuildThreshold); output.Write(value.EnableMotionPrediction); output.Write(value.MotionPrediction); output.Write(value.OptimizationPerFrame); output.Write(value.RelativeMargin); }
/// <summary> /// Saves sprite sheet data into an XNB file. /// </summary> protected override void Write(ContentWriter aOutput, SharedResourceList <T> aValue) { int nbElement = 0; nbElement = aValue.Count; aOutput.WriteObject(nbElement); foreach (T item in aValue) { aOutput.WriteSharedResource(item); } }
protected override void Write(ContentWriter output, H3DMaterialContent value) { output.Write(value.IsSkinned); var effectByteCode = value.EffectCompiled.GetEffectCode(); output.Write(effectByteCode.Length); output.Write(effectByteCode); output.Write(value.Material); output.Write(value.TextureSamplerSettings.Length); foreach (var textureHandler in value.TextureSamplerSettings) { output.Write((byte)textureHandler.MinFilter); output.Write((byte)textureHandler.MagFilter); output.Write((byte)textureHandler.WrapU); output.Write((byte)textureHandler.WrapV); } output.Write(value.TextureList.Length); foreach (var textureContent in value.TextureList) { output.Write(textureContent.Name); } foreach (var textureContent in value.TextureList) { output.WriteSharedResource(textureContent); } output.Write((byte)value.FaceCulling.GetValueOrDefault()); output.Write(value.EmissionColor.GetValueOrDefault(Color.White)); output.Write(value.AmbientColor.GetValueOrDefault(Color.White)); output.Write(value.DiffuseColor.GetValueOrDefault(Color.White)); output.Write(value.Specular0Color.GetValueOrDefault(Color.White)); output.Write(value.Specular1Color.GetValueOrDefault(Color.White)); output.Write(value.Constant0Color.GetValueOrDefault(Color.White)); output.Write(value.Constant1Color.GetValueOrDefault(Color.White)); output.Write(value.Constant2Color.GetValueOrDefault(Color.White)); output.Write(value.Constant3Color.GetValueOrDefault(Color.White)); output.Write(value.Constant4Color.GetValueOrDefault(Color.White)); output.Write(value.Constant5Color.GetValueOrDefault(Color.White)); output.Write(value.BlendColor.GetValueOrDefault(Color.White)); output.Write(value.DepthBufferRead.GetValueOrDefault()); output.Write(value.DepthBufferWrite.GetValueOrDefault()); output.Write(value.StencilBufferRead.GetValueOrDefault()); output.Write(value.StencilBufferWrite.GetValueOrDefault()); }
protected override void Write(ContentWriter output, DRSubmeshContent value) { output.WriteSharedResource(value.VertexBuffer); output.Write(value.StartVertex); output.Write(value.VertexCount); output.WriteSharedResource(value.IndexBuffer); output.Write(value.StartIndex); output.Write(value.PrimitiveCount); if (value.MorphTargets != null) { output.Write(value.MorphTargets.Count); foreach (var morphTarget in value.MorphTargets) { output.WriteObject(morphTarget); } } else { output.Write(0); } if (value.ExternalMaterial != null) { // Submesh uses external material. output.Write(true); output.WriteExternalReference(value.ExternalMaterial); } else { // Submesh uses local material. output.Write(false); output.WriteSharedResource(value.LocalMaterial); } output.WriteSharedResource(value.UserData); }
private void WriteBones(ContentWriter output) { output.Write(skeleton.Count); foreach (SkinnedModelBoneContent bone in skeleton) //{ output.WriteSharedResource(bone); /* output.Write(skeleton[i].Name); output.Write(skeleton[i].BindPoseTransform); output.Write(skeleton[i].InverseBindPoseTransform); output.WriteSharedResource(skeleton[i].Parent); // Write children output.Write(skeleton[i].Children.Count); for (int j = 0; j < skeleton.Count; j++) { output.WriteSharedResource(skeleton[i].Children[j]); } */ //} /* // Write root bone output.Write(rootBoneContent.Name); // Write each bone output.Write(skinnedModelBoneContentDictionary.Values.Count); foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values) { output.Write(bone.Name); output.Write(bone.Transform); output.Write(bone.AbsoluteTransform); output.Write(bone.InverseBindPoseTransform); } // Write the parent and children of each bone foreach (SkinnedModelBoneContent bone in skinnedModelBoneContentDictionary.Values) { string parentBoneName = null; if (bone.Parent != null) parentBoneName = bone.Parent.Name; output.WriteObject<string>(parentBoneName); // Children output.Write(bone.Children.Count); foreach (SkinnedModelBoneContent childBbone in bone.Children) output.Write(childBbone.Name); } */ }
public override void Write(ContentWriter writer, ModelMeshContent value) { writer.Write(value.Name); writer.Write((uint)(value.ParentBone == null ? 0 : value.ParentBone.Index + 1)); writer.WriteRawObject(value.BoundingSphere); writer.WriteSharedResource(value.Tag); writer.Write((uint)value.MeshParts.Count); ModelMeshPartWriter partWriter = new ModelMeshPartWriter(); foreach (ModelMeshPartContent item in value.MeshParts) { partWriter.Write(writer, item); } }
/// <summary> /// Compiles a strongly typed object into binary format. /// </summary> /// <param name="output">The content writer serializing the value.</param> /// <param name="value">The value to write.</param> protected override void Write(ContentWriter output, TimelineGroup value) { output.WriteRawObject(value.FillBehavior); output.Write(value.TargetObject != null); if (value.TargetObject != null) { output.Write(value.TargetObject); } output.Write(value.Count); for (int i = 0; i < value.Count; i++) { output.WriteSharedResource(value[i]); } }
/// <summary> /// Saves instanced model data into an XNB file. /// </summary> public void Write(ContentWriter output) { output.Write(modelParts.Count); foreach (ModelPart modelPart in modelParts) { output.Write(modelPart.IndexCount); output.Write(modelPart.VertexCount); output.Write(modelPart.VertexStride); output.WriteObject(modelPart.VertexElements); output.WriteObject(modelPart.VertexBufferContent); output.WriteObject(modelPart.IndexCollection); output.WriteSharedResource(modelPart.MaterialContent); } }
protected override void Write(ContentWriter output, DRSceneNodeContent value) { if (value.Children != null) { output.Write(value.Children.Count); foreach (var child in value.Children) { output.WriteObject(child); } } else { output.Write(0); } output.Write(value.Name ?? string.Empty); output.WriteRawObject(value.PoseLocal); output.WriteRawObject(value.ScaleLocal); output.Write(value.MaxDistance); output.WriteSharedResource(value.UserData); }
protected override void Write(ContentWriter output, TransformedShape value) { output.WriteSharedResource(value.Child); }
protected override void Write(ContentWriter output, GeometricObject value) { output.WriteRawObject(value.Pose); output.WriteSharedResource(value.Shape); output.WriteRawObject(value.Scale); }
protected override void Write(ContentWriter output, AabbTree <T> value) { output.Write(value.EnableSelfOverlaps); output.Write(value.BottomUpBuildThreshold); output.WriteSharedResource(value.Filter); }
/// <summary> /// Saves custom model data into an XNB file. /// </summary> public void Write( ContentWriter output ) { output.Write( modelParts.Count ); foreach ( ModelPart modelPart in modelParts ) { // Simple data types like integers can be written directly. output.Write( modelPart.TriangleCount ); output.Write( modelPart.VertexCount ); output.Write( modelPart.VertexStride ); // These design time graphics types will be automatically translated // into actual GPU data types when they are loaded back in at runtime. output.WriteObject( modelPart.VertexElements ); output.WriteObject( modelPart.VertexBufferContent ); output.WriteObject( modelPart.IndexCollection ); // A single material instance may be shared by more than one ModelPart, // in which case we only want to write a single copy of the material // data into the XNB file. The WriteSharedResource method takes care // of this merging for us. output.WriteSharedResource( modelPart.MaterialContent ); } }
protected override void Write(ContentWriter output, SweepAndPruneSpace <T> value) { output.Write(value.EnableSelfOverlaps); output.WriteSharedResource(value.Filter); }
protected override void Write(ContentWriter output, MinkowskiSumShape value) { output.WriteSharedResource(value.ObjectA); output.WriteSharedResource(value.ObjectB); }
internal void Write(ContentWriter output) { output.Write(index); output.Write(name); // Write bind pose output.Write(bindPose.Translation); output.Write(bindPose.Orientation); output.Write(bindPose.Scale); output.Write(inverseBindPoseTransform); // Write parent and children output.WriteSharedResource(parent); output.Write(children.Count); foreach (SkinnedModelBoneContent childBone in children) output.WriteSharedResource(childBone); }