Hey guys
I'm trying to implement the render of CEGUI with an engine called RenderWare these days. When I worked on the virtual class "rendertarget", I can hardly understand the implementation of Direct3dRenderTarget::unprojectPoint.
In that, the method uses the screen coordinate to be unprojected into a 3D coordinate system and constructs an ray with the centre screen coordinate which is unprojected into a 3D coordinate system as well. Then it projects three points (0,0,0)(0,1,0)(1,0,0) into screen coordinate system, and contructs a plane with that three points( in screen coordinate system strangly ). In the end, the method finds the point where the ray intersects the plane and outputs the point.
So strange! The ray is under 3D coordinate system but the plane is just projected into screen coorinate system. How they can work together?
How unprojectPoint works?
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: How unprojectPoint works?
Believe it or not, I can't remember exactly why things are like they are in there as far as the exact operations go
However, the purpose of the function is (obviously?) to convert a point from the space of the parent window (at the top of the chain, this is screen space), to an equivalent pixel location on a given window, taking into account the orientation of that window (which is obtained via the matrix of the given GeometryBuffer). Basically doing that, in that way, is intended to allow the hit-testing to work correctly with variously orientated windows, which may be nested as required.
So, it's supposed to unproject the ray and calculate the intersection point with a plane that's orientated according to the window. This being said, I think there are some issues here, so it's possible / likely that the implementations I have are wrong I will go though it next weekend and double-check what's happening.
Sorry for giving such a crappy answer
CE
However, the purpose of the function is (obviously?) to convert a point from the space of the parent window (at the top of the chain, this is screen space), to an equivalent pixel location on a given window, taking into account the orientation of that window (which is obtained via the matrix of the given GeometryBuffer). Basically doing that, in that way, is intended to allow the hit-testing to work correctly with variously orientated windows, which may be nested as required.
So, it's supposed to unproject the ray and calculate the intersection point with a plane that's orientated according to the window. This being said, I think there are some issues here, so it's possible / likely that the implementations I have are wrong I will go though it next weekend and double-check what's happening.
Sorry for giving such a crappy answer
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
-
- Quite a regular
- Posts: 60
- Joined: Tue Oct 28, 2008 10:46
Re: How unprojectPoint works?
I have just deleted it, and recompiled it, then it works fine.
So, I think the function maybe useless.
So, I think the function maybe useless.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: How unprojectPoint works?
I don't think the function is useless, the implementation may be buggy (well, it is buggy, I know this), but the function has a definite use, and things are not correct without it. For example, rotate a FrameWindow 45 degrees on the Y axis - without this function, dragging the window with the title bar requires you to drag from the location the title bar would be unrotated, this function takes into account the rotation so dragging works based on the actual visual position of the title bar (if we ignore the afore mentioned little bugs!)
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 3 guests