Hi Thorsten,
> De: thorsten i renk
> 
> > I don't think the Model matrix will help you much either, as IIRC
> > (0,0,0) is the center of the earth spheroid.
> 
> Hm, the line is
> 
>   gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
> 
> Doesn't gl_ModelViewProjectionMatrix transform things into 2d screen
> coordinates?
> 
> Would it work if I use a different matrix instead? Apparently
> 
>     vec4 groundPoint = gl_ModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
> 
> can be used to generate the zero altitude point just below the
> current view, so then the length of the difference vector dotted with 
> an 'up' normal would represent altitude (?)

gl_ModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); 

has always been the position of the camera in world coordinates.

If object center is at altitude 0, and up vector is (0,0,1,0), you could 
use gl_Vertex.z/gl_Vertex.w as the altitude of the vertex, but you'll 
probably see numerical inaccuracy because transforming big numbers with 
matrices of float is not recommended.

If you need world coordinates of any vertex, OSG predefined this :

// add me to the shader
uniform mat4 osg_ViewMatrixInverse;

that you can use like this :

vec3 wPos = osg_ViewMatrixInverse * gl_ModelViewMatrix * gl_Vertex;

Regards,
-Fred

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to