Re: [osg-users] [forum] About the camera direction of the AnimationPathManipulator.

2014-03-10 Thread Fan ZHANG
Hi,

Did you solve the problem yet?

Cause now I encountered exactly the same problem:(

Thank you!

Cheers,
Fan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58541#58541





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


Re: [osg-users] osgText::Text, a question about line breaker n

2013-09-05 Thread Fan ZHANG
Problem solved!

Because I read texts from XML files, so I just put '
' instead of '\n'.

Thanks for all the replies above!

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56126#56126





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


Re: [osg-users] osgText::Text, a question about line breaker n

2013-09-05 Thread Fan ZHANG
Here is what I get:

Set the text using a std::string,  which is converted to an internal TextString.

I think I should find out the secret of TextString.



Oceane wrote:
> Forgive my silly typo, I did mean std::string.
> 
> It is strange that now
> 
>   std::string str = "This is the first line \n This is 
> the second line";
>   text->setText(str);
> works!!!
> 
> I don't know why it failed two hours ago.
> 
> But if I change the str content with things read from external files, the \n 
> does not work again'(
> 
> When creating the external text files, I already added the breaker into the 
> contents.
> 
> Thanks anyway!!!
> 
> 
> 
> 
> Wojtek wrote:
> > Hi,
> > 
> > Hmm, still have doubts. Because of uppercase String name yu just wrote. 
> > std::String does not exist. I would be ok, though, if you wrote you did 
> > declare it as std::string (lowercase) ;-). But lets assume you did just 
> > that and it still does not work, so then I would suggest to enter setText 
> > call with debugger and see what version of it is called. Is it setText( 
> > const osgText::String & ) or setText( const std::string & ) or 
> > setText(const wchar_t* text) ? See which one is this and then select proper 
> > type as your type for declaring str variable.
> > 
> > 
> > Cheers,
> > Wojtek
> > 
> > 
> > 
> > 2013/9/5 Fan ZHANG < ()>
> > 
> > > Thanks for your reply.
> > > 
> > > In my codes, I did declare it as std::String str.
> > > 
> > > Just simply put String here to illustrate:)
> > > 
> > > 
> > > Wojtek wrote:
> > > 
> > > > Hi,
> > > > 
> > > > 
> > > > Its just a guess, but I believe your call:   text->setText("This is the 
> > > > first line n This is the second line");
> > > > is done implicit conversion to std::string and calling following method:
> > > >   TextBase::setText( const std::string & );
> > > > 
> > > > so in your code I would try declaring str variable as std::string (not 
> > > > a String as you did).
> > > > 
> > > > 
> > > > Cheers,
> > > > Wojtek Lewandowski
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > > 
> > > > 2013/9/5 Fan ZHANG < ()>
> > > > 
> > > > 
> > > > > Thanks for your reply but it still does not work:(
> > > > > 
> > > > > 
> > > > > 
> > > > > Sebastian Messerschmidt wrote:
> > > > > 
> > > > > 
> > > > > > Hi Fan,
> > > > > > 
> > > > > > Could you try:
> > > > > > 
> > > > > > String str = "This is the first line n This is the second line";
> > > > > > text->setText(str);
> > > > > > 
> > > > > > (note the double )
> > > > > > 
> > > > > > cheers
> > > > > > Sebastian
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > > Hi all,
> > > > > > > 
> > > > > > > Sorry to disturb but I have a question about the line breaker 'n'.
> > > > > > > 
> > > > > > > If I use text->setText("This is the first line n This is the 
> > > > > > > second line");
> > > > > > > 
> > > > > > > It works and gets the result as:
> > > > > > > 
> > > > > > > This is the first line
> > > > > > > This is the second line
> > > > > > > 
> > > > > > > But if I read the string from a variable, it does not work, 
> > > > > > > namely,
> > > > > > > 
> > > > > > > String str = "This is the first line n This is the second line";
> > > > > > > text->setText(str);
> > > > > > > 
> > > > > > > The result will be:
> > > > > > > 
> > > > > > > This is the first line n This is the second line
> > > > > > > 
> > > > > > > 
> > 

Re: [osg-users] osgText::Text, a question about line breaker n

2013-09-05 Thread Fan ZHANG
Forgive my silly typo, I did mean std::string.

It is strange that now

std::string str = "This is the first line \n This is 
the second line";
text->setText(str);
works!!!

I don't know why it failed two hours ago.

But if I change the str content with things read from external files, the \n 
does not work again'(

When creating the external text files, I already added the breaker into the 
contents.

Thanks anyway!!!




Wojtek wrote:
> Hi,
> 
> Hmm, still have doubts. Because of uppercase String name yu just wrote. 
> std::String does not exist. I would be ok, though, if you wrote you did 
> declare it as std::string (lowercase) ;-). But lets assume you did just that 
> and it still does not work, so then I would suggest to enter setText call 
> with debugger and see what version of it is called. Is it setText( const 
> osgText::String & ) or setText( const std::string & ) or setText(const 
> wchar_t* text) ? See which one is this and then select proper type as your 
> type for declaring str variable.
> 
> 
> Cheers,
> Wojtek
> 
> 
> 
> 2013/9/5 Fan ZHANG < ()>
> 
> > Thanks for your reply.
> > 
> > In my codes, I did declare it as std::String str.
> > 
> > Just simply put String here to illustrate:)
> > 
> > 
> > Wojtek wrote:
> > 
> > > Hi,
> > > 
> > > 
> > > Its just a guess, but I believe your call:   text->setText("This is the 
> > > first line n This is the second line");
> > > is done implicit conversion to std::string and calling following method:
> > >   TextBase::setText( const std::string & );
> > > 
> > > so in your code I would try declaring str variable as std::string (not a 
> > > String as you did).
> > > 
> > > 
> > > Cheers,
> > > Wojtek Lewandowski
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> > 
> > > 2013/9/5 Fan ZHANG < ()>
> > > 
> > > 
> > > > Thanks for your reply but it still does not work:(
> > > > 
> > > > 
> > > > 
> > > > Sebastian Messerschmidt wrote:
> > > > 
> > > > 
> > > > > Hi Fan,
> > > > > 
> > > > > Could you try:
> > > > > 
> > > > > String str = "This is the first line n This is the second line";
> > > > > text->setText(str);
> > > > > 
> > > > > (note the double )
> > > > > 
> > > > > cheers
> > > > > Sebastian
> > > > > 
> > > > > 
> > > > > 
> > > > > > Hi all,
> > > > > > 
> > > > > > Sorry to disturb but I have a question about the line breaker 'n'.
> > > > > > 
> > > > > > If I use text->setText("This is the first line n This is the second 
> > > > > > line");
> > > > > > 
> > > > > > It works and gets the result as:
> > > > > > 
> > > > > > This is the first line
> > > > > > This is the second line
> > > > > > 
> > > > > > But if I read the string from a variable, it does not work, namely,
> > > > > > 
> > > > > > String str = "This is the first line n This is the second line";
> > > > > > text->setText(str);
> > > > > > 
> > > > > > The result will be:
> > > > > > 
> > > > > > This is the first line n This is the second line
> > > > > > 
> > > > > > 
> > > > > > Anyone knows why and how to deal with it?
> > > > > > 
> > > > > > I have to read lots of texts from external files.
> > > > > > So it is impossible to do it in the first way to directly put the 
> > > > > > texts there, but to read texts each time.
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > Thanks in advance for any kind reply!
> > > > > > 
> > > > > > Cheers,
> > > > > > 
> > > > > > Fan
> > > > > > 
> > > > > > --
> > > > > > Read this topic online here:
> > > > > > 
> > >

Re: [osg-users] osgText::Text, a question about line breaker n

2013-09-05 Thread Fan ZHANG
Thanks for your reply.

In my codes, I did declare it as std::String str.

Just simply put String here to illustrate:)


Wojtek wrote:
> Hi,
> 
> 
> Its just a guess, but I believe your call:   text->setText("This is the first 
> line n This is the second line");
> is done implicit conversion to std::string and calling following method:
>   TextBase::setText( const std::string & );
> 
> so in your code I would try declaring str variable as std::string (not a 
> String as you did).
> 
> 
> Cheers,
> Wojtek Lewandowski
> 
> 
> 
> 
> 
> 
> 2013/9/5 Fan ZHANG < ()>
> 
> > Thanks for your reply but it still does not work:(
> > 
> > 
> > 
> > Sebastian Messerschmidt wrote:
> > 
> > > Hi Fan,
> > > 
> > > Could you try:
> > > 
> > > String str = "This is the first line \n This is the second line";
> > > text->setText(str);
> > > 
> > > (note the double )
> > > 
> > > cheers
> > > Sebastian
> > > 
> > > 
> > > > Hi all,
> > > > 
> > > > Sorry to disturb but I have a question about the line breaker 'n'.
> > > > 
> > > > If I use text->setText("This is the first line n This is the second 
> > > > line");
> > > > 
> > > > It works and gets the result as:
> > > > 
> > > > This is the first line
> > > > This is the second line
> > > > 
> > > > But if I read the string from a variable, it does not work, namely,
> > > > 
> > > > String str = "This is the first line n This is the second line";
> > > > text->setText(str);
> > > > 
> > > > The result will be:
> > > > 
> > > > This is the first line n This is the second line
> > > > 
> > > > 
> > > > Anyone knows why and how to deal with it?
> > > > 
> > > > I have to read lots of texts from external files.
> > > > So it is impossible to do it in the first way to directly put the texts 
> > > > there, but to read texts each time.
> > > > 
> > > > 
> > > > 
> > > > Thanks in advance for any kind reply!
> > > > 
> > > > Cheers,
> > > > 
> > > > Fan
> > > > 
> > > > --
> > > > Read this topic online here:
> > > > http://forum.openscenegraph.org/viewtopic.php?p=56110#56110 
> > > > (http://forum.openscenegraph.org/viewtopic.php?p=56110#56110)
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > ___
> > > > osg-users mailing list
> > > > 
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > >  
> > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > > 
> > > > 
> > > 
> > > ___
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > 
> > >  --
> > > Post generated by Mail2Forum
> > > 
> > 
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=56116#56116 
> > (http://forum.openscenegraph.org/viewtopic.php?p=56116#56116)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56118#56118





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


Re: [osg-users] osgText::Text, a question about line breaker n

2013-09-05 Thread Fan ZHANG
Thanks for your reply but it still does not work:(



Sebastian Messerschmidt wrote:
> Hi Fan,
> 
> Could you try:
> 
> String str = "This is the first line \\n This is the second line";
> text->setText(str);
> 
> (note the double \)
> 
> cheers
> Sebastian
> 
> > Hi all,
> > 
> > Sorry to disturb but I have a question about the line breaker '\n'.
> > 
> > If I use text->setText("This is the first line \n This is the second line");
> > 
> > It works and gets the result as:
> > 
> > This is the first line
> > This is the second line
> > 
> > But if I read the string from a variable, it does not work, namely,
> > 
> > String str = "This is the first line \n This is the second line";
> > text->setText(str);
> > 
> > The result will be:
> > 
> > This is the first line \n This is the second line
> > 
> > 
> > Anyone knows why and how to deal with it?
> > 
> > I have to read lots of texts from external files.
> > So it is impossible to do it in the first way to directly put the texts 
> > there, but to read texts each time.
> > 
> > 
> > 
> > Thanks in advance for any kind reply!
> > 
> > Cheers,
> > 
> > Fan
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=56110#56110
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> 
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56116#56116





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


[osg-users] osgText::Text, a question about line breaker \n

2013-09-05 Thread Fan ZHANG
Hi all,

Sorry to disturb but I have a question about the line breaker '\n'.

If I use text->setText("This is the first line \n This is the second line");

It works and gets the result as:

This is the first line
This is the second line

But if I read the string from a variable, it does not work, namely,

String str = "This is the first line \n This is the second line";
text->setText(str);

The result will be:

This is the first line \n This is the second line


Anyone knows why and how to deal with it?

I have to read lots of texts from external files.
So it is impossible to do it in the first way to directly put the texts there, 
but to read texts each time.



Thanks in advance for any kind reply!

Cheers,

Fan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56110#56110





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


Re: [osg-users] [forum] How to overlap two cameras with different scenes?

2013-04-24 Thread Fan ZHANG
Thanks so much for your kindly help and will try the solution tomorrow.


robertosfield wrote:
> On 24 April 2013 17:16, Fan ZHANG < ()> wrote:
> 
> >  Thanks for your reply but my house names are not HUD texts.
> > 
> > They are 3D objects too.
> > 
> > And for future purpose they have to be 3D objects.
> > 
> 
> 
> It doesn't matter, the same technique applies for 3D and 2D objects.
> 
>  
> 
> >  And I realize I posted to a wrong place in the forum, please move this 
> > post to the right place if you can ,thanks:)
> > 
> 
> 
> 
> I don't use the forum, just the mailing list so have little knowledge or 
> control over what the forum does for threads.
> 
> Robert.
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53793#53793





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


Re: [osg-users] [forum] How to overlap two cameras with different scenes?

2013-04-24 Thread Fan ZHANG
Thanks for your reply but my house names are not HUD texts.

They are 3D objects too.

And for future purpose they have to be 3D objects.

And I realize I posted to a wrong place in the forum, please move this post to 
the right place if you can ,thanks:)



robertosfield wrote:
> Hi Fan,
> 
> 
> For HUD's like this have a look at the osghud example.  The key bit you need 
> to add is to set the ClearMask to just clear the depth buffer of the overlaid 
> Camera, and set the RenderOrder of the Camera's to make sure the overlay 
> camera gets drawn second.
> 
> Robert.
> 
> 
> 
> On 24 April 2013 16:57, Fan ZHANG < ()> wrote:
> 
> > Hi all,
> > 
> > Sorry to disturb but I want to know how can I overlap two cameras with two 
> > different scenes?
> > 
> > Here the picture is the result I tried with CompositeViewer, but this is 
> > not exactly what I want. As you can see, the names of houses are displayed 
> > in one view while buildings in another view.
> > 
> > I have one scenegraph containing only buildings and another one containing 
> > only house names. Due to some specific needs, I can not put them under the 
> > same camera.
> > 
> > So I have one camera adding houses as children and meanwhile one camera 
> > adding house names as children. So how can I overlap them in one view?
> > 
> > I tried like this but failed, I don't have a good master of OSG theory part 
> > :(
> > 
> > 
> > Code:
> > 
> > osgViewer::Viewer viewer;
> > //is this a right way to add houses to one camera?
> > viewer.getCamera()->addChild(houses);
> > 
> > //here I want to construct a camera, with all the parameters the same as 
> > the viewer.getCamera(), so that they can be overlaped. Is this a right way?
> >     osg::Camera* myCam = new osg::Camera;
> >     myCam->setProjectionMatrix(viewer.getCamera()->getProjectionMatrix());
> >     myCam->setViewMatrix(viewer.getCamera()->getViewMatrix());
> >     myCam->setViewport(viewer.getCamera()->getViewport());
> >     myCam->addChild(house names);
> >     myCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
> >     viewer.addSlave(myCam, false);
> > 
> > 
> > 
> > And I don't know how to make them visualized.
> > 
> > I searched for answer in older posts, and I found the "Producer" example, I 
> > don't have the Producer version. Then there was suggestion of looking at 
> > osgdistortion example where there are multiple cameras. However these 
> > multiple cameras share the same scene dataset, simple by 
> > viewer.assignSceneDataToCameras(). But I don't use the same dataset.
> > 
> > I don't know if I make myself clear here.
> > 
> > So huge thanks in advance for any reply:)
> > 
> > Fan
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=53788#53788 
> > (http://forum.openscenegraph.org/viewtopic.php?p=53788#53788)
> > 
> > 
> > 
> > 
> > Attachments:
> > http://forum.openscenegraph.org//files/result_155.png 
> > (http://forum.openscenegraph.org//files/result_155.png)
> > http://forum.openscenegraph.org//files/result_212.png 
> > (http://forum.openscenegraph.org//files/result_212.png)
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53790#53790





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


[osg-users] [forum] How to overlap two cameras with different scenes?

2013-04-24 Thread Fan ZHANG
Hi all,

Sorry to disturb but I want to know how can I overlap two cameras with two 
different scenes?

Here the picture is the result I tried with CompositeViewer, but this is not 
exactly what I want. As you can see, the names of houses are displayed in one 
view while buildings in another view.

I have one scenegraph containing only buildings and another one containing only 
house names. Due to some specific needs, I can not put them under the same 
camera.

So I have one camera adding houses as children and meanwhile one camera adding 
house names as children. So how can I overlap them in one view?

I tried like this but failed, I don't have a good master of OSG theory part :( 


Code:

osgViewer::Viewer viewer;
//is this a right way to add houses to one camera?
viewer.getCamera()->addChild(houses);

//here I want to construct a camera, with all the parameters the same as the 
viewer.getCamera(), so that they can be overlaped. Is this a right way?
osg::Camera* myCam = new osg::Camera;
myCam->setProjectionMatrix(viewer.getCamera()->getProjectionMatrix());
myCam->setViewMatrix(viewer.getCamera()->getViewMatrix());
myCam->setViewport(viewer.getCamera()->getViewport());
myCam->addChild(house names);
myCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
viewer.addSlave(myCam, false);



And I don't know how to make them visualized.

I searched for answer in older posts, and I found the "Producer" example, I 
don't have the Producer version. Then there was suggestion of looking at 
osgdistortion example where there are multiple cameras. However these multiple 
cameras share the same scene dataset, simple by 
viewer.assignSceneDataToCameras(). But I don't use the same dataset. 

I don't know if I make myself clear here.

So huge thanks in advance for any reply:)

Fan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53788#53788




Attachments: 
http://forum.openscenegraph.org//files/result_155.png
http://forum.openscenegraph.org//files/result_212.png


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


Re: [osg-users] How to acquire the screen coordinates of a 3D object?

2013-02-11 Thread Fan ZHANG
And here are the contents of matrices:


The viewMatrix is 
1.00 0.00 0.00 0.00
0.00 1.00 0.00 0.00
0.00 0.00 1.00 0.00
0.00 0.00 0.00 1.00

The projectionMatrix is 
2.403846 0.00 0.00 0.00
0.00 3.846154 0.00 0.00
0.00 0.00 -1.000200 -1.00
0.00 0.00 -2.000200 0.00

The projectionMatrix is 
840.00 0.00 0.00 0.00
0.00 525.00 0.00 0.00
0.00 0.00 0.50 0.00
0.00 525.00 0.50 1.00


Anything wrong with these matrices?


Thank you!

Cheers,
Fan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52533#52533





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


Re: [osg-users] How to acquire the screen coordinates of a 3D object?

2013-02-07 Thread Fan ZHANG

S2LR wrote:
> If you're new to the OSG, it is really helpful to look at the examples and 
> also search the OSG forums for the problems you're looking for. Many of the 
> questions most new folks ask, have already been addressed and answered in the 
> forum.
> 
> Hopefully the link below will help you...
> 
> http://forum.openscenegraph.org/viewtopic.php?t=9172&highlight=
> 
> Shayne


Thank you so much for your kindly remind and reply, I will see to it next time.
Sorry to disturb you all again, because the result I got was quite strange:

Before transformation, the original coordinates of CityGML are X 
3450462.314718, Y 5430520.143368, Z 8.289120
After automatically transformation, the coordinates are X -840532249.575058, Y 
-1322874921.178542
After manually transformation, the coordinates are  X -840532249.575058, Y 
-1322874921.178542, Z 1.120752

Before transformation, the original coordinates of CityGML are X 
3450398.833305, Y 5430561.272085, Z 11.772124
After automatically transformation, the coordinates are X -591833875.402660, Y 
-931484454.045872
After manually transformation, the coordinates are  X -591833875.402660, Y 
-931484454.045872, Z 1.085055


Firstly I load a CityGML dataset and then acquire some of the 3D point 
information. Automatically and manually are just two names I set, but in fact 
the same, just to compare the result. Here is the manual one:

Code:
osg::Matrix local2worldMatrix;
osg::MatrixList list = root->getWorldMatrices();
for(osg::MatrixList::iterator it = list.begin(); it != list.end(); ++it)
   {local2worldMatrix = local2worldMatrix*(*it);}//For loading one model, this 
step is not necessary actually

osg::Matrix finalMatrix;//the final MVPW matrix
osg::Matrix viewMatrix = cam->getViewMatrix();
osg::Matrix projectionMatrix = cam->getProjectionMatrix();
osg::Matrix windowMatrix = cam->getViewport()->computeWindowMatrix();
finalMatrix = local2worldMatrix*viewMatrix*projectionMatrix*windowMatrix;




And here is the automatic one I got from the link in reply above:


Code:
osg::Vec2d worldToScreen(const osg::Vec3d& worldPosition, const osg::Camera* 
pCamera)
{
osg::Vec2d screenPosition;

osg::Matrixd MVPW = pCamera->getViewMatrix() * 
pCamera->getProjectionMatrix();
osg::Vec4d screenPosition4d = osg::Vec4d(worldPosition, 1.0) * MVPW;
screenPosition4d = screenPosition4d / screenPosition4d.w();
screenPosition4d = 
screenPosition4d*pCamera->getViewport()->computeWindowMatrix();
//screenPosition4d.y() = pCamera->getViewport()->height() - 
screenPosition4d.y();
screenPosition.set(screenPosition4d.x(), screenPosition4d.y());


return screenPosition;
}





Actually no big difference. I think I've missed one important step some where.
But I really don't know why.
Perhaps it is because the camera is just viewer.getCamera().
Then how can I deal with it?

Thanks a lot in advance.


ohh newbie to OSG..

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52471#52471





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


[osg-users] How to acquire the screen coordinates of a 3D object?

2013-01-31 Thread Fan ZHANG
Hi all,

I want to know how to acquire the screen coordinates of a 3D object?

posi is a Vec3 containing the coordinates information in WCS. Then I tried:

osgViewer::Viewer viewer;

osg::Camera* cam = viewer.getCamera();
  
osg::Matrix viewMatrix = cam->getViewMatrix();
posi = posi*viewMatrix;

osg::Matrix projectionMatrix = cam->getProjectionMatrix();
posi = posi*projectionMatrix;


Staring here, the codes do not work anymore:

osg::Matrix windowMatrix = cam->getViewport()->computeWindowMatrix();
posi = posi*windowMatrix;

Here the posi is supposed to be the right screen coordinates but it just does 
not work. Then how can I do with this?

Sorry for this simple post but I don't know very well about OpenGL and OSG, and 
this question already occupied me two days.  

So thanks in advance for anyone who gives me a reply!
... 

Thank you!

Cheers,

Fan


ohh newbie to OSG..

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52304#52304





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


[osg-users] [forum] Segmentation fault (core dumped), difference lies bewteen using a function or not....

2012-09-14 Thread Fan ZHANG
Hi all,

I have a problem that if I put the contents of the function 'findVertices' 
directly here, it runs perfectly. But if I separate it out and just call it 
here, it compiles well but when it runs, it gets the error of Segmentation 
fault (core dumped)


strange?

int main( int argc, char** argv)

{

std::string file;
file = "..citygml";

findVertices(file);

osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile(file));
viewer.run();
 
return 1;
}


Thank you!

Cheers,
Fan


ohh newbie to OSG..

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50048#50048





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


Re: [osg-users] [forum] Anyone knows how to load CityGML files in OSG?

2012-09-12 Thread Fan ZHANG
oh what a shame
Simply needs to remove '/root' at the beginning of the file path
Now it works...

tks~



tassilo.glander wrote:
> Hi Fan,
> 
> I do not see something wrong in this moment. I would try a few things:
> * Do you get commandline output while loading? (libcitygml usually puts out 
> something text while loading)
> * You could check that something is loaded with a debugger to check what is 
> returned or add some code to see if a node is returned.
> * You could try to load another model that is known to work, like the cow.osg 
> model
> * Do you have only one osg on your machine? Might be that when you try 
> osgviewer you actually use another version...
> 
> Cheers,
> Tassilo[/list]



ohh newbie to OSG..

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49988#49988





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


Re: [osg-users] [forum] Anyone knows how to load CityGML files in OSG?

2012-09-12 Thread Fan ZHANG
Okay thanks so much for your suggestions.
I will try to fix this up and leave a feedback here if problem solved.

Thanks again.




tassilo.glander wrote:
> Hi Fan,
> 
> I do not see something wrong in this moment. I would try a few things:
> * Do you get commandline output while loading? (libcitygml usually puts out 
> something text while loading)
> * You could check that something is loaded with a debugger to check what is 
> returned or add some code to see if a node is returned.
> * You could try to load another model that is known to work, like the cow.osg 
> model
> * Do you have only one osg on your machine? Might be that when you try 
> osgviewer you actually use another version...
> 
> Cheers,
> Tassilo[/list]
 :D  :D


ohh newbie to OSG..

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49987#49987





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


Re: [osg-users] [forum] Anyone knows how to load CityGML files in OSG?

2012-09-12 Thread Fan ZHANG
Thanks so much for your fast reply~
I mean to start to deal with citygml files, not just 'see' the graphical model 
on the screen with osgviewer. So I just want to ask how to load citygml files 
and make it display on the screen using C++ codes of my own? I know this is 
sort of simple and stupid questionI just tried several times and failed, so 
I posted it here... 



tassilo.glander wrote:
> Hi Fan,
> 
> not sure what you mean with "load citygml files with codes". You want to 
> access the citygml semantics and attributes in addition to just see the 
> graphical model? Then you have to take a look at the reader in libcitygml to 
> see how it stores the citygml nodes and maybe write your own.
> 
> Cheers,
> Tassilo


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49983#49983





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


[osg-users] [forum] Anyone knows how to load CityGML files in OSG?

2012-09-12 Thread Fan ZHANG
Hi,

There is a plugin libcitygml that supports citygml files read operation in OSG.
And I can use osgviewer to see citygml files.
Now I want to load citygml files with codes.
Should it be added as Node or something?
Actually I tried with the osgDB::readNodeFile
Failed
So please anyone knows the right way?


Thank you!

Cheers,
Fan :D

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49980#49980





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


Re: [osg-users] How to acquire the current location information of a drawable object? And how to calculate the distance between an object and the viewpoint?

2012-07-09 Thread Fan ZHANG
Thanks so much but the first problem still seems quite complicated

Anyway I'll try the cull callback first.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48765#48765





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


[osg-users] [forum] How to acquire the current location information of a drawable object? And how to calculate the distance between an object and the viewpoint?

2012-07-02 Thread Fan ZHANG
Hi all,

I'm quite new to OSG and have no OPENGL background.

I want to know how to acquire the current location information of a drawable 
object?
Actually the initial position of the geometry is set by me. But when I move the 
objects with mouse, the spatial information changes, right? So I want to 
acquire such information.


For the second question, how to calculate the distance between an object and 
the viewpoint? Because I want to differentiate the 'stateset' when objects are 
far away from the viewpoint and when they are close to the camera. And I don't 
even know where the camera viewpoint is!


Regards and thank you!

Cheers,
Fan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48628#48628





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