Select DXF objects in OpenGL rendering orthographic projection
![]() 10/31/2007 5:23 PM
|
---|
Hi, Excuse me but I again have problems with OpenGL. 1) I cannot get correct result from method EntitySelector.GetEntitiesInRectangle() but method EntitySelector.GetClosestEntities() works correct. I create Rectangle2D by using mouse then transforms points of rectange how you show me in example then pass this Rectangle2D to EntitySelector.GetEntitiesInRectangle() but method returns IList<IList<DxfEntity>> closestEntities.Count = 0. I don't undestand why method EntitySelector.GetClosestEntities() works correct and method EntitySelector.GetEntitiesInRectangle() not correct. Can you check this in your example and answer me about results? 2) I cannot set white background in OpenGL? How I can do it? |
![]() 11/1/2007 6:06 PM
|
---|
Hi, 1) Make sure the rectangle's first coordinate is the bottom left, and the second coordinate is the top right. Wout |
![]() 11/2/2007 10:19 AM
|
---|
Hi, Thanks for your anwer. It's really work but I have question for you. |
![]() 11/2/2007 12:39 PM
|
---|
It is the same with OpenGL, with the minor modification that the screen point must now be defined in clip space (so normalized to -1, 1 as you have seen already). Alternatively you could correct for the viewport transformation in stead of normalizing the screen point, as I've explained before. Note that you should be using a orthographic transformation (not perspective). Wout |
![]() 11/2/2007 1:57 PM
|
---|
Sorry but I cannot get correct result from calculating real CAD point's coordinates (DxfModel points coordinate) from mouse click point in OpenGL. I am using next code: Matrix4D modelViewTransform = GetModelViewTransform(); public static DxfPolyline2D ConvertToPolyline(Rectangle2D rectangle, Matrix4D matrix)       DxfPolyline2D resultPolyline = new DxfPolyline2D(); Can you say me what I've wrote wrong? |
![]() 11/2/2007 2:03 PM
|
---|
Hi, Looks like you have reversed the order of model view and projection transform. The projection transform takes place last, which means it has to be first in the matrix multiplication: C# Code:
DxfPolyline2D createdPolyline = MathDxf.ConvertToPolyline(
   new Rectangle2D(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y),
   projectionTransform * modelViewTransform
); Also I suggest calculating the inverse matrix just once in stead of for each point again, because it's a fairly expensive operation. Probably you can cache it somewhere. Wout |
![]() 11/2/2007 2:09 PM
|
---|
Thanks I think order of matrix not importent. :) |