Re: [osg-users] how to change project matrix temporarily?;

2012-10-29 Thread wh_xiexing
hi Robert osifield
i am writing an editor which can add polylines and polygons on the mesh 
model(mountains model).  the lines and polygons must follow the terrain .

so i tessellate the polylines into many parts .   because the mesh is irregular 
, unlike the GIS .   some part of the line segment is above the terrain .  
other 

other is under the terrain .so i want to put the surface shapes (polylines  
polygons ) near to the camera .   worldwind give a method as the following 

code show.but i don't know how to do that in the OSG.






Shawl

From: Robert Osfield
Date: 2012-10-29 16:30
To: OpenSceneGraph Users
Subject: Re: [osg-users] how to change project matrix temporarily?;
Hi Shawl,

Could you explain for what purpose you need to temporarily modify the
projection matrix, this has a huge baring on how you will want to go
about it.

The OSG has an osg::Projection node that allows you to override the
project matrix for the subgraph that you attach below the Projection
Node, and the osg::Camera node that allows you to modify the
projection and view matrices, and there there is slave Camera's at the
viewer level, and finally cull callbacks that you can use to modify
the modelview and projection matrices along with many other things.
As you see there are plenty of options, which to recommend I can't say
as you haven't yet given the context of the problem you are trying to
solve.

Robert.

On 29 October 2012 00:21, wh_xiexing  wrote:
> i want to implement the same effect of the following code using open scene
> graph. can it be possiable?
>
> public void pushProjectionOffest(Double offset)
> {
> // Modify the projection transform to shift the depth values
> slightly toward the camera in order to
> // ensure the lines are selected during depth buffering.
> GL gl = this.getGL();
>
> float[] pm = new float[16];
> gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, pm, 0);
> pm[10] *= offset != null ? offset : 0.99; // TODO: See Lengyel 2 ed.
> Section 9.1.2 to compute optimal offset
>
> gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
> gl.glMatrixMode(GL.GL_PROJECTION);
> gl.glPushMatrix();
> gl.glLoadMatrixf(pm, 0);
> }
>
>  public void popProjectionOffest()
> {
> GL gl = this.getGL();
>
> gl.glMatrixMode(GL.GL_PROJECTION);
> gl.glPopMatrix();
> gl.glPopAttrib();
> }
>
> 
> Shawl
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] how to change project matrix temporarily?;

2012-10-29 Thread Robert Osfield
Hi Shawl,

Could you explain for what purpose you need to temporarily modify the
projection matrix, this has a huge baring on how you will want to go
about it.

The OSG has an osg::Projection node that allows you to override the
project matrix for the subgraph that you attach below the Projection
Node, and the osg::Camera node that allows you to modify the
projection and view matrices, and there there is slave Camera's at the
viewer level, and finally cull callbacks that you can use to modify
the modelview and projection matrices along with many other things.
As you see there are plenty of options, which to recommend I can't say
as you haven't yet given the context of the problem you are trying to
solve.

Robert.

On 29 October 2012 00:21, wh_xiexing  wrote:
> i want to implement the same effect of the following code using open scene
> graph. can it be possiable?
>
> public void pushProjectionOffest(Double offset)
> {
> // Modify the projection transform to shift the depth values
> slightly toward the camera in order to
> // ensure the lines are selected during depth buffering.
> GL gl = this.getGL();
>
> float[] pm = new float[16];
> gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, pm, 0);
> pm[10] *= offset != null ? offset : 0.99; // TODO: See Lengyel 2 ed.
> Section 9.1.2 to compute optimal offset
>
> gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
> gl.glMatrixMode(GL.GL_PROJECTION);
> gl.glPushMatrix();
> gl.glLoadMatrixf(pm, 0);
> }
>
>  public void popProjectionOffest()
> {
> GL gl = this.getGL();
>
> gl.glMatrixMode(GL.GL_PROJECTION);
> gl.glPopMatrix();
> gl.glPopAttrib();
> }
>
> 
> Shawl
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] how to change project matrix temporarily?;

2012-10-28 Thread wh_xiexing
i want to implement the same effect of the following code using open scene 
graph. can it be possiable?

public void pushProjectionOffest(Double offset)
{
// Modify the projection transform to shift the depth values slightly 
toward the camera in order to
// ensure the lines are selected during depth buffering.
GL gl = this.getGL();

float[] pm = new float[16];
gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, pm, 0);
pm[10] *= offset != null ? offset : 0.99; // TODO: See Lengyel 2 ed. 
Section 9.1.2 to compute optimal offset

gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadMatrixf(pm, 0);
}

 public void popProjectionOffest()
{
GL gl = this.getGL();

gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glPopAttrib();
}




Shawl___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org