[osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Morning all,
I have been doing some testing and have updated a fresh copy from SVN of
openscenegraph-data and the latest SVN.
After running examples.bat I get a blank screen on a lot of the examples...
If I run osgviewer cow.osg it works, but cow.osgt does not, it looks like
its WIP but just to let you know or I am not understanding the new format
osgt.
Is there a new plugin for this, maybe my OSG is not using it?



Cheers

Martin

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

On Mon, Jun 27, 2011 at 11:00 AM, Martin Naylor
martinnay...@virginmedia.com wrote:
 I have been doing some testing and have updated a fresh copy from SVN of
 openscenegraph-data and the latest SVN.
 After running examples.bat I get a blank screen on a lot of the examples...
 If I run osgviewer cow.osg it works, but cow.osgt does not, it looks like
 its WIP but just to let you know or I am not understanding the new format
 osgt.
 Is there a new plugin for this, maybe my OSG is not using it?

The .osgt is the new native ascii file fomat that deprecates .osg.  Both the old
format and new .osgt, .osgb and .osgx formats are all supported from
the same osg plugin,
but the serializers are now located in src/osgWrappers/serializers and
srcWraperss/deprecated_dot_osg plugins
that are loading by the osg plugin as required.

Now if the .osgt format is not loading for you then I'd suspect that
you haven't built and installed the latest dev, svn/trunk or
OSG-3.0-rc* properly.

What version do you get when your run:

 osgversion

You should get 3.1.0 is you are using svn/trunk and OSG-3.0.0 for any
of the rc's or the OSG-3.0 branch.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi Robert,
Yeah its 3.1.0
Let me take a look at a few bits and check my paths etc...

Cheers

Martin


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 11:11
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

On Mon, Jun 27, 2011 at 11:00 AM, Martin Naylor
martinnay...@virginmedia.com wrote:
 I have been doing some testing and have updated a fresh copy from SVN of
 openscenegraph-data and the latest SVN.
 After running examples.bat I get a blank screen on a lot of the
examples...
 If I run osgviewer cow.osg it works, but cow.osgt does not, it looks like
 its WIP but just to let you know or I am not understanding the new format
 osgt.
 Is there a new plugin for this, maybe my OSG is not using it?

The .osgt is the new native ascii file fomat that deprecates .osg.  Both the
old
format and new .osgt, .osgb and .osgx formats are all supported from
the same osg plugin,
but the serializers are now located in src/osgWrappers/serializers and
srcWraperss/deprecated_dot_osg plugins
that are loading by the osg plugin as required.

Now if the .osgt format is not loading for you then I'd suspect that
you haven't built and installed the latest dev, svn/trunk or
OSG-3.0-rc* properly.

What version do you get when your run:

 osgversion

You should get 3.1.0 is you are using svn/trunk and OSG-3.0.0 for any
of the rc's or the OSG-3.0 branch.

Robert.
___
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] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

On Mon, Jun 27, 2011 at 12:03 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 I have had a look around and can come up with no problems.
 Not sure where to look at the moment, running  via remote desktop at present
 so ignore the GL errors...it did happen when running on my desktop yesterday
 so I am ruling RDP out for the moment as osgviewer cow.osg works via RDP...

 Attached is the logfile from the debug not sure if it will help.
 I noticed it when I wiped my openscenegraph-data and checked it out again...

The debug output looks OK, it does look that the
osgdb_serializer_osg.dll is found
should it should be able to load the data.  The only slighty odd thing
is that the
osgdb_serializer_ prefix is only used right at the end, it should
really be checked
right at the start rather than searching for osg.dll.  I'll look into
this but I don't think
this is the cause of the issues on your system.

Could you try an:

   osgconv cow.osgt test.osg

To see what result you get.  Try the test.osg with osgviewer.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi Robert,
Yeah the same results, attached is the converted osg file just in case you
spot some oddities..
Certainly a small file, let me know if you need any debug output or anything
you want me to try.
Not sure if it will convert ok being on remotedesktop...


Cheers

Martin.


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 12:12
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

On Mon, Jun 27, 2011 at 12:03 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 I have had a look around and can come up with no problems.
 Not sure where to look at the moment, running  via remote desktop at
present
 so ignore the GL errors...it did happen when running on my desktop
yesterday
 so I am ruling RDP out for the moment as osgviewer cow.osg works via
RDP...

 Attached is the logfile from the debug not sure if it will help.
 I noticed it when I wiped my openscenegraph-data and checked it out
again...

The debug output looks OK, it does look that the
osgdb_serializer_osg.dll is found
should it should be able to load the data.  The only slighty odd thing
is that the
osgdb_serializer_ prefix is only used right at the end, it should
really be checked
right at the start rather than searching for osg.dll.  I'll look into
this but I don't think
this is the cause of the issues on your system.

Could you try an:

   osgconv cow.osgt test.osg

To see what result you get.  Try the test.osg with osgviewer.

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


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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

The test.osg you have is missing all the contents of the scene graph
save for the root group.  I would suspect that loading of the
serializers is amiss somewhere.

The curious thing is that other windows users have been use the new
serializers for a while now without any problems.

As another test could you try:

  osgconv cow.osg test.osgt
  osgviewer test.osgt

Robert.

On Mon, Jun 27, 2011 at 12:19 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Hi Robert,
 Yeah the same results, attached is the converted osg file just in case you
 spot some oddities..
 Certainly a small file, let me know if you need any debug output or anything
 you want me to try.
 Not sure if it will convert ok being on remotedesktop...


 Cheers

 Martin.


 -Original Message-
 From: osg-users-boun...@lists.openscenegraph.org
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
 Osfield
 Sent: 27 June 2011 12:12
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] problem with openscenegraph-data?

 Hi Martin,

 On Mon, Jun 27, 2011 at 12:03 PM, Martin Naylor
 martinnay...@virginmedia.com wrote:
 I have had a look around and can come up with no problems.
 Not sure where to look at the moment, running  via remote desktop at
 present
 so ignore the GL errors...it did happen when running on my desktop
 yesterday
 so I am ruling RDP out for the moment as osgviewer cow.osg works via
 RDP...

 Attached is the logfile from the debug not sure if it will help.
 I noticed it when I wiped my openscenegraph-data and checked it out
 again...

 The debug output looks OK, it does look that the
 osgdb_serializer_osg.dll is found
 should it should be able to load the data.  The only slighty odd thing
 is that the
 osgdb_serializer_ prefix is only used right at the end, it should
 really be checked
 right at the start rather than searching for osg.dll.  I'll look into
 this but I don't think
 this is the cause of the issues on your system.

 Could you try an:

   osgconv cow.osgt test.osg

 To see what result you get.  Try the test.osg with osgviewer.

 Robert.
 ___
 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] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

I've had another thought, the old .osg plugin explictly preloads the
core osg class wrappers to retain backwards compatibility with how
they worked bofore, while the new serailizers load an the serializer
dll's on demand.  It could be this secondary dll loading that is at
fault.

Could you try:

  osgviewer cessnafire.osg

As this should get the plugin to load the osgParticle NodeKit and
associate deprecated  osgParticle wrappers.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
HI Robert,
That works fine!
Is it the files that are naff that are downloaded from Openscenegraph-data,
or need updating?

Cheers

Martin




-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 12:23
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

The test.osg you have is missing all the contents of the scene graph
save for the root group.  I would suspect that loading of the
serializers is amiss somewhere.

The curious thing is that other windows users have been use the new
serializers for a while now without any problems.

As another test could you try:

  osgconv cow.osg test.osgt
  osgviewer test.osgt

Robert.

On Mon, Jun 27, 2011 at 12:19 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Hi Robert,
 Yeah the same results, attached is the converted osg file just in case you
 spot some oddities..
 Certainly a small file, let me know if you need any debug output or
anything
 you want me to try.
 Not sure if it will convert ok being on remotedesktop...


 Cheers

 Martin.


 -Original Message-
 From: osg-users-boun...@lists.openscenegraph.org
 [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
 Osfield
 Sent: 27 June 2011 12:12
 To: OpenSceneGraph Users
 Subject: Re: [osg-users] problem with openscenegraph-data?

 Hi Martin,

 On Mon, Jun 27, 2011 at 12:03 PM, Martin Naylor
 martinnay...@virginmedia.com wrote:
 I have had a look around and can come up with no problems.
 Not sure where to look at the moment, running  via remote desktop at
 present
 so ignore the GL errors...it did happen when running on my desktop
 yesterday
 so I am ruling RDP out for the moment as osgviewer cow.osg works via
 RDP...

 Attached is the logfile from the debug not sure if it will help.
 I noticed it when I wiped my openscenegraph-data and checked it out
 again...

 The debug output looks OK, it does look that the
 osgdb_serializer_osg.dll is found
 should it should be able to load the data.  The only slighty odd thing
 is that the
 osgdb_serializer_ prefix is only used right at the end, it should
 really be checked
 right at the start rather than searching for osg.dll.  I'll look into
 this but I don't think
 this is the cause of the issues on your system.

 Could you try an:

   osgconv cow.osgt test.osg

 To see what result you get.  Try the test.osg with osgviewer.

 Robert.
 ___
 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

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi Robert,
Using .osg works fine, but .osgt is still coming up blank...
Converted cessnafire to osgt and it works ok..

Cheers

Martin


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 12:43
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

I've had another thought, the old .osg plugin explictly preloads the
core osg class wrappers to retain backwards compatibility with how
they worked bofore, while the new serailizers load an the serializer
dll's on demand.  It could be this secondary dll loading that is at
fault.

Could you try:

  osgviewer cessnafire.osg

As this should get the plugin to load the osgParticle NodeKit and
associate deprecated  osgParticle wrappers.

Robert.
___
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] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

On Mon, Jun 27, 2011 at 12:56 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Is it the files that are naff that are downloaded from Openscenegraph-data,
 or need updating?

As far as I'm aware the .osgt files in OpenSceneGraph-Data are all
correct, I have now tagged
and posted the OpenSceneGraph-Data-3.0.0.

   http://www.openscenegraph.org/projects/osg/wiki/Downloads/SampleDatasets

Could you post your the cow.osgt so I can double check it's OK.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi Robert,
I just sent you the cow.osgt I was using, but its stuck in the list manager
approval...
Also I have downloaded and replaced the dataset with the same results.
Anything else you want me to try just shout...

Cheers

Martin

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 13:14
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

On Mon, Jun 27, 2011 at 12:56 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Is it the files that are naff that are downloaded from
Openscenegraph-data,
 or need updating?

As far as I'm aware the .osgt files in OpenSceneGraph-Data are all
correct, I have now tagged
and posted the OpenSceneGraph-Data-3.0.0.

   http://www.openscenegraph.org/projects/osg/wiki/Downloads/SampleDatasets

Could you post your the cow.osgt so I can double check it's OK.

Robert.
___
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] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Martin,

On Mon, Jun 27, 2011 at 1:18 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Hi Robert,
 Here is the osgt cow...
 I will check out 3.0.0 dataset and give that a go..

I've just done a diff and uour cow.osgt is identical with the one
OpenSceneGaph-Data-3.0.0.

The problem at you end has to be an issue with loading the new and
utilzing the new serializers.  I'm afraid I don't
have any clue at all why they might be failing.

From your previous emails you reported sucsess, but you weren't
specific in which test this was.  So just for cariity what happens
when you do:

  osgconv cow.osg test.osgt
  osgviewer test.osgt

If this works could you compare the cow.osgt in OpenSceneGraph-Data
and the test.osgt.

Robert.


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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi Robert,
I just did a diff on the files, it's the old chestnut of carriage returns at
the end of the files(unix style), when comparing against the one using
osgconv.
Believe you have a tool for updating the mass unix carriage returns...does
that make sense?


Cheers

Martin


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 13:31
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi Martin,

On Mon, Jun 27, 2011 at 1:18 PM, Martin Naylor
martinnay...@virginmedia.com wrote:
 Hi Robert,
 Here is the osgt cow...
 I will check out 3.0.0 dataset and give that a go..

I've just done a diff and uour cow.osgt is identical with the one
OpenSceneGaph-Data-3.0.0.

The problem at you end has to be an issue with loading the new and
utilzing the new serializers.  I'm afraid I don't
have any clue at all why they might be failing.

From your previous emails you reported sucsess, but you weren't
specific in which test this was.  So just for cariity what happens
when you do:

  osgconv cow.osg test.osgt
  osgviewer test.osgt

If this works could you compare the cow.osgt in OpenSceneGraph-Data
and the test.osgt.

Robert.


Robert.
___
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] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


From your previous emails you reported sucsess, but you weren't
specific in which test this was.  So just for cariity what happens
when you do:

   osgconv cow.osg test.osgt
   osgviewer test.osgt

If this works could you compare the cow.osgt in OpenSceneGraph-Data
and the test.osgt.


I've just done the same test on my nightly built OSG. I've done this:

osgviewer cow.osgt

(meaning the cow.osgt that's in OSG-Data) and this comes up blank. Then 
I did as you suggest:


osgconv cow.osg test.osgt
osgviewer test.osgt

and this works fine. Diffing cow.osgt (from OSG-Data) and test.osgt 
(from my osgconv) gives a lot of small precision differences in floating 
point numbers (probably meaningless) and a difference in line endings as 
Martin said.


If I change cow.osgt (from OSG-Data) to Windows line endings, then it 
loads correctly in osgviewer. So the question is, why does the line 
ending style make any difference? Perhaps the osgt plugin tries to read 
the file's header, fails because of line endings, and then hands off 
responsibility of loading to another plugin?


I can have a go at debugging this if you have no ideas. Clearly changing 
all the files in OSG-Data to have Windows line endings is not a solution.


J-S

--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

On Mon, Jun 27, 2011 at 2:20 PM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:
 If I change cow.osgt (from OSG-Data) to Windows line endings, then it loads
 correctly in osgviewer. So the question is, why does the line ending style
 make any difference? Perhaps the osgt plugin tries to read the file's
 header, fails because of line endings, and then hands off responsibility of
 loading to another plugin?

 I can have a go at debugging this if you have no ideas. Clearly changing all
 the files in OSG-Data to have Windows line endings is not a solution.

Thanks for the testing.  It confirms that it isn't a problem specific
problem to Martin's system, and show's that we all haven't done enough
testing of all the different combinations of usage of the new
serializers.

I'm glad this has now been spotted, unfortunately Rui is likely to
have headed off to be so we'll probably need to track down the line
ending issues ourselves.

I'll convert line endings to dos on my system to see if I can recreate
the problem under Linux.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

On Mon, Jun 27, 2011 at 2:41 PM, Robert Osfield
robert.osfi...@gmail.com wrote:
 I'll convert line endings to dos on my system to see if I can recreate
 the problem under Linux.

I've just done a test and .osgt with dos line endings works fine under Linux.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Ulrich Hertlein
On 27/06/11 15:46 , Robert Osfield wrote:
 I'll convert line endings to dos on my system to see if I can recreate
 the problem under Linux.
 
 I've just done a test and .osgt with dos line endings works fine under Linux.

I ran the same test on OS X and it works fine here as well (line endings don't 
make a
difference).

/ulrich

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


I can have a go at debugging this if you have no ideas. Clearly changing
all the files in OSG-Data to have Windows line endings is not a solution.


OK, debugging into this, it gets into InputStream::readObjectFields() 
(src/osgDB/InputStream.cpp line 632 on trunk). Here as I understand it, 
it's supposed to read the data for each type in the object's class 
hierarchy. It reads the Object part, then the Node part, and when it 
gets to the Group part (which has only the Children field to read) it 
fails (in UserSerializer::read() - include/osgDB/Serializer line 162).


if ( !is.matchString(_name) )
return true;

(here _name is Children). Going into matchString, which is this:

std::string s; readString(s);
// ...

After readString(s), s is 1, which means that the Children string 
had already been consumed somewhere.


Starting over, it seems that the Children gets consumed when it tries 
to deserialize UserDataContainer (the last field of osg::Object to be 
deserialized). This doesn't match, so it should go back in the stream, 
but it doesn't because from then on when reading osg::Node's properties, 
it always gets the 1.


I don't quite know how to debug this further... Any hints?

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


Thanks for the testing.  It confirms that it isn't a problem specific
problem to Martin's system, and show's that we all haven't done enough
testing of all the different combinations of usage of the new
serializers.


Yeah, well this is the first time I've tried using .osgt files someone 
else created, before I was the one creating them and using them so as we 
saw that use case worked fine. I agree it's something we should have 
tested before, sorry for that.



I'm glad this has now been spotted, unfortunately Rui is likely to
have headed off to be so we'll probably need to track down the line
ending issues ourselves.


See my other message.

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

Thanks for looking into this issue.  I will need to dig into the code
itself to have a go at understanding it so can't yet provide any
suggestions, the difference in behaviour between Windows and Unices
seems to be the key, so I'd suspect there is something probably
happening when reading from the stream that one system end of
tokens/lines are picked up and the other system these aren't.

Unfortunately I have to head offline for half an hour as I have
children to look after and they are icing a birthday that needs some
adult assistance, ahhh the joys of juggling work and family :-)

Robert.

On Mon, Jun 27, 2011 at 3:01 PM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:
 Hi Robert,

 I can have a go at debugging this if you have no ideas. Clearly changing
 all the files in OSG-Data to have Windows line endings is not a solution.

 OK, debugging into this, it gets into InputStream::readObjectFields()
 (src/osgDB/InputStream.cpp line 632 on trunk). Here as I understand it, it's
 supposed to read the data for each type in the object's class hierarchy. It
 reads the Object part, then the Node part, and when it gets to the Group
 part (which has only the Children field to read) it fails (in
 UserSerializer::read() - include/osgDB/Serializer line 162).

            if ( !is.matchString(_name) )
                return true;

 (here _name is Children). Going into matchString, which is this:

    std::string s; readString(s);
    // ...

 After readString(s), s is 1, which means that the Children string had
 already been consumed somewhere.

 Starting over, it seems that the Children gets consumed when it tries to
 deserialize UserDataContainer (the last field of osg::Object to be
 deserialized). This doesn't match, so it should go back in the stream, but
 it doesn't because from then on when reading osg::Node's properties, it
 always gets the 1.

 I don't quite know how to debug this further... Any hints?

 J-S
 --
 __
 Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                    http://whitestar02.dyndns-web.com/
 ___
 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] problem with openscenegraph-data?

2011-06-27 Thread Martin Naylor
Hi All,
Cheers all for looking into it, glad it was not my system...
Let me know if I can be of anymore assistance on the matter.
The good news is I have not found anything else that is causing me issues
under VS2008x64 and Windows 7 x64, with Nvidia 480gtx and latest drivers.
Robert -Enjoy the holiday and icing, I suspect you have had enough of Ice in
Scotland ;)
 
Cheers

Martin 

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
Osfield
Sent: 27 June 2011 15:10
To: OpenSceneGraph Users
Subject: Re: [osg-users] problem with openscenegraph-data?

Hi J-S,

Thanks for looking into this issue.  I will need to dig into the code
itself to have a go at understanding it so can't yet provide any
suggestions, the difference in behaviour between Windows and Unices
seems to be the key, so I'd suspect there is something probably
happening when reading from the stream that one system end of
tokens/lines are picked up and the other system these aren't.

Unfortunately I have to head offline for half an hour as I have
children to look after and they are icing a birthday that needs some
adult assistance, ahhh the joys of juggling work and family :-)

Robert.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

I'm back online once more.  Have you looked into this topic any
further?  Unfortunately as I don't have a Windows box at it's a window
specific problem I'm rather stuck in debugging it.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi Window dev's,

I'm currently investigation the problem under Windows with the unix
line endings, which is a bit awkward as I only have a Linux system so
can't test it directly... So will need Windows users to test stuff out
for me.

One thing I'd like to test is whether the addition of the new
UserDataContainer causes a problem, the check for this new data
structure is only added to .osgt files that are tagged later than so
version 76.  This version is listed in the first few lines of a .osgt
file, so in the cow.osgt you'll see the so version number listed under
the #Version line:

#Ascii Scene
#Version 78
#Generator OpenSceneGraph 2.9.17

Could copy the cow.osgt to cow_76.osgt and then you ammend this files
so the top few lines read read

#Ascii Scene
#Version 76
#Generator OpenSceneGraph 2.9.17

And then attempt to run :

   osgviewer cow_76.osgt

Ohh, you'll need to make sure that the line endings don't change with
the editing.  If you have problem with this I can post you a modified
file.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


I'm back online once more.  Have you looked into this topic any
further?  Unfortunately as I don't have a Windows box at it's a window
specific problem I'm rather stuck in debugging it.


Looking at it some more, the problem seems to be here:

virtual bool matchString( const std::string str )
{
std::string s; readString(s);  // (1)
if ( s==str ) return true; // (2)
else _in-seekg( -(int)(s.length()), std::ios::cur );  // (3)
return false;
}

(src/osgPlugins/osg/AsciiStreamOperator.h line 277 in trunk)

str is UserDataContainer. readString(s) reads Children, without 
quotes of course, which is the next item in the string. (1) Then, since 
the (s==str) test fails (2), it's supposed to seek back by 8 characters 
(3). The call to seekg does give -8 as parameter, but for some reason 
the call seems to not do anything, though it doesn't return an error 
either...


Oh, I think I've just found the problem, and it's definitely weird if 
it's that. It seems that when seeking back by 8 characters, the _fseek() 
function (which seekg eventually calls) converts the relative position 
of -8 to an absolute one. For that, it must know the current position in 
the file, so it calls _ftell. It looks like it counts line endings as 
\r\n when counting the characters, even if they are only \n in the 
actual file. So the position it seeks back to is 148 - 8 = 140. Notice 
that the Children line is the 9th line of the file, so there are 
exactly 8 extra \r characters counted (by pure coincidence), and the 
length of Children is also 8, so when seeking back to before 
Children it actually seeks to right after it.


I don't know how to fix this. It seems to me like the _ftell function is 
broken, it should count exactly what is in the file and not add extra 
characters that aren't there. I guess setting the file to binary mode, 
and then manually replacing all \r\n by \n, and then reading files as on 
Linux on all platforms would work. Or, on Windows, we could read the 
whole file in binary mode, replace \n with \r\n, and then use that in a 
stringstream to be read from by the .osgt plugin. But that sounds like a 
lot of work for something that should work automatically.


Did we ever have a similar problem for the other .osg plugin?

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


Could copy the cow.osgt to cow_76.osgt and then you ammend this files
so the top few lines read read

#Ascii Scene
#Version 76
#Generator OpenSceneGraph 2.9.17

And then attempt to run :

osgviewer cow_76.osgt


This didn't make any difference. The result is the same, only the top 
Group is read because it can't read the Children tag.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

Thanks for digging into the problem.  I find it difficult to believe
that tell, seek istream implementations are broken.  It might be worth
putting a tellg before and after the seek to see what values it's
using.

As for moving to binary mode, this is possible, nor sure of the
fallout though, but it terms of making sure we get the same results
across all platforms it might well be the best thing to do.  Off hand
I don't know how much of a fallout this would have.

As for the .osg plugin, I deliberately avoiding using seek and instead
implemented caching of strings within the FieldReaderIterator to hide
the fact that we'd read data in but then not use it directly.
Potentially would could do something similar with InputStream, but
again I'm not sure how much of a impact this might have.

Robert.

On Mon, Jun 27, 2011 at 6:46 PM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:
 Hi Robert,

 I'm back online once more.  Have you looked into this topic any
 further?  Unfortunately as I don't have a Windows box at it's a window
 specific problem I'm rather stuck in debugging it.

 Looking at it some more, the problem seems to be here:

    virtual bool matchString( const std::string str )
    {
        std::string s; readString(s);                          // (1)
        if ( s==str ) return true;                             // (2)
        else _in-seekg( -(int)(s.length()), std::ios::cur );  // (3)
        return false;
    }

 (src/osgPlugins/osg/AsciiStreamOperator.h line 277 in trunk)

 str is UserDataContainer. readString(s) reads Children, without quotes
 of course, which is the next item in the string. (1) Then, since the
 (s==str) test fails (2), it's supposed to seek back by 8 characters (3). The
 call to seekg does give -8 as parameter, but for some reason the call seems
 to not do anything, though it doesn't return an error either...

 Oh, I think I've just found the problem, and it's definitely weird if it's
 that. It seems that when seeking back by 8 characters, the _fseek() function
 (which seekg eventually calls) converts the relative position of -8 to an
 absolute one. For that, it must know the current position in the file, so it
 calls _ftell. It looks like it counts line endings as \r\n when counting the
 characters, even if they are only \n in the actual file. So the position it
 seeks back to is 148 - 8 = 140. Notice that the Children line is the 9th
 line of the file, so there are exactly 8 extra \r characters counted (by
 pure coincidence), and the length of Children is also 8, so when seeking
 back to before Children it actually seeks to right after it.

 I don't know how to fix this. It seems to me like the _ftell function is
 broken, it should count exactly what is in the file and not add extra
 characters that aren't there. I guess setting the file to binary mode, and
 then manually replacing all \r\n by \n, and then reading files as on Linux
 on all platforms would work. Or, on Windows, we could read the whole file in
 binary mode, replace \n with \r\n, and then use that in a stringstream to be
 read from by the .osgt plugin. But that sounds like a lot of work for
 something that should work automatically.

 Did we ever have a similar problem for the other .osg plugin?

 J-S
 --
 __
 Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                    http://whitestar02.dyndns-web.com/
 ___
 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] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S and all other Window dev's

I have just re-implemented the possibly offending matchString method
with a seekp that uses absolute positions.  The code looks like - the
#if 0 is the original implementation, and the #else implementation is
my new version based on absolute file positions.

The full modified
OpenSceneGraph/src/osgPlugins/osg/AsiiStreamOperator.h is attached.

Robert.

#if 0
virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else _in-seekg( -(int)(s.length()), std::ios::cur );
return false;
}
#else
virtual bool matchString( const std::string str )
{
// record position before read to fallback on if match doesn't succeed.
std::streampos filePos = _in-tellg();

std::string s; readString(s);

if ( s==str ) return true;
else
{
_in-seekg( filePos, std::ios::beg );
}
return false;
}
#endif

I have tested this under Linux and it works fine.  I have no clue to
how things will work out under Windows.  Fingers crossed.

Robert.
#ifndef OSGDB_ASCIISTREAMOPERATOR
#define OSGDB_ASCIISTREAMOPERATOR

#include ostream
#include osgDB/StreamOperator

class AsciiOutputIterator : public osgDB::OutputIterator
{
public:
AsciiOutputIterator( std::ostream* ostream )
: _readyForIndent(false), _indent(0) { _out = ostream; }

virtual ~AsciiOutputIterator() {}

virtual bool isBinary() const { return false; }

virtual void writeBool( bool b )
{
indentIfRequired();
if ( b ) *_out  TRUE ;
else *_out  FALSE ;
}

virtual void writeChar( char c )
{ indentIfRequired(); *_out  (short)c  ' '; }

virtual void writeUChar( unsigned char c )
{ indentIfRequired(); *_out  (unsigned short)c  ' '; }

virtual void writeShort( short s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeUShort( unsigned short s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeInt( int i )
{ indentIfRequired(); *_out  i  ' '; }

virtual void writeUInt( unsigned int i )
{ indentIfRequired(); *_out  i  ' '; }

virtual void writeLong( long l )
{ indentIfRequired(); *_out  l  ' '; }

virtual void writeULong( unsigned long l )
{ indentIfRequired(); *_out  l  ' '; }

virtual void writeFloat( float f )
{ indentIfRequired(); *_out  f  ' '; }

virtual void writeDouble( double d )
{ indentIfRequired(); *_out  d  ' '; }

virtual void writeString( const std::string s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeStream( std::ostream (*fn)(std::ostream) )
{
indentIfRequired(); *_out  fn;
if ( isEndl( fn ) )
{
_readyForIndent = true;
}
}

virtual void writeBase( std::ios_base (*fn)(std::ios_base) )
{
indentIfRequired(); *_out  fn;
}

virtual void writeGLenum( const osgDB::ObjectGLenum value )
{
GLenum e = value.get();
const std::string enumString = osgDB::Registry::instance()-getObjectWrapperManager()-getString(GL, e);
indentIfRequired(); *_out  enumString  ' ';
}

virtual void writeProperty( const osgDB::ObjectProperty prop )
{
std::string enumString = prop._name;
if ( prop._mapProperty )
{
enumString = osgDB::Registry::instance()-getObjectWrapperManager()-getString(prop._name, prop._value);
}
indentIfRequired(); *_out  enumString  ' ';
}

virtual void writeMark( const osgDB::ObjectMark mark )
{
_indent += mark._indentDelta;
indentIfRequired(); *_out  mark._name;
}

virtual void writeCharArray( const char* s, unsigned int size ) {}

virtual void writeWrappedString( const std::string str )
{
std::string wrappedStr;
unsigned int size = str.size();
for ( unsigned int i=0; isize; ++i )
{
char ch = str[i];
if ( ch=='\' ) wrappedStr += '\\';
else if ( ch=='\\' ) wrappedStr += '\\';
wrappedStr += ch;
}

wrappedStr.insert( std::string::size_type(0), 1, '\' );
wrappedStr += '\';

indentIfRequired();
writeString( wrappedStr );
}

protected:

inline void indentIfRequired()
{
if ( _readyForIndent )
{
for (int i=0; i_indent; ++i)
*_out  ' ';
_readyForIndent = false;
}
}

bool _readyForIndent;
int _indent;
};

class AsciiInputIterator : public osgDB::InputIterator
{
public:
AsciiInputIterator( std::istream* istream ) { _in = istream; }
virtual ~AsciiInputIterator() {}

virtual bool isBinary() const { return false; }

virtual void readBool( bool b )
{
std::string boolString;
 

Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


Thanks for digging into the problem.  I find it difficult to believe
that tell, seek istream implementations are broken.  It might be worth
putting a tellg before and after the seek to see what values it's
using.


I did this:

virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else
{
std::istream::pos_type pos_before = _in-tellg();
_in-seekg( -(int)(s.length()), std::ios::cur );
std::istream::pos_type pos_after = _in-tellg();
}
return false;
}

What I get is pos_before = 148, pos_after = 140. However, next time 
matchString is called, the value of s is 1 instead of Children, so 
it obviously didn't succeed...


Changing the function to:

virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else
{
std::istream::pos_type pos_before = _in-tellg();
for (unsigned int i = 0; i  s.length(); ++i)
_in-unget();
std::istream::pos_type pos_after = _in-tellg();
}
return false;
}

(so instead of seeking back by 8 characters, we call unget() 8 times)

This works, i.e. the next time matchString is called the value of s is 
Children, and the cow is read correctly. What's weird is that I kept 
the two tellg() calls, and they still return the same values (pos_before 
= 148 and pos_after = 140). There seems to be some inconsistency between 
how seekg and tellg work (or the underlying functions they eventually 
call to do their work).


So unless someone finds a better solution, I suggest changing 
matchString from this:


virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else _in-seekg( -(int)(s.length()), std::ios::cur );
return false;
}

to this:

virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else
{
for (unsigned int i = 0; i  s.length(); ++i)
_in-unget();
}
return false;
}

Or you can obfuscate it by removing newlines if you want :-)

It's really sad we need to avoid seekg for one particular platform (and 
I wonder if VC++ 2010 fixes this... I'm on 2008).



As for moving to binary mode, this is possible, nor sure of the
fallout though, but it terms of making sure we get the same results
across all platforms it might well be the best thing to do.  Off hand
I don't know how much of a fallout this would have.

As for the .osg plugin, I deliberately avoiding using seek and instead
implemented caching of strings within the FieldReaderIterator to hide
the fact that we'd read data in but then not use it directly.
Potentially would could do something similar with InputStream, but
again I'm not sure how much of a impact this might have.


For these two possible solutions I'll defer to you or others who might 
know about how stream i/o works on multiple platforms. I'm generally 
just a user of these things and hack at them until they work, I'm not 
well placed to say what will work and what the consequences will be...


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


 _in-seekg( filePos, std::ios::beg );


Still doesn't work for me, same effect... See my other message, and in 
particular the fact that the tellg() calls returned the same values in 
both the working and non-working cases makes me think this is not 
reliable, so even seeking with an absolute position does not work since 
this position comes from tellg()...


_ftell() which is called from tellg() seems to be the source of the 
problem, and my solution in the other message doesn't use this.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

On Mon, Jun 27, 2011 at 7:34 PM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:
 Still doesn't work for me, same effect... See my other message, and in
 particular the fact that the tellg() calls returned the same values in both
 the working and non-working cases makes me think this is not reliable, so
 even seeking with an absolute position does not work since this position
 comes from tellg()...

 _ftell() which is called from tellg() seems to be the source of the problem,
 and my solution in the other message doesn't use this.

Argghghg unget it is.  Could you send me the whole modified file
and I'll merge it with svn/trunk, do some testing and if it looks OK
check it into the OSG-3.0 branch for the release.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert,


Argghghg unget it is.  Could you send me the whole modified file
and I'll merge it with svn/trunk, do some testing and if it looks OK
check it into the OSG-3.0 branch for the release.


Argghghg is exactly the term I would use to describe this situation ;-)

Here is the file (src/osgPlugins/osg/AsciiStreamOperator.h), and you 
might want to put a descriptive comment so people know why this was 
done... After all, my instinct would be to replace a loop with a single 
function call too...


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
#ifndef OSGDB_ASCIISTREAMOPERATOR
#define OSGDB_ASCIISTREAMOPERATOR

#include ostream
#include osgDB/StreamOperator

class AsciiOutputIterator : public osgDB::OutputIterator
{
public:
AsciiOutputIterator( std::ostream* ostream )
: _readyForIndent(false), _indent(0) { _out = ostream; }

virtual ~AsciiOutputIterator() {}

virtual bool isBinary() const { return false; }

virtual void writeBool( bool b )
{
indentIfRequired();
if ( b ) *_out  TRUE ;
else *_out  FALSE ;
}

virtual void writeChar( char c )
{ indentIfRequired(); *_out  (short)c  ' '; }

virtual void writeUChar( unsigned char c )
{ indentIfRequired(); *_out  (unsigned short)c  ' '; }

virtual void writeShort( short s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeUShort( unsigned short s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeInt( int i )
{ indentIfRequired(); *_out  i  ' '; }

virtual void writeUInt( unsigned int i )
{ indentIfRequired(); *_out  i  ' '; }

virtual void writeLong( long l )
{ indentIfRequired(); *_out  l  ' '; }

virtual void writeULong( unsigned long l )
{ indentIfRequired(); *_out  l  ' '; }

virtual void writeFloat( float f )
{ indentIfRequired(); *_out  f  ' '; }

virtual void writeDouble( double d )
{ indentIfRequired(); *_out  d  ' '; }

virtual void writeString( const std::string s )
{ indentIfRequired(); *_out  s  ' '; }

virtual void writeStream( std::ostream (*fn)(std::ostream) )
{
indentIfRequired(); *_out  fn;
if ( isEndl( fn ) )
{
_readyForIndent = true;
}
}

virtual void writeBase( std::ios_base (*fn)(std::ios_base) )
{
indentIfRequired(); *_out  fn;
}

virtual void writeGLenum( const osgDB::ObjectGLenum value )
{
GLenum e = value.get();
const std::string enumString = 
osgDB::Registry::instance()-getObjectWrapperManager()-getString(GL, e);
indentIfRequired(); *_out  enumString  ' ';
}

virtual void writeProperty( const osgDB::ObjectProperty prop )
{
std::string enumString = prop._name;
if ( prop._mapProperty )
{
enumString = 
osgDB::Registry::instance()-getObjectWrapperManager()-getString(prop._name, 
prop._value);
}
indentIfRequired(); *_out  enumString  ' ';
}

virtual void writeMark( const osgDB::ObjectMark mark )
{
_indent += mark._indentDelta;
indentIfRequired(); *_out  mark._name;
}

virtual void writeCharArray( const char* s, unsigned int size ) {}

virtual void writeWrappedString( const std::string str )
{
std::string wrappedStr;
unsigned int size = str.size();
for ( unsigned int i=0; isize; ++i )
{
char ch = str[i];
if ( ch=='\' ) wrappedStr += '\\';
else if ( ch=='\\' ) wrappedStr += '\\';
wrappedStr += ch;
}

wrappedStr.insert( std::string::size_type(0), 1, '\' );
wrappedStr += '\';

indentIfRequired();
writeString( wrappedStr );
}

protected:

inline void indentIfRequired()
{
if ( _readyForIndent )
{
for (int i=0; i_indent; ++i)
*_out  ' ';
_readyForIndent = false;
}
}

bool _readyForIndent;
int _indent;
};

class AsciiInputIterator : public osgDB::InputIterator
{
public:
AsciiInputIterator( std::istream* istream ) { _in = istream; }
virtual ~AsciiInputIterator() {}

virtual bool isBinary() const { return false; }

virtual void readBool( bool b )
{
std::string boolString;
*_in  boolString;
if ( boolString==TRUE ) b = true;
else b = false;
}

virtual void readChar( char c )
{
short s = 0;
*_in  s;
c = (char)s;
}

virtual void readSChar( signed char c )
{
short s = 0;
*_in  s;
c = (signed char)s;
}

virtual void readUChar( unsigned char c )
{

Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Robert Osfield
Hi J-S,

On Mon, Jun 27, 2011 at 8:29 PM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:
 Here is the file (src/osgPlugins/osg/AsciiStreamOperator.h), and you might
 want to put a descriptive comment so people know why this was done... After
 all, my instinct would be to replace a loop with a single function call
 too...

Many thanks for the fix, finally back on trackalbeit rather later
in the evening than I had planned.  The comment of explanation I went
for was:


virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else
{
// originally _in-seekg( -(int)(s.length()),
std::ios::cur ); was used below but
// problems under windows occurred when reading ascii
files with unix line endings.
// The workaround for this problem was to unget each of
the characters in term,
// hacky yes, but at least it works!
for (unsigned int i = 0; i  s.length(); ++i)
_in-unget();
}
return false;
}

Let me know if it doesn't make sense.  I've now merged this change
with svn/trunk and the OSG-3.0 branch.

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


Re: [osg-users] problem with openscenegraph-data?

2011-06-27 Thread Daly, Jason
Hi, all,

Sorry I'm late to the thread, but I can confirm that seeking doesn't work for 
files open in text mode in VC++.  I ran into this with some of my software in 
the past.  It's rather unbelievable, but it's true.  

The docs at msdn.microsoft.com confirm it (search for seekg and look at the 
remarks).  The same is true for the fseek() function in C.

JS's unget fix is probably the best workaround.

--J

Sent from my iPhone

On Jun 27, 2011, at 11:38 PM, Robert Osfield robert.osfi...@gmail.com wrote:

 Hi J-S,
 
 On Mon, Jun 27, 2011 at 8:29 PM, Jean-Sébastien Guay
 jean-sebastien.g...@cm-labs.com wrote:
 Here is the file (src/osgPlugins/osg/AsciiStreamOperator.h), and you might
 want to put a descriptive comment so people know why this was done... After
 all, my instinct would be to replace a loop with a single function call
 too...
 
 Many thanks for the fix, finally back on trackalbeit rather later
 in the evening than I had planned.  The comment of explanation I went
 for was:
 
 
virtual bool matchString( const std::string str )
{
std::string s; readString(s);
if ( s==str ) return true;
else
{
// originally _in-seekg( -(int)(s.length()),
 std::ios::cur ); was used below but
// problems under windows occurred when reading ascii
 files with unix line endings.
// The workaround for this problem was to unget each of
 the characters in term,
// hacky yes, but at least it works!
for (unsigned int i = 0; i  s.length(); ++i)
_in-unget();
}
return false;
}
 
 Let me know if it doesn't make sense.  I've now merged this change
 with svn/trunk and the OSG-3.0 branch.
 
 Robert.
 ___
 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] problem with openscenegraph-data?

2011-06-27 Thread Jean-Sébastien Guay

Hi Robert, Jason,

Thanks for the checkin Robert, looks good though I would have been a bit 
less familiar in the comment but that's fine :-)



Sorry I'm late to the thread, but I can confirm that seeking doesn't work for 
files open in text mode in VC++.  I ran into this with some of my software in 
the past.  It's rather unbelievable, but it's true.


Yeah, really weird. At least we have a workaround, though I would have 
thought something that basic would work out of the box...


Thanks for confirming!

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org