How unprojectPoint works?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

ericlgf
Just popping in
Just popping in
Posts: 1
Joined: Tue Aug 03, 2010 07:35

How unprojectPoint works?

Postby ericlgf » Tue Aug 03, 2010 08:22

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?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: How unprojectPoint works?

Postby CrazyEddie » Tue Aug 03, 2010 19:17

Believe it or not, I can't remember exactly why things are like they are in there as far as the exact operations go :oops:

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 :cry: I will go though it next weekend and double-check what's happening.

Sorry for giving such a crappy answer :lol:

CE

songge3604
Quite a regular
Quite a regular
Posts: 60
Joined: Tue Oct 28, 2008 10:46

Re: How unprojectPoint works?

Postby songge3604 » Tue Aug 17, 2010 03:08

I have just deleted it, and recompiled it, then it works fine.
So, I think the function maybe useless. :wink:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: How unprojectPoint works?

Postby CrazyEddie » Tue Aug 17, 2010 09:36

:lol:

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.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests