[osg-users] Ultra High Resolution Building Format

2009-06-25 Thread brettwiesner

Hi,

Has anyone experimented with an Ultra High Resolution Building (UHRB) 
loader?


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


Re: [osg-users] Database pager questions

2009-06-05 Thread brettwiesner

Thanks!

Robert Osfield wrote:

HI Bret,

On Thu, Jun 4, 2009 at 6:18 PM, brettwiesnerbrettwies...@gmail.com wrote:
  

Hi,

Just validating some assumptions about the database pager...
1) Is paging in single threaded mode blocking? If OSG is in single threaded
mode, will the pager load data and stop rendering or will it load in another
thread anyway?




As others have said the DatabasePager it totally orthogonal to the
osgViewer::Viewer/CompositeViewer, so the pagers threading works
regardless of what you do with the viewer.

  

2) If OSG is running in multithreaded mode will the pager load data
asychronously?



The DatabasePager always loaded asynchronously - that's the whole point of it.

  

Now some real questions:
3) How does the pager decide when to page something in?



When PagedLOD nodes that are encountered during the cull traversal
require an external tile that isn't loaded yet they makes a request to
the loaded the tile.

  

4) How does the pager decide when to page something out?



That depends upon the mode the DatabasePager is set up with.  The
current default in 2.8.0 onwards is to mainatain a maximum number of
active PagedLOD and to prune inactive branches when that number is
exceeded.  Note, it only prunes inactive branches, it never touches
the active ones i.e. the ones on screen,

  

5) How does the pager page something out?



It maintains a list of expired subgraphs and during the update
traversal these subgraphs are removed.

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] Is clearing the nodemasks on loaded data a bad practice?

2009-06-04 Thread brettwiesner

Hi,

We use nodemasks in our scenegraph to do things like figure out what can 
be picked, what can be shadowed, etc. When we load data most of the time 
the nodes come in with masks of 0x. Occasionally we get an .ive 
or .osg file that has some other value set in the nodemask. We are going 
to reset these values under the admonition it's our scenegraph. we 
control those bits. If we leave them alone we have to figure out 
another way to do picking, shadows, etc.


So my question... is this bad practice?

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


Re: [osg-users] Is clearing the nodemasks on loaded data a bad practice?

2009-06-04 Thread brettwiesner

Thanks!

Tomlinson, Gordon wrote:

Generically speaking changing the nodes masks is fine its up to you and
how your program is using them with-in the confines of how culling,
rendering uses them etc.

So no I would says it is not bad practice and is perfectly valid to do


Gordon
Product Manager 3d
__
Gordon Tomlinson
Email  : gtomlinson @ overwatch.textron.com
__


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
brettwiesner
Sent: Thursday, June 04, 2009 12:00 PM
To: OpenSceneGraph Users
Subject: [osg-users] Is clearing the nodemasks on loaded data a bad
practice?

Hi,

We use nodemasks in our scenegraph to do things like figure out what can
be picked, what can be shadowed, etc. When we load data most of the time
the nodes come in with masks of 0x. Occasionally we get an .ive
or .osg file that has some other value set in the nodemask. We are going
to reset these values under the admonition it's our scenegraph. we
control those bits. If we leave them alone we have to figure out
another way to do picking, shadows, etc.

So my question... is this bad practice?

Thanks,
Brett
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
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] Database pager questions

2009-06-04 Thread brettwiesner

Hi,

Just validating some assumptions about the database pager...
1) Is paging in single threaded mode blocking? If OSG is in single 
threaded mode, will the pager load data and stop rendering or will it 
load in another thread anyway?
2) If OSG is running in multithreaded mode will the pager load data 
asychronously?


Now some real questions:
3) How does the pager decide when to page something in?
4) How does the pager decide when to page something out?
5) How does the pager page something out?

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


Re: [osg-users] Database pager questions

2009-06-04 Thread brettwiesner

Thanks!

Ralf Stokholm wrote:

Hi Brett
 
12) As far as I know the database pager is multithreaded regardless 
if osg is running multi or single threaded. Osg threading is related 
to threading of the cull and draw traversals.

3) How does the pager decide when to page something in?
My understanding is that this is based on the cull traversal if a 
pagedlod is (inside) the cull requirements based on the viewfrustrun 
and the lodscale of the camera. its children are loaded.


4) How does the pager decide when to page something out?
This depends on your sceme, when a given lod no longer fulfills the 
requirements to be in the scene it could be culled. The database pager 
pre 2.8 uses a sceme based on how much time has passed since the node 
last fulfilled the requirements to stay in the scene, in 2.8 the 
maximum number of nodes to keep can be capped.

5) How does the pager page something out?
Initially it is removed from the scenegraph and then the nodes are 
deleted (more likely they are dereferences and the ref_ptr takes care 
of freeing the memmory.
 
Brgs
 
Ralf Stokholm


2009/6/4 brettwiesner brettwies...@gmail.com 
mailto:brettwies...@gmail.com


Hi,

Just validating some assumptions about the database pager...
1) Is paging in single threaded mode blocking? If OSG is in single
threaded mode, will the pager load data and stop rendering or will
it load in another thread anyway?
2) If OSG is running in multithreaded mode will the pager load
data asychronously?

Now some real questions:
3) How does the pager decide when to page something in?
4) How does the pager decide when to page something out?
5) How does the pager page something out?

Thanks,
Brett
___
osg-users mailing list
osg-users@lists.openscenegraph.org
mailto: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] Ground clamping to paging terrain

2009-05-28 Thread brettwiesner

Hi,

I want to position something (let's say a building) to a terrain. 
Currently I'm getting the Z value for the building doing this with an 
osgUtil::IntersectVisitor and that works fine for static terrains. When 
I run on a paging terrain (like one from osgEarth) and I position the 
building, I get a Z value of the lowest LOD. Then more data pages in and 
the building gets buried underground as more accurate data comes 
available.


What's the most effiecient ground clamp things to paging terrain?

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


Re: [osg-users] On demand and frame rate capping schemes from Viewer::run()

2009-04-27 Thread brettwiesner

Robert,

Good stuff.Limit frame rate (ie, frame rate capping) is good. But how 
about Fixed frame rate though? Where the OSG renders at a specified 
frame rate no matter what.


Thanks,
Brett

Robert Osfield wrote:

Hi All,

When following up on a bug report about the pager not handling on
demand/lazy frame rendering I resolved the the problems wasn't down to
the pager, just the way the end user viewer code was set up to the the
on demand frame rendering.  Rather than leave this type of viewer
usage open to end users come up with lots of different schemes to
attempt to the same thing, and with it the potential fall out in terms
of support of trying to help debug them I've coded up a solution for
osgViewer that can either be used directly or as a template for others
to learn from.

What I have done is to refactor osgViewer::ViewerBase::run() so that
it's frame loop now has two new capabilities:

   1) On demand (lazy) frame rendering  vs Continuous frame rendering
(the original functionality, and still the default.)
   2) Optional frame rate capping to a specified maximum frame rate
(defaults to off.)

Now item 2 isn't a required for on demand frame rendering, but it more
for coping with end user system not having vsync enabled by default.
Since I was working on this piece of code I thought I'd tackle this
item as well.  The actual ViewerBase::run() method (use by both Viewer
and CompositeViewer) now looks like:


int ViewerBase::run()
{
if (!isRealized())
{
realize();
}

const char* str = getenv(OSG_RUN_FRAME_COUNT);
int runTillFrameNumber = str==0 ? -1 : atoi(str);

while(!done() || (runTillFrameNumber=0 
getViewerFrameStamp()-getFrameNumber()runTillFrameNumber))
{
double minFrameTime = _runMaxFrameRate0.0 ? 1.0/_runMaxFrameRate : 0.0;
osg::Timer_t startFrameTick = osg::Timer::instance()-tick();
if (_runFrameScheme==ON_DEMAND)
{
if (checkNeedToDoFrame()) frame();
}
else
{
frame();
}

// work out if we need to force a sleep to hold back the frame rate
osg::Timer_t endFrameTick = osg::Timer::instance()-tick();
double frameTime =
osg::Timer::instance()-delta_s(startFrameTick, endFrameTick);
if (frameTime  minFrameTime)
OpenThreads::Thread::microSleep(100.0*(minFrameTime-frameTime));
}

return 0;
}

The code isn't final yet, but is certainly good enough for us to start
testing.  You can test it by setting the env vars:

   OSG_RUN_FRAME_SCHEME=ON_DEMAND

or go back to default

   OSG_RUN_FRAME_SCHEME=CONTINUOUS

And

   OSG_RUN_MAX_FRAME_RATE=60.0

or switch off and the default

   OSG_RUN_MAX_FRAME_RATE=0.0


You can also use the following command line options:

  osgviewer cow.osg --run-on-demand

  osgviewer cow.osg --run-continuous

  osgviewer cow.osg --run-continuous  --run-max-frame-rate 30.0


The on demand frame rendering does already support paged databases,
and I've updated various event handles to manually do a
requestRedraw() which prompts the viewer::run() to rendering a new
frame.   What I have got working yet is handling of the update visitor
doing updates. so on demand rendering just freezes things like
particle systems and animations till you move the eye point, trigger
an event.  I'll have a look at support event callbacks next.

Please note this support only affect viewer::run() it doesn't effect
apps that roll their own frame loop.

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] bug - resources aren't properly deallocated when a viewer is destroyed

2008-11-21 Thread brettwiesner

Hi,

I have a simple example that shows that if you run a viewer, tear it 
down and run it again, textures are missing. (winXP, 2.6.0). It appears 
that resources such as Textures and DisplayLists are leaking and 
corrupting runs.


The attached example simply creates a viewer and loads the cow.osg file. 
Press esc to exit the viewer which removes the cow from the scene and 
tears the viewer down. Then another viewer is created and the cow is 
loaded again. This time, the cow has no textures.


What calls are necessary to properly deallocate resources when tearing 
down the viewer so that future viewers can be created and load the next 
resources?


Thanks,
Brett

#include osg/ref_ptr
#include osgDB/ReadFile
#include osgViewer/Viewer
#include osgGA/TrackballManipulator
#include osgDB/ReadFile
#include osgDB/WriteFile

void testViewerTeardown()
{
{
osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;
osg::ref_ptrosg::Group root = new osg::Group;
viewer-setUpViewOnSingleScreen(0);
viewer-setSceneData(root.get());
viewer-setCameraManipulator(new osgGA::TrackballManipulator());
viewer-realize();
{
std::string originalFile = Cow.osg;
osg::ref_ptrosgDB::ReaderWriter::Options options = 
osgDB::Registry::instance()-getOptions(); 
osg::ref_ptrosg::Node modelNode = 
osgDB::readNodeFile(originalFile, options.get()); 
root-addChild(modelNode.get());
viewer-run();  
root-removeChildren(0,root-getNumChildren());
}
}

{ 
osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;
osg::ref_ptrosg::Group root = new osg::Group;
viewer-setUpViewOnSingleScreen(0);
viewer-setSceneData(root.get());
viewer-setCameraManipulator(new osgGA::TrackballManipulator());
viewer-realize();
{
std::string originalFile = Cow.osg;
osg::ref_ptrosgDB::ReaderWriter::Options options = 
osgDB::Registry::instance()-getOptions(); 
osg::ref_ptrosg::Node modelNode = 
osgDB::readNodeFile(originalFile, options.get()); 
root-addChild(modelNode.get());
viewer-run();  
root-removeChildren(0,root-getNumChildren());
}
}
} ___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] what kind of path should a referenced texture be written out with

2008-11-07 Thread brettwiesner

Hi,

If an IVE file is written out with the noTexturesInIVEFile option, it 
references textures using an absolute path. Is this correct?


I wondered what will happen when the application is run on a different 
machine with a different directory structure. So I changed the directory 
name where the model lives (which would make the absolute path to 
textures fail) but it loaded the textures just fine. Does OSG strip the 
path and look in the directory of the IVE file first?


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


[osg-users] Writing dds textures - they're bigger than the originals?

2008-11-06 Thread brettwiesner

Hi,

I'm writing out textures from my models as DDS. The originals are rgb's. 
This is all working however the DDS textures are 3x larger than the 
originals! It seems like the DDS writer will write out images 
differently depending on their pixel format. The osg::Image class has a 
setPixelFormat() method. I'm assuming if I can figure out a good pixel 
format to set the image to then the DDS textures will write out smaller. 
Does anyone have a recommendation?


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


[osg-users] Another case for extendable plugin loaders... Was Re: DDS textures flipped on flt files

2008-10-16 Thread brettwiesner

Hey,

Since most DDS textures are going to come in flipped (ie: directX style 
and not openGL style) I would like my application to always pass the 
dds_flip option to the DDS loader. If I could extend the DDS loader I 
could do that. Just another case for including the loaders as actual 
libs and the plugins themselves as smaller projects that just use the 
loaders api.


Thanks,
Brett

Gordon Tomlinson wrote:

This could be the way the DDS files have been generated,  a lot of DDS
creation tools by default start with 0,0 top left instead of top bottom (or
the other way round)  to the norm in vis-sim imagery, 


This has been covered before on the list and a search will most likely pop
out how you can fix this, tools supplied with things like Creator /VegaPrime
make sure the correct 0,0 is chosen, so check you DDS creation tool and
re-gen with the 0,0 origin flipped

__
Gordon Tomlinson 


[EMAIL PROTECTED]
IM: [EMAIL PROTECTED]
www.vis-sim.com www.gordontomlinson.com 
__


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
brettwiesner
Sent: Wednesday, October 15, 2008 10:38 AM
To: OpenSceneGraph Users
Subject: [osg-users] DDS textures flipped on flt files

Hi,

I have a sample terrain that shows that DDS textures are incorrect on flt
files. If you load up the flt file in osgviewer you should see a framed
terrain. However, the textures are flipped (it seems only vertically).

Thanks,
Brett

___
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] DDS textures flipped on flt files

2008-10-15 Thread brettwiesner

Hi,

Yes, the DDS textures were generated with 0,0 being top left. This is 
because DDS (aka microsoft and directX) has its origin in the upper left 
corner, while OpenGL  has its origin in the lower left corner. While I 
can flip the textures with an option, I wonder if the loader should do 
this automatically. BMP's have the same problem and they are loaded 
correctly (ie, the flipping is done automatically).


Thanks,
Brett


Gordon Tomlinson wrote:

This could be the way the DDS files have been generated,  a lot of DDS
creation tools by default start with 0,0 top left instead of top bottom (or
the other way round)  to the norm in vis-sim imagery, 


This has been covered before on the list and a search will most likely pop
out how you can fix this, tools supplied with things like Creator /VegaPrime
make sure the correct 0,0 is chosen, so check you DDS creation tool and
re-gen with the 0,0 origin flipped

__
Gordon Tomlinson 


[EMAIL PROTECTED]
IM: [EMAIL PROTECTED]
www.vis-sim.com www.gordontomlinson.com 
__


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
brettwiesner
Sent: Wednesday, October 15, 2008 10:38 AM
To: OpenSceneGraph Users
Subject: [osg-users] DDS textures flipped on flt files

Hi,

I have a sample terrain that shows that DDS textures are incorrect on flt
files. If you load up the flt file in osgviewer you should see a framed
terrain. However, the textures are flipped (it seems only vertically).

Thanks,
Brett

___
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] Inlined textures and .ive files

2008-10-06 Thread brettwiesner

Hi,

When writing out .ive files, textures are inlined by default. If a model 
references another model via a proxy node and the other model is written 
out as an .ive file then it's texture is inlined. Is that inlined 
texture loaded into memory multiple times if the model is referenced 
multiple times?


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


Re: [osg-users] How do I Subclass a file loader?

2008-10-02 Thread brettwiesner

Robert,

OK, I'm reading up on basic_streambufchar now. In the meantime, maybe 
you can help me understand how I can use a derived streambuf with the 
existing IVE loader. Aren't I going to run into the same problem? When 
the IVE loader comes across a proxy node, it will write out the node 
using the IVE loader and it won't matter that I originally made the call 
to writeNode() with my specialized ostream. It's going to create a file 
stream and write out the proxy node and there's no way for me to change 
that.


Thanks,
Brett

Robert Osfield wrote:

Hi Brett,

You need to read up about deriving your own custom std::streambuf,
once you understand this part then adapting existing plugins to use
your encrypted stream will be straightforward.  You could even be lazy
a use a stringstream like the curl plugin does.  Please look into this
stuff - this will answer your need, and there is certainly no need to
subclass from plugins, C++ std::stream streambuf extensibility exist
to help solve problem like yours, and the OSG takes advantage of this.

Robert.

On Wed, Oct 1, 2008 at 9:27 PM, brettwiesner [EMAIL PROTECTED] wrote:
  

Hey Robert,

I'm confused about what you mean here. Many plugins have read/ write methods
that take istreams/ ostreams (ReaderWriterIVE being one of them). However,
since I can't subclass them I can't attach to the stream. For example, in
ReaderWriterIVE::writeNode() a std::ofstream is created but there's no way
for me to attach it to a stream buffer.

It seems like the osga plugin would have the same problem. The doread()/
dowrite() methods call up to whatever ReaderWriter was passed in and I can't
subclass those.

Thanks,
Brett

Robert Osfield wrote:


Hi Brett,

A number of the plugins support reading a writing from istream/ostream
which means you can implement your std::streambuffer and attach to the
stream and then pass this to the plugin.  This technique allows you to
do items like compression/decompression/encription/decription.  Have a
look at the osga and curl plugins as they provide examples of using
streams this way.

Robert.

On Wed, Oct 1, 2008 at 5:02 PM, brettwiesner [EMAIL PROTECTED]
wrote:

  

Hi,

I've got a requirement to ship certain 3rd party model data only in an
encrypted format. So I wrote my own loader that does the encryption/
decryption but uses the IVE loader for everything. This works except for
files that reference other files. The master file is encrypted, but the
referenced files are saved out as .ive's.

Ideally all I would have to do is subclass ReaderWriterIVE and override
the
following stream methods:

 virtual osgDB::ReaderWriter::ReadResult readObject(std::istream fin,
   const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::ReadResult readImage(std::istream fin,
   const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::ReadResult readNode(std::istream fin,
   const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::WriteResult writeObject(const osg::Object
object,
   std::ostream fout, const osgDB::ReaderWriter::Options* options)
const;

 virtual osgDB::ReaderWriter::WriteResult writeImage(const osg::Image
image,
   std::ostream fout, const osgDB::ReaderWriter::Options* options)
const;

 virtual osgDB::ReaderWriter::WriteResult writeNode(const osg::Node
node,
   std::ostream fout, const osgDB::ReaderWriter::Options* options)
const;

For writing I could get the raw data from the ive loader encrypt it and
write it out. For reading I could decrypt the data, then pass the
unencrypted data up to the ive loader for use.

There is one fatal flaw... I can't subclass the ReaderWriterIVE plugin.
:(

1) Has anyone besides me ever wanted to derive from a file loader? Would
it
make sense to keep the logic in a lib with headers, then have another
library that is just the plugin?

2) Is there some other mechanism in OSG that will let me do this?

Thanks,
Brett
___
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
  


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


Re: [osg-users] How do I Subclass a file loader?

2008-10-02 Thread brettwiesner

Robert,

Maybe some code will help Let's say I write my own ReaderWriter that 
reads and writes encrypted ive files or eive files.


class ReaderWriterEive : public osgDB::ReaderWriter
{

public

  virtual bool acceptsExtension(const std::string extension) const
  {
//  Accepts eive as an extension.
  }

  // This takes in a .eive file which is an encrypted ive file.
  virtual osgDB::ReaderWriter::ReadResult readNode(const std::string 
file,

 const osgDB::ReaderWriter::Options* options) const
  {
 // basic file checking, etc.

 std::ifstream istream(file.c_str(), std::ios::in | std::ios::binary);
 return readNode(istream, options);
  }

  virtual osgDB::ReaderWriter::ReadResult readNode(std::istream 
encryptedInput,

 const osgDB::ReaderWriter::Options* options) const
  {
 ReadResult rr;
 //
 // 1. decrypt stream.
 // 2. call the ive readerWriter's readNode() method on the 
decrypted stream.

 //

 // Create an input stream to store the decrypted data in so the 
reader can read it.
 std::istringstream decryptedInputStream(std::ios::in | 
std::ios::binary);


 // Decrypted the encryptedInput into the decryptedInputStream.
 if(decrypt(encryptedInput, decryptedInputStream))
 {
 // Find the correct reader writer.
 osgDB::ReaderWriter* readerWriter =
   
osgDB::Registry::instance()-getReaderWriterForExtension(.ive);


 if(readerWriter)
 {
// Use the reader to read the decrypted data.
rr = readerWriter-readNode(decryptedInputStream, 
options);  
 }

 }
 return rr;
  }

  virtual osgDB::ReaderWriter::WriteResult writeNode(const osg::Node node,
 const std::string fileName, const osgDB::ReaderWriter::Options* 
options) const

  {
 // basic file checking...

 std::ofstream fout(fileName.c_str(), std::ios::out | 
std::ios::binary);

 if(!fout)
 {
return osgDB::ReaderWriter::WriteResult::ERROR_IN_WRITING_FILE;
 }

 osgDB::ReaderWriter::WriteResult result = writeNode(node, fout, 
local_opt.get());

 fout.close();
 return result;
  }


  virtual osgDB::ReaderWriter::WriteResult writeNode(const osg::Node node,
 std::ostream fout, const osgDB::ReaderWriter::Options* options) const
  {
WriteResult wr;
//
// 1. call the ive readerWriter's writeNode() method on the stream.
// 2. encrypt stream.
//
  
// Find the correct reader writer.

osgDB::ReaderWriter* readerWriter =
   
osgDB::Registry::instance()-getReaderWriterForExtension(.ive);
 
if(readerWriter)

{
 // Create an output stream to store the raw ive data.
 std::ostringstream rawIveData(std::ios::out |std::ios::binary);

 // Use the reader to write the decrypted data.
 // This is where the problem is. The ive's reader writer will 
get called
 // for every proxy node. My reader writer will not get called 
and therefore all

 // referenced files will be written out as unencrypted ive files.
 wr = readerWriter-writeNode(node, rawIveData, options); 
 
 // Encrypt the decrypted data into the file output.

 encrypt(rawIveData, fileOutputStream);
 }

 return wr;
  }

The problem is in the writeNode() method that writes out to an ofstream. 
When I give it a stream to write the data to, it does so, but it also 
writes out all referenced files on its own, as regular .ive's. Perhaps 
my design is flawed and there is a better way but I'm not seeing it in 
the curl or osga loader.


Thanks,
Brett


Robert Osfield wrote:

HI Brett,

Please follow the suggestions already made.  The osga plugin already
implementents a custom std::streambuf, and the curl plugin uses a
stingstream to adapt an external stream into something that the other
OSG plugins can use.

Robert.

On Thu, Oct 2, 2008 at 3:47 PM, brettwiesner [EMAIL PROTECTED] wrote:
  

Robert,

OK, I'm reading up on basic_streambufchar now. In the meantime, maybe you
can help me understand how I can use a derived streambuf with the existing
IVE loader. Aren't I going to run into the same problem? When the IVE loader
comes across a proxy node, it will write out the node using the IVE loader
and it won't matter that I originally made the call to writeNode() with my
specialized ostream. It's going to create a file stream and write out the
proxy node and there's no way for me to change that.

Thanks,
Brett

Robert Osfield wrote:


Hi Brett,

You need to read up about deriving your own custom std::streambuf,
once you understand this part then adapting existing plugins to use
your encrypted stream will be straightforward.  You could even be lazy
a use a stringstream like the curl plugin does.  Please look into this
stuff - this will answer your need, and there is certainly no need to
subclass from plugins, C++ std::stream streambuf extensibility exist
to help solve problem like yours, and the OSG takes advantage

Re: [osg-users] How do I Subclass a file loader?

2008-10-02 Thread brettwiesner

Hi,

I'm going to try one more thing... In my readerWriter, I can unregister 
the real IVE loader, and register my encrypted ive loader. This way, 
my loader gets called when a .ive is written out/ read in. I'll 
actually call the real IVE loader for all read and writes, but the 
recursive proxy node writer will ask the registry for the readerWriter 
associated with an .ive file and it will get give it my EIVE loader. 
When it's all done, I'll re-register the IVE loader with the .ive 
extension.


I'll let you know what happens...

Thanks,
Brett



Jean-Sébastien Guay wrote:

Hi Brett,

As expected, the visitor goes and changes the names of all the 
referenced files. Then the top level file is written out. The proxy 
nodes try to write themselves out but since the files they reference 
(referencedFile.eive) doesn't exist, nothing is written out.


I don't quite know what options you have then. In the case of 
ProxyNodes and PagedLOD nodes, you might have to force reading of the 
whole file before you can write it out again anyways... But that may 
exceed the memory in your system (the reason why you use those nodes 
in the first place, most of the time...).


You could catch that error, read the file yourself (original ive 
extension), write it out to eive, and then re-write the parent file. 
(recursively)  That's so ugly I'm almost ashamed I thought of it...


I still don't get why Robert tells you it should work fine, and you 
say it doesn't. Sure, there are any number of things that may go 
wrong, but it should be easier than that.


Sorry I can't help more,

J-S


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


[osg-users] How do I Subclass a file loader?

2008-10-01 Thread brettwiesner

Hi,

I've got a requirement to ship certain 3rd party model data only in an 
encrypted format. So I wrote my own loader that does the encryption/ 
decryption but uses the IVE loader for everything. This works except for 
files that reference other files. The master file is encrypted, but the 
referenced files are saved out as .ive's.


Ideally all I would have to do is subclass ReaderWriterIVE and override 
the following stream methods:


 virtual osgDB::ReaderWriter::ReadResult readObject(std::istream fin,
 const osgDB::ReaderWriter::Options* options) const;

  virtual osgDB::ReaderWriter::ReadResult readImage(std::istream fin,
 const osgDB::ReaderWriter::Options* options) const;

  virtual osgDB::ReaderWriter::ReadResult readNode(std::istream fin,
 const osgDB::ReaderWriter::Options* options) const;

  virtual osgDB::ReaderWriter::WriteResult writeObject(const 
osg::Object object,
 std::ostream fout, const osgDB::ReaderWriter::Options* options) 
const;


  virtual osgDB::ReaderWriter::WriteResult writeImage(const osg::Image 
image,
 std::ostream fout, const osgDB::ReaderWriter::Options* options) 
const;


  virtual osgDB::ReaderWriter::WriteResult writeNode(const osg::Node node,
 std::ostream fout, const osgDB::ReaderWriter::Options* options) 
const;


For writing I could get the raw data from the ive loader encrypt it and 
write it out. For reading I could decrypt the data, then pass the 
unencrypted data up to the ive loader for use.


There is one fatal flaw... I can't subclass the ReaderWriterIVE plugin. :(

1) Has anyone besides me ever wanted to derive from a file loader? Would 
it make sense to keep the logic in a lib with headers, then have another 
library that is just the plugin?


2) Is there some other mechanism in OSG that will let me do this?

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


Re: [osg-users] How do I Subclass a file loader?

2008-10-01 Thread brettwiesner

Bryan,

Thanks for the reply. See inline...

You could implement your own loader with a different file extension
(say, .enc) that does the en/decryption and then calls the IVE loader
to load the resulting data. The curl loader does something like this.
  


This is what I did originally. There was a problem with referenced 
files; those wouldn't get encrypted/ decrypted. The IVE loader would 
just process them as .ive's.



Or you could use a osgDB::Registry::Read/WriteFileCallback to de/encrypt
the data before it gets read/sent from/to disk.

  


That is interesting. I didn't know about those before. I think they will 
have the same problem though. If I write a callback that does something 
special when it's suppose to write out an encrypted file, and it uses 
the IVE loader to get the data to encrypt, that process will still cause 
the IVE loader to write out referenced files as .ive's.


This would be pretty easy if I could derive from ReaderWriterIVE.

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


Re: [osg-users] How do I Subclass a file loader?

2008-10-01 Thread brettwiesner

Hey Robert,

I'm confused about what you mean here. Many plugins have read/ write 
methods that take istreams/ ostreams (ReaderWriterIVE being one of 
them). However, since I can't subclass them I can't attach to the 
stream. For example, in ReaderWriterIVE::writeNode() a std::ofstream is 
created but there's no way for me to attach it to a stream buffer.


It seems like the osga plugin would have the same problem. The doread()/ 
dowrite() methods call up to whatever ReaderWriter was passed in and I 
can't subclass those.


Thanks,
Brett

Robert Osfield wrote:

Hi Brett,

A number of the plugins support reading a writing from istream/ostream
which means you can implement your std::streambuffer and attach to the
stream and then pass this to the plugin.  This technique allows you to
do items like compression/decompression/encription/decription.  Have a
look at the osga and curl plugins as they provide examples of using
streams this way.

Robert.

On Wed, Oct 1, 2008 at 5:02 PM, brettwiesner [EMAIL PROTECTED] wrote:
  

Hi,

I've got a requirement to ship certain 3rd party model data only in an
encrypted format. So I wrote my own loader that does the encryption/
decryption but uses the IVE loader for everything. This works except for
files that reference other files. The master file is encrypted, but the
referenced files are saved out as .ive's.

Ideally all I would have to do is subclass ReaderWriterIVE and override the
following stream methods:

 virtual osgDB::ReaderWriter::ReadResult readObject(std::istream fin,
const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::ReadResult readImage(std::istream fin,
const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::ReadResult readNode(std::istream fin,
const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::WriteResult writeObject(const osg::Object
object,
std::ostream fout, const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::WriteResult writeImage(const osg::Image
image,
std::ostream fout, const osgDB::ReaderWriter::Options* options) const;

 virtual osgDB::ReaderWriter::WriteResult writeNode(const osg::Node node,
std::ostream fout, const osgDB::ReaderWriter::Options* options) const;

For writing I could get the raw data from the ive loader encrypt it and
write it out. For reading I could decrypt the data, then pass the
unencrypted data up to the ive loader for use.

There is one fatal flaw... I can't subclass the ReaderWriterIVE plugin. :(

1) Has anyone besides me ever wanted to derive from a file loader? Would it
make sense to keep the logic in a lib with headers, then have another
library that is just the plugin?

2) Is there some other mechanism in OSG that will let me do this?

Thanks,
Brett
___
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] Open/Close the window on win32

2008-09-11 Thread brettwiesner

Hi,

Recycling context id's is something that seems fixed in 2.6.0. I'm not 
sure if you can keep a graphics context around without a window however 
you can keep the scene graph around. Just hold onto a ref ptr to the 
root node of your scene graph. You should be able to open a new window 
and create a new viewer and pass in the root node of the SG you've kept 
around.


(I'm not sure if video's/ animations will still be played though. Try it 
out.)


Thanks,
Brett

christophe loustaunau wrote:

Hello,

This is something I'd like to make available as well. I have tried to
implement a function that restores the previous graphic context one
the window as been closed. Nothing has been successful. Is such a
thing possible with osg?

Thanks


On Tue, Sep 9, 2008 at 3:00 PM, Lucas Lallement 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Hey all,

My software receives orders such as play, pause but also close and
open window.
I was wondering what was the best way to close (or hide) the osgViewer
window on win32 to later on reopen it without having lost what is
going on (video being played on a node).
Everything I have tried so far makes me loose the context when I
reopen the window.

I am using osg 2.4.0 on Windows 2000 with a Nvidia GeForce 7800GS

Regards,

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




--
Christophe Loustaunau.


___
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] Update callbacks occur in between calls to glBegin and glEnd?

2008-08-21 Thread brettwiesner

Hi,

I was wondering if update callbacks are suppose to occur in between 
calls to glBegin and glEnd? I think this test code demonstrates that 
they do.


I'm using a glGet command (in this case glGetIntegerv) and checking for 
it's error code. From the open GL docs:


GL_INVALID_OPERATION is generated if glGet is executed between the 
execution of glBegin and the corresponding execution of glEnd.


I'm making that call inside the update callback and getting that error, 
suggesting that the update callback occurs somewhere in between a 
glBegin and glEnd. Is this correct?


Thanks,
Brett

class TestUpdateCallback : public osg::NodeCallback
  {

  public:

 void operator()(osg::Node* node, osg::NodeVisitor* nv)
 { 
// Clear any previous error.
GLenum eError = glGetError();  


// Make the call that will generate a new error.
int maxUnits;
glGetIntegerv(GL_MAX_TEXTURE_UNITS,maxUnits);

// Check the error
eError = glGetError(); 
if(eError == GL_INVALID_OPERATION)

{
   std::cout  TestUpdateCallback: This update callback 
occurs in between glBegin and glEnd.  std::endl;

}

// Continue traverse.
traverse(node,nv);
 }
  };

  main()
  {
 std::string modelPath = testDataDir();
 modelPath += cow.osg;

 osg::ref_ptrosg::Node modelNode = osgDB::readNodeFile(modelPath); 
 modelNode-setUpdateCallback(new TestUpdateCallback);


 osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;
 viewer-setUpViewOnSingleScreen(0);
 viewer-setSceneData(modelNode.get());
 viewer-setCameraManipulator(new osgGA::TrackballManipulator());
 viewer-run();
  }
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with recycled context id's and OPTIMIZE_TEXTURE_SETTINGS

2008-08-21 Thread brettwiesner

Hi Robert,

I finally got around to getting the 2.6.0 build and tested it out again. 
Unfortunatly, the  OPTIMIZE_TEXTURE_SETTINGS

flag still causes problems.

As stated below, the problem is if you optimize your scene graph using 
the OPTIMIZE_TEXTURE_SETTINGS setting, then recycle the context id, 
textures are missing.


Thanks,
Brett

Robert Osfield wrote:

Hi Brett,

We've done work since 2.4.0 to address this issue, could you please
try 2.5.5 or the svn/trunk.

Cheers,
Robert.

On Thu, Jul 17, 2008 at 9:31 PM, Brett Wiesner [EMAIL PROTECTED] wrote:
  

Hi,

Problem:
Using OSG 2.4.0 I have built an app that dynamically creates composite
viewers that have one of more views. The scene graph is kept around as a ref
pointer during the course of multiple viewers. When I delete a composite
viewer and create another one and then use the original root node of the
scene graph, textures are gone (ie, everythings white).

I've tracked the problem down to this. If you optimize your scene graph
using the OPTIMIZE_TEXTURE_SETTINGS setting, then recycle the context id,
textures are missing.

I'm honestly not sure what the optimizer option OPTIMIZE_TEXTURE_SETTINGS
does but I can reproduce the bug.

I've included sample code below to reproduce the bug.

Thanks,
Brett


// This method reads in a flt file and writes it out optimized using the
troublesome flag.
 writeOutModelAsIveOptimized()
 {
std::string modelPath = testDataDir();
modelPath += testTree\\Test_tree.flt;

std::string modelPathOut = testDataDir();
modelPathOut += testTree\\Test_tree_optimized.ive;

// create a scene graph (and keep it around).
osg::ref_ptrosg::Node modelNode = osgDB::readNodeFile(modelPath);
osgUtil::Optimizer op;

op.optimize(modelNode.get(),osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS);

osgDB::writeNodeFile(*modelNode.get(), modelPathOut);
 }

// This method reads in a flt file and writes it out unoptimized. Please
substitute any flt file you have.
 writeOutModelAsIve()
 {
std::string modelPath = testDataDir();
modelPath += testTree\\Test_tree.flt;

std::string modelPathOut = testDataDir();
modelPathOut += testTree\\Test_tree_unoptimized.ive;

// create a scene graph (and keep it around).
osg::ref_ptrosg::Node modelNode = osgDB::readNodeFile(modelPath);
osgDB::writeNodeFile(*modelNode.get(), modelPathOut);
 }


// This method creates a scene graph and keeps it around after the
destruction of a viewer.
// Then it creates a viewer and loads the model. You try this with both the
unoptimized ive and the
// optimized one. It runs the viewer waits for you to look at the model and
then hit esc to quit.
// Then it destroys the viewer, and creates another one using the same scene
graph.
// You'll notice that the scene no longer has textures.
 TEST(test_osgKeepSceneGraphAround)
 {
std::string modelPath = testDataDir();
modelPath += testTree\\Test_tree_optimized.ive;

// create a scene graph (and keep it around).
osg::ref_ptrosg::Node modelNode = osgDB::readNodeFile(modelPath);

// create viewer1 and set the scene graph data.
osgViewer::Viewer* viewer1 = new osgViewer::Viewer;
viewer1-setUpViewOnSingleScreen(0);
viewer1-setSceneData(modelNode.get());
viewer1-setCameraManipulator(new osgGA::TrackballManipulator());

// render
viewer1-realize();
while(!viewer1-done())
{
   viewer1-frame();
}

// delete viewer1.
delete viewer1;
viewer1 = 0;

// create viewer2 and set the scene graph data.
osgViewer::Viewer* viewer2 = new osgViewer::Viewer;
viewer2-setUpViewOnSingleScreen(0);
viewer2-setSceneData(modelNode.get());
viewer2-setCameraManipulator(new osgGA::TrackballManipulator());

// render
viewer2-realize();
while(!viewer2-done())
{
   viewer2-frame();
}

// delete viewer2.
delete viewer2;
viewer2 = 0;
}
___
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] Update callbacks occur in between calls to glBegin andglEnd?

2008-08-21 Thread brettwiesner
OK, that makes sense. The error is saying it's invalid to call glGetInt 
in between a glbegin and glend. I took this for face value and thought 
it was weird because I shouldn't be inside glbegin and glend in the 
update traversal. But what the error means is really, the graphics 
context isn't current so you can't make these calls. That makes sense. 
Too bad the error message isn't very helpful.


Thanks guys.

Tomlinson, Gordon wrote:

Hi

I think the GL error is because your doing a GL call in the update
process/thread and not the draw process/threads (You need a valid GL
context which is typically owned by the draw process/threads)


Gordon

__
Gordon Tomlinson
Email  : gtomlinson @ overwatch.textron.com


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
brettwiesner
Sent: Thursday, August 21, 2008 10:01 AM
To: OpenSceneGraph Users
Cc: [EMAIL PROTECTED]
Subject: [osg-users] Update callbacks occur in between calls to glBegin
andglEnd?

Hi,

I was wondering if update callbacks are suppose to occur in between
calls to glBegin and glEnd? I think this test code demonstrates that
they do.

I'm using a glGet command (in this case glGetIntegerv) and checking for
it's error code. From the open GL docs:

GL_INVALID_OPERATION is generated if glGet is executed between the
execution of glBegin and the corresponding execution of glEnd.

I'm making that call inside the update callback and getting that error,
suggesting that the update callback occurs somewhere in between a
glBegin and glEnd. Is this correct?

Thanks,
Brett

class TestUpdateCallback : public osg::NodeCallback
   {

   public:

  void operator()(osg::Node* node, osg::NodeVisitor* nv)
  { 
 // Clear any previous error.
 GLenum eError = glGetError();  


 // Make the call that will generate a new error.
 int maxUnits;
 glGetIntegerv(GL_MAX_TEXTURE_UNITS,maxUnits);

 // Check the error
 eError = glGetError(); 
 if(eError == GL_INVALID_OPERATION)

 {
std::cout  TestUpdateCallback: This update callback
occurs in between glBegin and glEnd.  std::endl;
 }

 // Continue traverse.
 traverse(node,nv);
  }
   };

   main()
   {
  std::string modelPath = testDataDir();
  modelPath += cow.osg;

  osg::ref_ptrosg::Node modelNode =
osgDB::readNodeFile(modelPath); 
  modelNode-setUpdateCallback(new TestUpdateCallback);


  osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;
  viewer-setUpViewOnSingleScreen(0);
  viewer-setSceneData(modelNode.get());
  viewer-setCameraManipulator(new osgGA::TrackballManipulator());
  viewer-run();
   }
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
___
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] Fog and desired usage

2008-08-18 Thread brettwiesner

Hi,

I just had a couple of questions about the desired usage of the fog 
state attribute.


1) What does it mean to have different fog states on different branches 
of the scene graph? Would this have any effect?
2) Is the desired usage to set the fog attribute on the root node?   


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