AutoCAD에 포함 된 응용 프로그램의 3D 부품 미리보기에서 작업하고 있습니다.AutoCAD의 DirectX 뷰어에서 AutoCAD가 정상적으로 작동하지 않습니다.
3D는 SlimDX (2.0 버전)를 통해 DirectX를 사용하여 구현됩니다.
나는 3.5
다음 코드는 다음 코드가 미리
을 렌더링하기 위해 OnPaint를 제어 방법에서 호출foreach (var item in ObjectTable.Objects)
item.Dispose();
_presentParameters = new PresentParameters()
{
BackBufferFormat = Format.Unknown,
SwapEffect = SwapEffect.Discard,
BackBufferWidth = 1500,
BackBufferHeight = 1500,
EnableAutoDepthStencil = true,
AutoDepthStencilFormat = Format.D16,
PresentationInterval = PresentInterval.Immediate
};
_device = new Device(new Direct3D(), 0, DeviceType.Hardware, preview3DTarget.Handle, CreateFlags.HardwareVertexProcessing, _presentParameters);
_device.SetRenderState(RenderState.ZEnable, true);
_device.SetRenderState(RenderState.Lighting, false);
_device.SetRenderState(RenderState.CullMode, Cull.None);
DirectX를 장치를 초기화 .NET 프레임 워크를 사용하고 있습니다
_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); _device.BeginScene(); float ratio = (float)preview3DTarget.ClientSize.Width/preview3DTarget.ClientSize.Height; _device.SetTransform(TransformState.Projection, Matrix.OrthoLH(200, 200, 0.0f, 200.0f)); _device.SetTransform(TransformState.World, Matrix.Translation(-center.X, -center.Y, -center.Z)); _device.SetTransform(TransformState.View, Matrix.RotationYawPitchRoll(Math.radians(0), Math.radians(0), 0.0f) * Matrix.Translation(0f, 0f, 100)); for (int i = 0; i < this.vertices.Count; i += 4) { _device.DrawPrimitives(PrimitiveType.TriangleStrip, i, 2); } for (int i = 0; i < this.points.Count; i += 5) { _device.DrawPrimitives(PrimitiveType.LineStrip, i + this.vertices.Count, 4); } _device.EndScene(); _device.Present();
이 코드는 모두 올바르게 작동하지만 처음 미리보기를 렌더링하면 AutoCAD가 제대로 작동하지 않습니다. AutoCAD 모형 공간 내의 객체는 선택할 수 없습니다. REGEN을 호출하면 화면이 선명하고 아무 것도 다시 그려지지 않습니다. 새 객체가 그려지면 나타납니다. 그러나 기존 객체와 마찬가지로 선택할 수 없습니다.
나는 내 응용 프로그램이 DirectX 엔진을 제어하고 AutoCAD에서 사용을 중지하고 있다고 생각합니다. 어떤 종류의 릴리스/내 응용 프로그램과 AutoCAD에서 DirectX를 동시에 사용할 수 있도록 놓친 전화를 처리합니까?