Re: [osg-users] How do remove a node's built in offset?

2013-04-24 Thread Joshua Cook
No dice.  I just end up with a second matrix offset to offset the first matrix 
offset.  This works fine for a simple viewer, say osgviewer, but when loaded by 
our software it still doesn't show up.  I'm wondering if the way OSG performs 
its matrix multiplication has something to do with it.  Not that I think it is 
wrong just that it may not be what I think it is so what I'm thinking is making 
the thing think it is in a different spot.  Oh well, time to see what else I 
can do with this.

Thanks for the suggestion anyhow.

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





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


Re: [osg-users] How do remove a node's built in offset?

2013-04-24 Thread Joshua Cook
Well, here are the objects in question.  My cube and a crossing arm.  If you 
display them both using OSGViewer you end up with the crossing arm inside a 
black box (I didn't set the flag to keep the texture from scaling).  I'm not 
sure how the program I'm working with translates and rotates the objects but 
the crossing arm ends up in just the right place but the box is nowhere to be 
seen.  They should occupy the same position.  Well, in theory that is.  Further 
help is, as always, greatly appreciated.  :)

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




Attachments: 
http://forum.openscenegraph.org//files/test_624.osg
http://forum.openscenegraph.org//files/doc_xform2_165.osg


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


Re: [osg-users] How do remove a node's built in offset?

2013-04-24 Thread Joshua Cook
As noted from the last reply from robertosfield:

I may not be asking the correct question.  Unfortunately, if that is the case, 
I don't know what the right question is.

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





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


Re: [osg-users] How do remove a node's built in offset?

2013-04-24 Thread Joshua Cook
So it turns out that I have been asking the wrong question.

It is true that I'm new to scene graphs and all the nuances that go along with 
them.  However, I do understand enough about the to know that if you have two 
objects whose local coordinate center is 0,0,0 then they should be 
interchangable in the scenegraph; scale and rotation shouldn't make a 
difference.

To test this I did a variety of things ranging from using the infamous cow.osg 
(as an IVE of course) in place of the rail crossings to combining a multitude 
of IVE files into one and makeing sure I saw a jumble of shapes where I thought 
I should see them.

This all worked perfectly except for the model I converted from a KML file.  No 
matter what I did to the model the box never appeared.  I tried adding other 
modesl with it; they all appeared but the box did not.  I tried turning off all 
culling; no change.  I tried different scales; no change.  I tried adding a few 
lines to represent the coordinate axises (axies, asciis?); I saw the lines but 
not the box.  I set up a viewer that had the box revolve around each of the 
axis while rotating around it's local axies at the same time; this looked 
exactly as expected.

With all culling off, with other viewers displaying the model as expected, I'm 
not sure what could possibly cause this.  I think my best option at the time is 
to hand this over to my boss, explain the situation, and wish whoever gets 
stuck with this the best of all possible luck.

Thanks for all of your help, Robert.

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





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


[osg-users] How do remove a node's built in offset?

2013-04-22 Thread Joshua Cook
Ok, so I have a set of IVE files and each one of them has some sort built in 
offset.  For example: a cube with a center of X, Y, Z.  I really would love to 
be able to save these off as an IVE with a center of 0, 0, 0.

My Google-Fu is weak today, master, and I humbly request assistance with this 
problem.

Thanks,
soulsabr

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





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


Re: [osg-users] How do remove a node's built in offset?

2013-04-22 Thread Joshua Cook

Paul Martz wrote:
 You could translate them with the .trans pseudoloader:osgconv 
 infile.ive.(-x,-y,-z).trans outfile.ive
 
 
 I'm not sure that's the right syntax for the .trans pseudoloader, but you can 
 check the source code in src/osgPlugins/trans.
 
 
 
 On Mon, Apr 22, 2013 at 12:00 PM, Joshua Cook  () wrote:
 
  Ok, so I have a set of IVE files and each one of them has some sort built 
  in offset.  For example: a cube with a center of X, Y, Z.  I really would 
  love to be able to save these off as an IVE with a center of 0, 0, 0.
  
  My Google-Fu is weak today, master, and I humbly request assistance with 
  this problem.
  
  Thanks,
  soulsabr
  
  --
  Read this topic online here:
  http://forum.openscenegraph.org/viewtopic.php?p=53725#53725 
  (http://forum.openscenegraph.org/viewtopic.php?p=53725#53725)
  
  
  
  
  
  ___
  osg-users mailing list
   ()
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
  (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
  
 
 
 
 
 -- 
 Paul Martz
 Skew Matrix Software LLC
 
  --
 Post generated by Mail2Forum


I have never heard of this thing.  I shall check it out post haste.  Thanks for 
your suggestions.  I'll let you know if it works.

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





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


Re: [osg-users] [RESOLVED] KML with texture fails to save as IVE

2013-03-26 Thread Joshua Cook
So, turns out I was doing everything correctly and OSG and OSGEarth were 
working as expected.  OSGEarth actually adds a shader to the node after it is 
read by the DAE plugin which osgDB::writeNodeFile doesn't like.  The 
recomendation was to parse through the KML/KMZ file, get the name and location 
of the DAE file, and then let the OSG DAE plugin do the rest.  Now to learn how 
to work with zipped files.

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





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


[osg-users] KML with texture fails to save as IVE

2013-03-25 Thread Joshua Cook
I'm attempting to load a KML/KMV file and convert it to IVE.  Well, the DAE 
plugin works great and the KML plugin for osgEarth works great, too.  Further, 
when I use osgViewere.run() after setting my new node in the scene I can see 
the node in all of its 3D glory.  In other words, from load to display 
everything looks great and I have no issues.

When I try to save the node I get this error on the console:
image C:\Workspace\OpenSceneGraph\build\bin\models\untitled\texture.jpg' 256
 128
Error writing IVE image: StateSet::write(): Unknown StateAttribute: 
VirtualProgram

The file writes out to an IVE file as an uncompressed IVE stream or so the 
output claims.  When I try to read in the file I just saved I get an error 
saying that osg couldn't find a plugin to read the IVE file.  Well, garbage in 
garbage out.

What is annoying is that if I have a KML without a texture there is no issues.  
Even with the issue I can display the 3d object if I put it in a viewer.  Also, 
if I try to load and save any other type of file there is no issue.  I can go 
from IVE to OSG to 3ds etc without a hitch.  Any ideas would be appreciated.

Please note I assume this is an OSG question since I'm having an issue with the 
write node function.  If you guys believe this is better handled on the 
osgEarth forum let me know.

Thanks,
soulsabr


Code:

bool Converter::initialize()
{
  // Assume failure; only set true if everything succeeds
  bool succeeded = false;

  // Read in the .earth file.
  _earthModel = osgDB::readNodeFile(nodata.earth);

  // Check for a successful read
  if(_earthModel != NULL)
  {
// Create the mapnode needed for reading KML/KMZ files
_mapNode = osgEarth::MapNode::findMapNode(_earthModel);

if(_mapNode != NULL)
{
  // Initialization succeeded
  succeeded = true;
}
  }

  return succeeded;
}

bool Converter::convert(std::string aFileName)
{
  //osgEarth::URI uri(aFileName);
  osgEarth::URI uri(C:\\Workspace\\OpenSceneGraph\\build\\bin\\doc.kml);

  std::string ext = osgDB::getLowerCaseFileExtension(uri.full());
  bool val = (ext == kmz);

  osg::Node* node = 
osgEarth::Drivers::KML::load(uri,
 _mapNode,
 osgEarth::Drivers::KMLOptions());


if(node != NULL)
  {
osgDB::writeNodeFile(*node, test.ive);
node = 
osgDB::readNodeFile(C:\\Workspace\\OpenSceneGraph\\build\\bin\\test.ive);
  }

  osgViewer::Viewer* viewer = new osgViewer::Viewer();
  viewer-setSceneData(node);
  viewer-run();

  return true;
}





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





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


Re: [osg-users] KML with texture fails to save as IVE

2013-03-25 Thread Joshua Cook

Aurelien wrote:
 Hi,
 This is normal, osgEarth insert custom VirtualProgram state attribute and 
 they are not serializable.
 
 If you want to remove this error, you'll have to use a osg::Visitor to remove 
 all osgEarth::VirtualProgram attributes, but I don't think this error is a 
 real problem and you probably can just ignore it.
 
 But the point is that's a little weird to save a KML file as an IVE file : 
 KML files are XML files which declares some data (POI, image overlay...) and 
 reference external models. You can probably just pick up the external model 
 file, open your KML with a text editor and have a look at it to see where 
 your model file is declared.
 
 Handling of KML files in osg are based on a several osgEarth specific 
 classes, so you will get better answer on their forum I guess.
 
 Cheers,
 Aurelien


I'm just a grunt, I do what they tell me to do.

OT We were thinking that the VirtualProgram had something to do with it.  Guess 
this confirms it.

Well, the issue is the customer wants the model out of the KML/KMZ file and in 
IVE format and that is what I have to give them.  I know about all of the other 
data that the KML files have but they're not really interested in any of that.

Well, I'm off to the osgEarth forum to ask my question.  Thanks for the reply I 
appreciate it.  I'll drop back in to post the result and switch to resolved if 
they can help me.  If not then I'll try your advice to use a visitor to strip 
out the VirtualProgram data.

Thanks again,
soulsabr

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





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


[osg-users] setUpViewInWindow fails to create graphics context if laptop not docked

2013-02-23 Thread Joshua Cook
I'm working on a 3D simulation project that runs like a dream on my boss's 
desktop and on my laptop when it is docked and has my two work monitors 
connected.  However, I decided to work from home today so tried to run the 
project on the laptop without the dock.  Before I left work yesterday this 
program was running great.  I get up today and try to run it and it crashes due 
to a lack of graphics context.  The error message I get is No matching pixel 
format found based on traits specified.

Please note that I did not recompile the program at all nor did I make any 
changes to anything when I tried to run the program from home.

To further add to my confusion the included osgviewer runs perfectly.

I thought I'd put this out here while I set up to run with more debug output 
and sifted through that.  I'll add that output as soon as I have it.  Thanks, 
all!

soulsabr

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





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


Re: [osg-users] setUpViewInWindow fails to create graphics context if laptop not docked

2013-02-23 Thread Joshua Cook
The call to setNumMultiSamples is the culprit.  When I was working yesterday 
the multisample number was set at 16 and worked fine.  Today, after I found I 
was having an issue, I started moving the call to realize and run the viewer 
down the setup routine to see what might be causing the failure.  Turns out 
that the laptop doesn't like a sample of 16 when not docked though 2, 4, and 8 
work just fine.

It seems odd to me that simply removing two monitors with the same resolution 
as the laptop's screen would cause an issue.  It also seems odd that 
multisampling doesn't work for the higher number (but I don't know anything 
about how it is handled) but works for a lower number.  I would have guessed 
that a higher number would only cause the program to run slower.

Anyhow, I think I can mark this solved but thought somebody might be interested 
in the cause.  Thanks.

soulsabr

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





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


[osg-users] Rotation Translation problem

2012-06-05 Thread Joshua Cook
Greetings

I have a custom camera object that I use to store position and direction in a 
vec3 and quat and a matrixd which should contain both.  Due to the nature of 
the software I have to interact with using the osg camera is not an option.

So, once I have the position and rotation I am supposed to use these values to 
create the matrixd and then feed that  into an osg camera.  If I simply use 
matrixd::setTrans the osg camera ends up in the right place.  If I use 
matrixd::setRotate the osg camera ends up facing the correct direction.  If I 
use both, in either order, the camera ends up in the wrong place.  Like a 90 
degree rotation about an axis.

I'm operating under the assumption that the set function for position is the 
same as moving an object to world coordinates x,y,z regardless of orientation 
and set rotation is the same as rotating the object around it's local origin.  
Please correct me if I'm wrong.

So, any ideas as to what I may be doing wrong?  Thanks for any help.

I also apologize if this is in the wrong thread but I thought this would be the 
place seeing as how I need advice as to the functions to use.

soulsabr

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





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


Re: [osg-users] osgViewer::GraphicsWindowEmbeded causing OpenGL error

2011-11-16 Thread Joshua Cook
Robert,

it seems to work ok now.  The view on each of the cave walls is good and I'm 
even getting stereo now.  I'm still getting an OpenGL error but I can't see 
what problems it is causing; lighting, textures, perspective, placement, and 
all the rest look good.

The older code I am using as an example uses glGetFloatv to get the perspective 
and view matrixes.  Well, in my code, glGetFloatv is returning an identity 
matrix for the projection matrix (which is probably part of the OpenGL error 
reported).  Since I saw what looked like the inside of the example .ive I've 
been using I didn't think that the perspective was off.  Using the CAVElib 
matrixes fixes the view problem.

Anyhow, thanks for your help again.

Josh

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





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


Re: [osg-users] osgViewer::GraphicsWindowEmbeded causing OpenGL error

2011-11-14 Thread Joshua Cook

 1) Is the CAVElib creating multiple graphics contexts? If so there you'll
 need a GraphicsWindow on the OSG per context you can't reuse the
 same window per context.

Sorry, forgot to describe CAVElib's behavior there.  CAVElib will create a 
thread for each wall of the cave and thus a new context.  Each of these threads 
will act exactly the same and call the init function once and then call frame 
followed by display.  Using a few built in functions I can use if/else blocks 
to alter behavior based on the wall but it would have to be in the above three 
functions;  I can just make the master wall update positions and what not.  So, 
to answer your question a bit more specifically, there will be one embedded 
window for each context.


 2) Do you really need to use CAVElib? The OSG itself can render
 to a cave just by setting up the Viewer slave Camera appropriately.
 There is also integration with other 3rd party VR libs.


Yup, for the present, I have to use CAVElib.  I've ready many good things about 
vrjuggler and would love to use it but the clear time here would be around 6 
months if I'm lucky.  The project is due in a few weeks so that isn't an option 
at present.  :([/quote]

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





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


Re: [osg-users] osgViewer::GraphicsWindowEmbeded causing OpenGL error

2011-11-14 Thread Joshua Cook
Robert,
Thanks for the replies.

Anyhow, the reasoning has to do with risk and periferal support; head tracker, 
a wand, and other assorted goodies CAVElib already deals with.  I probably 
could write something that did the same but would have a heck of a time 
convincing them it would be the best approach with the deadline looming like 
Lancelot at a wedding party.  The other thing that CAVElib does is sync the 3D 
effect over multiple computers.  I'm fairly sure that is not too difficult to 
do but since I've no experience there I wouldn't be able to argue that point 
very effectively.  Yes, they are fairly weak arguments but it is what I have to 
work with.  :)

Anyhow, I'll drop the embeded window and look towards another solution.  
Mayhaps it will be with the osg::Viewer that I'll find the final, correct 
answer.  Thanks again.

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





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


[osg-users] osgViewer::GraphicsWindowEmbeded causing OpenGL error

2011-11-09 Thread Joshua Cook
So, comes the hard part of my asignment.  I'm now tasked with taking the 
wonderful viewer that I've written using OSG and making it play nice with 
CAVElib.  Well, CAVElib does not like to play nice.  It must own the OpenGL 
context and controll everything except the drawing of the objects.  Well, the 
only way I could see to do this was use a GraphicsWindowEmbeded.  Now, if I 
just run CAVElib in the background, so to speak, I can see the example .iv file 
perfectly.  However, there is a constant barage of warnings that an OpenGL 
error has been detected starting with Warning: detected OpenGL error 'invalid 
operation' at Before Renderer::compile, once for each pipe, and then a constant 
stream of Warning: detected OpenGL error 'invalid operation' at after 
RenderBin::draw(..).  If I let CAVElib determine my view frustrum and look at 
matrix I get a screen of garbage because both frustrum and view matrixes are 
identity matrixes which I attribute to the OpenGL issues.

the simple code I'm running to show a .iv file is as follows


Code:

osg::Node* node = NULL;
osg::PositionAttitudeTransform* pat = NULL;
std::vectorosgViewer::Viewer* viewVec;
OpenThreads::Mutex m;
osg::GraphicsContext* gc = NULL;

 void init()
{
  osgViewer::Viewer* viewer = NULL;
  {
OpenThreads::ScopedLockOpenThreads::Mutex lock(m);
viewer = new osgViewer::Viewer();
viewer-setReleaseContextAtEndOfFrameHint(false);
osg::ref_ptrosgViewer::GraphicsWindowEmbedded gw = 
viewer-setUpViewerAsEmbeddedInWindow(100, 100, 500, 500);
viewer-getCamera()-setGraphicsContext(gw);
viewer-setSceneData(pat);
viewer-setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer-setCameraManipulator(new osgGA::TrackballManipulator);
viewer-setThreadSafeRefUnref(true);
viewer-realize();
viewVec.push_back(viewer);
  }

  CAVEDisplayBarrier();

}

void display()
{
  //GLenum errorNo;

  //glPushAttrib(GL_ALL_ATTRIB_BITS);
  //glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
  //glShadeModel(GL_SMOOTH);

  //glMatrixMode(GL_TEXTURE);
  //glPushMatrix();
  //glLoadIdentity();
  //glMatrixMode(GL_PROJECTION);
  //glPushMatrix();
  //glLoadIdentity();
  //glMatrixMode(GL_MODELVIEW);
  //glPushMatrix();
  //glLoadIdentity();

  int num = CAVEPipeNumber();
  osgViewer::Viewer* viewer = viewVec[num];
  viewer-frame();

  //glMatrixMode(GL_TEXTURE);
  //glPopMatrix();
  //glMatrixMode(GL_PROJECTION);
  //glPopMatrix();
  //glMatrixMode(GL_MODELVIEW);
  //glPopMatrix();

  //glPopAttrib();
  //glPopClientAttrib();

  //errorNo = glGetError();

  CAVEDisplayBarrier();
}

void frame()
{
  if(CAVEMasterDisplay())
  {
pat-setAttitude(pat-getAttitude() * osg::Quat(3.14 / 180.0, osg::Y_AXIS));
  }


  pat-setPosition(osg::Vec3(-100, -100, -100));
  int num = CAVEPipeNumber();
  osgViewer::Viewer* viewer = viewVec[num];
  osg::Camera* cam = viewer-getCamera();
  int height = 0;
  int width = 0;
  int x = 0;
  int y = 0;
  CAVEGetViewport(x, y, width, height);
  cam-setViewport(x, y, width, height);

  float viewMatrixGL[16] = {0};
  float projMatrixGL[16] = {0};

  CAVENavTransform();

  glGetFloatv( GL_MODELVIEW_MATRIX , (float*)viewMatrixGL );
  glGetFloatv( GL_PROJECTION_MATRIX, (float*)projMatrixGL );

  osg::Matrix viewMatrix(viewMatrixGL);
  osg::Matrix projMatrix(projMatrixGL);

  // set theproj
  cam-setProjectionMatrix(projMatrix);
  // set the view
  cam-setViewMatrix(viewMatrix);

  CAVEDisplayBarrier();
}

int main(int argv, char** argc)
{
  node = osgDB::readNodeFile(test.iv);
  pat = new osg::PositionAttitudeTransform();
  pat-addChild(node);

  CAVEConfigure(NULL, NULL, NULL);
  CAVEInitApplication(init, 0);
  CAVEDisplay(display, 0);
  CAVEFrameFunction(frame, 0);
  CAVEInit();

  while(1)
  {
OpenThreads::Thread::microSleep(1000);
  }
}




I can't find a solution to my problem and I've scoured the forums, net, 
contacted Mechdyne who owns CAVElib, prayed, and even contemplated sacrificing 
a virgin but the alter is in for cleaning.  So, any help, insite, or the like 
would be greatly appreciated.

soulsabr[/code]

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





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


Re: [osg-users] [SOLVED] Viewer thread safety question

2011-10-13 Thread Joshua Cook

Paul Martz wrote:
 On 10/12/2011 9:41 AM, Chris 'Xenon' Hanson wrote:
 Are you 100% sure the DLL _is_ actually loading but the IV file fails to load?
 How have you verified this? You can set breakpoints in the DLL, or use 
 something like
 SysInternals' ProcessMonitor to snoop on successful (and unsuccessful) DLL 
 loads.
 

Well, there are a few indications we're using to know that the instructions in 
the osgDB_iv.dll and coin3.dll are loading and executing.  First is the VS2010 
output dialoge stating which dlls are being loaded and unloaded.  Second, error 
messages that are printed by coin when running in release.  Lastly, we're 
debugging coin atm to find out why it is failing before we move on to the .iv 
plugin and are seeing our debug statements in coin print.

I assume that instructions from a shared library execute then the shared 
library loaded.  However, since I'm still rather new at interacting with shared 
libraries like this, I'm not 100%.

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





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


Re: [osg-users] Viewer thread safety question

2011-10-12 Thread Joshua Cook
Hey,

I appreciate the advice from everybody and have implemented a lot of it as it 
will help me develope better code.  However, my original problem does not stem 
from thread safety but from the .IV plugin and COIN.  We discoved this before I 
left for the day and I believe this may be an issue to be looked into.

Here is what was happening.  When I tried to load up .IV files using Inventor 
and COIN the plugin would fail along the way.  Most times the failure would 
only return a NULL pointer and I would be led to believe, by the notify 
messages, that the plugin simply could not be found.  However, when we started 
messing around with the order of operations and a few other parameters we 
noticed that the crash was only taking place when attempting to load a .IV 
file.  The reason I thought this was a threading issue is that the call stack 
made it look like one of the internal vectors had been corrupted by another 
thread.  But, since the only thing that was happening at this time was failing 
to read a .IV file we figured something was not quite as it appeared.

To make a long story short COIN was failing in a bad way but the standard 
notify message at the INFO level is:

DynamicLibrary::failed loading osgPlugins-3.0.0/osgdb_ivd.dll
Warning: Could not find plugin to read objects from file ../../some_file.iv.

So, I know that COIN's failure is not an OSG problem but I do believe there may 
be room for a more useful debug output when a dll has problems that don't 
revolve around not existing.

My largest problem is that I'd love to tackle this myself but the legal I'd 
have to go through here would take at least 6 months.  So, it is here for 
discussion and if you think that 6 months + time to fix this wouldnt be that 
bad I could put in for permission to contribute to the project and hope they 
approve it.

Thanks,
soulsabr

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





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


[osg-users] Viewer thread safety question

2011-10-11 Thread Joshua Cook
Ok, so I have the unenviable task of rewriting software from the mid 1980's for 
our virtual reality/cave environment and while I'm rewriting all of this 
software I must make sure that it works with the older software so that 
operations can continue as before; yes, welcome to my world.

The system consists of over twenty different units each of which communicates 
with each other constantly via UDP and the first of these things to go is the 
viewer that was written using OSG .9x.

My viewer must request a dump of all file names and then wait for an end of 
dump message before I start rendering the scene.  However, since this is UDP 
and since there is no telling what the older software is doing (the older code 
uses void* like the fire department uses water) it ends up sending the packet 
with the file name to the wrong computer, fails to send the packet, or UDP just 
fails to make that left turn at Albuquerque and the packet is lost forever.  
So, now I need to request a resend and load all of the missed data into an 
actively running scene graph where every node is a leaf (I'm working on getting 
them to fix that part).

My viewer runs its own update loop in which it will computer inputs, compute 
other changes in the scene, and then check for any new nodes that have been 
received before calling the frame() function.

Since the root node of the scene may constantly change I was just thinking of 
making its variance DYNAMIC.  Of course that has been touted as very 
inefficient and I agree with that.  I had looked at inheriting from 
osg::Drawable::UpdateCallback but figure that I'd have to make the varience 
DYNAMIC anyhow so it wouldn't matter.  So, my question is, would there be a 
better way to make this thread safe other than setting the root node to DYNAMIC 
to avoid crashing when adding another node to the root?

And just in case you're wondering, I'm replacing the viewer first because it 
crashes the most of all of the other systems.

Thanks,
soulsabr

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





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


Re: [osg-users] osgText::Text heap corruption when using setText()

2011-10-08 Thread Joshua Cook
Ok, the original problem seems to have been solved by setting the data variance 
to DYNAMIC.  The further problems were caused by a polluted OSG build and the 
responsible party is currently being flogged. Anyhow, thanks for the help.

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





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


Re: [osg-users] osgText::Text heap corruption when using setText()

2011-10-01 Thread Joshua Cook
Ok, that sucked.  I got timed out while writing my reply and lost the entire 
post.  Lets try again.

Anyhow, got around to trying the code with the DYNAMIC enum and still had a 
crash.  It still looks like it is a threading issue when updating the osgText 
object in a thread.  I can't give all of the code but it should be easy enough 
to reproduce with the following snippet of code.  Please pretend I did a very 
excellent job initializing everything.


Code:


class foo : public OpenThreads::Thread
{
public:
  void addText(std::string text);
  void run();
private:
  OpenThreads::Mutex mMutex;
  std::queue{osg::Geode*} mOutputHistoryQueue;
};

void foo::addText(std::string text)
{
  static unsigned int horizTextOffset = 20;
  static unsigned int lineSpacing = 5;
  static unsigned int vertTextOffset = 20;

  OpenThreads::ScopedLockOpenThreads::Mutex
  lock(mRenderMutex);

  // Get the first geode from the queue
  osg::Geode* textGeode = mOutputHistoryQueue.front();
  mOutputHistoryQueue.pop();

  // These geodes should only have the one text entry; get it;
  osgText::Text* textLine = (osgText::Text*)textGeode-getDrawable(0);
  // Change the text on the entry, no need to put it back
  textLine-setText(aText);

  // Now, push the geode onto the end of the queue
  mOutputHistoryQueue.push(textGeode);

  // Loop through each geode and calculate their position on the screen
  for(unsigned int index = 0;
  index  mOutputHistoryQueue.size();
  index ++)
  {
// Get the text from the queue
textGeode = mOutputHistoryQueue.front();
textLine = (osgText::Text*)textGeode-getDrawable(0);
mOutputHistoryQueue.pop();

// calculate the position of the text
int size = mOutputHistoryQueue.size();
unsigned int yPos = (mOutputHistoryQueue.size() - index) *
(lineSpacing + textLine-getCharacterHeight()) +
vertTextOffset;


textLine-setPosition(osg::Vec3(horizTextOffset, yPos, 0));
// Push the text back onto the queue
mOutputHistoryQueue.push(textGeode);
  }
}

void foo::run()
{
  bool isRunning = true;
  std::string text;
  unsigned int counter = 0;

  while(isRunning)
  {
counter++;
text = *super cool algorithm to turn digits to text*
this-addText(text);
OpenThreads::ScopedLockOpenThreads::Mutex
lock(mRenderMutex);
mpViewer-frame();
  }
}




This should print the last N frames in the bottom left corner of the screen 
where N is the size of the queue.  I've monitored memory usage and the 
reference count for each of the osgText objects and have no memory leaks and 
none of the reference counters are dropping below 1.  I hacked a fix into the 
code and found that it works quite well if there is a mutex locker blocking 
anything that might change the text in osgText.cpp.

Just as an upfront, if this is a bug and not a horrible abuse of things on my 
side then I apologize for the fact that I won't be able to find a fix for this. 
 All other factors aside, by the time legal clears me to submit a patch I'll 
probably be staring in awe as Hell freezes over; yes, this includes my own 
time as well which I don't seem to own anymore.[/code]

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





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


Re: [osg-users] osgText::Text heap corruption when using setText()

2011-10-01 Thread Joshua Cook
Thanks for the reply.  As you can see in the code snippet, the text is changed 
in the render loop before I call the frame() function.  I would have thought 
that all of the processing to update the text position and ready the text to be 
rendered would complete before the updateText function completed.

This is the same as in my code here.  I take user input via a GUIEventHandler 
subclass and hold that until the render loop calls for the user input.  So, all 
user input is considered before the frame() function is called including the 
call to change text.  I guess this is what is confusing me; if I call 
setText(std::string) before I call frame() shouldn't the osgText::Text object 
have all of its data primed and ready before the drawing update occurs?

I apologize if the first sentence seems boorish but it was the best way I could 
put it without writing a paragraph or two.

Josh

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





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


[osg-users] osgText::Text heap corruption when using setText()

2011-09-19 Thread Joshua Cook
Greetings,

First post so please bear with me.  Anyhow, after searching the forum I've not 
run across this particular problem.  osgText seems to corrupt the heap when 
changing the text of an existing osgText::Text object (I'll just say Text 
object from here on).  Before I submitted this as a bug I'd like to know if 
anybody has experienced this or if I'm using the Text class incorrectly.  Here 
is what I'm doing.

I have a scene that is rendering large poly count objects, using the Viewer and 
it's default camera, running on one thread.  I also have a communications class 
running on a separate thread and a few other threads running.  Finally, I have 
a second camera that I'm using to display text in the bottom left corner as an 
overlay or HUD added as a child to the viewer.  The text is simple and I keep 
it at four lines that update text and position only when the text itself 
changes.  These Text objects are never deleted and I only change their text and 
location.  Since my change text function can be called by other threads I have 
a mutex locker at the start of the function and one right before I call the 
viewer to update to avoid race conditions.

Here is what is happening and what I did to correct the problem.  After X 
frames the debugger notifies me there has been a heap corruption.  The 
corruption always takes place in Text::drawTextWithBackdrop.  The problem seems 
to be that while the Text::drawTextWithBackdrop function is running 
Text::computeGlyphRepresentation is called by an OSG created thread and clears 
the _textureGlyphQuadMap member object.  Thus, when the the iterator in 
Text::drawTextWithBackdrop is incremented in the for loop the iterator now 
contains a pointer to garbage.  To solve this I put a locker at the beginning 
of both functions so that they could not use the _textureGlyphQuadMap at the 
same time.  This solved the problem for me.

So, I would like to know if a) I'm using the Text object correctly or if there 
is something else I should be doing to make it thread safe for a text update 
and b) if I'm using the Text object correctly then is this a known bug and do I 
need to submit a bug report.

thanks,

soulsabr

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





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


Re: [osg-users] osgText::Text heap corruption when using setText()

2011-09-19 Thread Joshua Cook

Jason Daly wrote:
 
 You might try setting the data variance of your text objects to DYNAMIC.
 
 text-setDataVariance(osg::Object::DYNAMIC);
 
 This method is inherited from osg::Object, and informs the scene graph 
 that the data might be changing on the fly, so it should double-buffer 
 it between the update and cull/draw phases.
 
 If that doesn't fix it, you might have found a genuine bug.
 
 --J
 

Hey, thanks for the fast reply.  I'll try it out tomorrow and let you know what 
happens.

thanks,

soulsabr

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





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