您可以接收具有相同位置的顶点,因为它们具有不同的法线,但如果您只想知道大小,则无关紧要。
从 ModelMeshPart 顶点缓冲区获取大小可以通过以下方式完成:
public void UpdateFrom( ModelMeshPart meshPart ) {
var indices = new short[meshPart.IndexBuffer.IndexCount];
meshPart.IndexBuffer.GetData<short>( indices );
var vertices = new float[meshPart.VertexBuffer.VertexCount
* meshPart.VertexBuffer.VertexDeclaration.VertexStride/4];
meshPart.VertexBuffer.GetData<float>( vertices );
// Usually first three floats are position,
// this way don't need to know what vertex struct is used
for ( int i=meshPart.StartIndex; i<meshPart.StartIndex + meshPart.PrimitiveCount*3; i++ ) {
int index = (meshPart.VertexOffset + indices[i]) *
meshPart.VertexBuffer.VertexDeclaration.VertexStride/4;
position = new Vector3(vertices[index] , vertices[index+1], vertices[index+2]));
UpdateFrom(position);
}
}
public void UpdateFrom(Vector3 point) {
if (point.X > box.Max.X) box.Max.X = point.X;
if (point.X < box.Min.X) box.Min.X = point.X;
....
}
您也可以在 winforms 示例中使用自定义处理器,您只需在 contentbuilder 中添加引用......诀窍是引用 dll 本身......
static string[] pipelineAssemblies =
{
"Microsoft.Xna.Framework.Content.Pipeline.FBXImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.XImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.TextureImporter" + xnaVersion,
"Microsoft.Xna.Framework.Content.Pipeline.EffectImporter" + xnaVersion,
Application.StartupPath + "\\SkinnedModelPipeline.dll" ,
Application.StartupPath + "\\AnimationPipeline.dll" ,
....