object IContentProcessor.Process(object input, ContentProcessorContext context) { context.Logger.LogMessage("Processing Dynamic Model"); try { var model = Process(input as NodeContent, context); var dynamicModel = new DynamicModelContent(model); foreach (var mesh in dynamicModel.Meshes) { foreach (var part in mesh.MeshParts) { ProcessVertexBuffer(dynamicModel, context, part); ProcessIndexBuffer(dynamicModel, context, part); } } return(dynamicModel); } catch (Exception ex) { context.Logger.LogMessage("Error {0}", ex); throw; } }
object IContentProcessor.Process(object input, ContentProcessorContext context) { var model = Process((NodeContent)input, context); var outputModel = new DynamicModelContent(model); foreach (var mesh in outputModel.Meshes) { foreach (var part in mesh.MeshParts) { ProcessVertexBuffer(outputModel, context, part); ProcessIndexBuffer(outputModel, context, part); } } // import animation var animationProcessor = new AnimationsProcessor(); animationProcessor.MaxBones = this.MaxBones; animationProcessor.GenerateKeyframesFrequency = this.GenerateKeyframesFrequency; animationProcessor.FixRealBoneRoot = this._fixRealBoneRoot; var animation = animationProcessor.Process((NodeContent)input, context); outputModel.Tag = animation; //ProcessNode((NodeContent)input); return(outputModel); }
protected virtual void ProcessIndexBuffer(DynamicModelContent dynamicModel, ContentProcessorContext context, DynamicModelMeshPartContent part) { if (IndexBufferType != DynamicModelContent.BufferType.Default) { if (!IndexBufferCache.TryGetValue(part.IndexBuffer, out var ib)) { ib = part.IndexBuffer; ib.IsWriteOnly = IndexBufferType == DynamicModelContent.BufferType.DynamicWriteOnly; IndexBufferCache[part.IndexBuffer] = ib; } part.IndexBuffer = ib; } }
protected virtual void ProcessVertexBuffer(DynamicModelContent dynamicModel, ContentProcessorContext context, DynamicModelMeshPartContent part) { if (VertexBufferType != DynamicModelContent.BufferType.Default) { // Replace the default VertexBufferContent with CpuAnimatedVertexBufferContent. if (!VertexBufferCache.TryGetValue(part.VertexBuffer, out var vb)) { vb = part.VertexBuffer; vb.IsWriteOnly = VertexBufferType == DynamicModelContent.BufferType.DynamicWriteOnly; VertexBufferCache[part.VertexBuffer] = vb; } part.VertexBuffer = vb; } }
protected override void ProcessVertexBuffer(DynamicModelContent dynamicModel, ContentProcessorContext context, DynamicModelMeshPartContent part) { if (VertexBufferType != DynamicModelContent.BufferType.Default) { // Replace the default VertexBufferContent with CpuAnimatedVertexBufferContent. CpuAnimatedVertexBufferContent vb; if (!_vertexBufferCache.TryGetValue(part.VertexBuffer, out vb)) { vb = new CpuAnimatedVertexBufferContent(part.VertexBuffer); vb.IsWriteOnly = (VertexBufferType == DynamicModelContent.BufferType.DynamicWriteOnly); _vertexBufferCache[part.VertexBuffer] = vb; } part.VertexBuffer = vb; } }
object IContentProcessor.Process(object input, ContentProcessorContext context) { var model = Process((NodeContent)input, context); var dynamicModel = new DynamicModelContent(model); foreach (var mesh in dynamicModel.Meshes) { foreach (var part in mesh.MeshParts) { ProcessVertexBuffer(dynamicModel, context, part); ProcessIndexBuffer(dynamicModel, context, part); } } return(dynamicModel); }