Select DXF objects in OpenGL rendering orthographic projection
overmaster
7/23/2007 2:20 PM


I work with OpenGL rendering and I want to know how I can build correct Matrix4D object for work with EntitySelector.GetEntitiesInRectangle(...) and EntitySelector.GetClosestEntities(...) methods when we have simply transformation orthographic projection (parallel projection). 
Wout
7/23/2007 3:08 PM


Hi, The transformations taking place in OpenGL are the modeling/viewing, projection and viewport transformations (EDIT: alternatively the screen point can be normalized first to be in OpenGL clipping space). So you will have to take into account all these transformations. It sounds like you have omitted the viewport transformation, which is not explicitly present as a matrix in OpenGL, but that transformation is handled through the glViewport() call. The projection matrix transforms to a cube with corners (1, 1, 1), (1, 1, 1). The viewport matrix transforms this to screen coordinates, so a simple translation and scaling transform. Let me know if this is enough for you to get it to work! Wout 
overmaster
7/23/2007 3:45 PM


Hi, Thanks for your quick answer but I can not undestand where I should use GL.Viewport(int x, I use next code for creating projection: It is a code from OpenGL View example in your solution but I modified it a little for implement my functionality (zoom and and drag). private Matrix4D GetProjectionTransform() // Scale such that front plane rectangle always fits the screen without distorting the image. // See if the screen width or height is the limiting factor. // Use transformation below for orthographic projection (parallel projection). This methods create Matrix4D object and load it in GL and return this matrix and when I try to use this object in next piece of code: protected override void OnMouseUp(MouseEventArgs e) I receive wrong result. What I doing wrong? 
Wout
7/23/2007 4:04 PM


Hi, As stated, there are 2 more transforms that form the full chain. You have picked just the projection transform from that chain. The missing pieces are: The total transform will be: You can check what the transform does by creating some points or line segments yourself, transforming then and draw using GDI if you like to experiment. Wout 
overmaster
10/23/2007 3:49 PM


Hello. I again retun to this topic because early I didn't to receive correct result for mouse selection in OpenGL mode. I try to use your advise but it's not helping to me. Now I think I need to create two methods one will convert OrthographicProjectionMatrix to normal 2DTransformMatrix which I can use in EntitySelector.GetClosestEntities(...) method and scale, move transformations and second opposite method which will convert 2DTransformMatrix to OrthographicProjectionMatrix for rendering in OpenGL. 
overmaster
10/29/2007 11:13 AM


Can give me full example of using OpenGL with scale, move and pick mouse selection functionality, exactly like as in your 'DxfExtendedViewExample VS2005' example but using OpenGL rendering instead of GDI rendering in it. I am very want to use exactly OpenGL rendering instead of GDI rendering in my application because rendering big dxf files in OpenGL greatly more quickly than in GDI 
overmaster
10/29/2007 11:16 AM


There are only rendering and rotation in your example for OpenGL 'DxfOpenGLViewExampleCS' I want get full example with scale, move and pick mouse selection functionality. 
Wout
10/29/2007 11:18 AM


Hi, I need to free a bit of time to work on that, I'll send you an example tomorrow. Regards, Wout 
overmaster
10/29/2007 11:20 AM


Thanks, I'll be waiting for your response. 
overmaster
10/31/2007 8:46 AM


Very big thanks for your example. I'm very impressed your solution. Thanks for your help. 