我正在尝试在混合平行六面体容器内显示几个 3D 对象。得到的结果并不令人满意。
第一个数字似乎是正确的 https://picasaweb.google.com/lh/photo/QabTkrf2zyIMP0UEuZvmTdMTjNZETYmyPJy0liipFm0?feat=directlink
第二个是错误的 https://picasaweb.google.com/lh/photo/JqnZqeTuomNLqDR5vhizadMTjNZETYmyPJy0liipFm0?feat=directlink
我将托管 Directx 与 C# 一起使用
初始化:
DxDeviceArea.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, MaxSizeArea * 2);
DxDeviceArea.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, MaxSizeArea / 2f), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
DxDeviceArea.RenderState.Lighting = true;
DxDeviceArea.RenderState.CullMode = Cull.CounterClockwise;
DxDeviceArea.RenderState.SourceBlend = Blend.SourceAlpha;
DxDeviceArea.RenderState.DestinationBlend = Blend.InvSourceAlpha;
DxDeviceArea.RenderState.AlphaBlendEnable = true;
DxDeviceArea.RenderState.BlendOperation = BlendOperation.Add;
DxDeviceArea.RenderState.AlphaTestEnable = true;
//Set light
DxDeviceArea.Lights[0].Type = LightType.Directional;
DxDeviceArea.Lights[0].Diffuse = Color.White;
DxDeviceArea.Lights[0].Direction = new Vector3(0, 0, -1);
DxDeviceArea.Lights[0].Enabled = true;
在渲染函数中,第一步是在对象内部绘制,第二步是绘制混合边框。
在绘制第二个之前,我将 cullmode 从 CounterClockwise 切换到 None
DxDeviceArea.RenderState.CullMode = Cull.None;
回转
//rotation
DxDeviceArea.Transform.World *= Matrix.RotationY((-PosX / 300F)) * Matrix.RotationX(PosY / 300F);
我怎样才能解决显示的问题?