Re: [osg-users] Crashing when calling "viewer->done()"

2011-05-20 Thread Robert Kern
Hi,

Don, I tried your suggestion and then I started getting compile errors in 
osgViewer/ViewerBase

Skylark, I'm working on checking the dependencies. This application was 
originally linked to a server program that performed some other tasks for the 
visualization, however that is no longer needed. I'm trying to make this a 
stand alone application. I tried to copy the settings a dependencies from the 
original application but maybe I missed something.

Thank you!

Cheers,
Robert

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





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


Re: [osg-users] Crashing when calling "viewer->done()"

2011-05-19 Thread Don Leich

Hello Robert,

I may be a couple of days late, but I have a suggestion to solve your
crashing problem.  Instead of s dynamically allocated viewer use a
static object.


osgViewer::Viewer viewer;
...
 //don't want this: viewer = new osgViewer::Viewer();
...
 viewer.realize();

 int iter = 0;

while( !viewer.done() )
{
cout<<"iter: "

Re: [osg-users] Crashing when calling "viewer->done()"

2011-05-16 Thread Jean-Sébastien Guay

Hello Robert,


Here is a simplified version of the code with all of the motion tracking and camera movement 
taken out. As the code is right now, my program crashes when calling viewer>done() the 
first time. If I comment out viewer->realize(), the program crashes on the first call to 
viewer->frame(). If I comment out viewer->realize() and viewer->frame() the the 
program runs indefinitely.


First of all, your example calls no OpenGL / GLU / GLUT code itself, so 
you can remove those headers...


Second of all, there was still an initTracker() call at the beginning of 
main() I had to comment out.


But after that, even though I don't have your data so it starts up an 
empty viewer, your code works for me. It doesn't crash.


...
iter: 594
iter: 595
iter: 596
iter: 597
iter: 598

So if it crashes for you, I suspect you have some mixup of release and 
debug libraries, or you have a mixup of versions of OpenSceneGraph, or 
something like that. Double- and triple-check your linker settings and 
dependencies, there is probably something there.


Hope this helps,

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] Crashing when calling "viewer->done()"

2011-05-16 Thread Robert Kern
Hi,

Here is a simplified version of the code with all of the motion tracking and 
camera movement taken out. As the code is right now, my program crashes when 
calling viewer >done() the first time. If I comment out viewer->realize(), the 
program crashes on the first call to viewer->frame(). If I comment out 
viewer->realize() and viewer->frame() the the program runs indefinitely.


Code:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 



using namespace std;
using namespace osg;

#define PI 3.1415926535


float SCREEN_HEIGHT = .03409;//.03409;//7.75;   //unit: feet - because near 
plane was converted from 1.0 to 0.01
float SCREEN_WIDTH = SCREEN_HEIGHT*1.25;//unit: feet
float CENTER_HEIGHT = SCREEN_HEIGHT / 2.0;  //unit: feet

float eye_height = 0.0; //eye height will read from a 
network shared file at the beginning. 
float METERS2FEET = 3.28084;//ratio of 1 metre and 1 feet
int exptCondition = 0;

osgViewer::Viewer *viewer;


int main( int argc, char **argv )
{

initTracker();

// initialize the viewer.
osg::ArgumentParser arguments(&argc,argv);

viewer = new osgViewer::Viewer();

/***
ELEVATORS
Start of Elevator Scene Graph Code
***/

osg::Group* elevatorRoot = new osg::Group();

//create nodes: later for full tower, consider arrays of nodes
osg::Node* elevatorNode = NULL;
osg::Node* elevatorShaftNode= NULL;
osg::Node* floorNode= NULL;
osg::Node* glassNode= NULL;
osg::Node* pillarNode   = NULL;


//create transformers   
= new osg::Group();
osg::PositionAttitudeTransform* rootPATXform= new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* elevatorXform   = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* elevatorShaftXform  = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* floorXform  = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* glassXform  = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* pillarXform = new 
osg::PositionAttitudeTransform();

//create textures
osg::Texture2D* elevatorTexture = new osg::Texture2D;
osg::Texture2D* elevatorShaftTexture= new osg::Texture2D;
osg::Texture2D* floorTexture= new osg::Texture2D;
osg::Texture2D* glassTexture= new osg::Texture2D;
osg::Texture2D* pillarTexture   = new osg::Texture2D;

elevatorTexture->setDataVariance(osg::Object::DYNAMIC);
elevatorShaftTexture->setDataVariance(osg::Object::DYNAMIC);
floorTexture->setDataVariance(osg::Object::DYNAMIC);
glassTexture->setDataVariance(osg::Object::DYNAMIC);
pillarTexture->setDataVariance(osg::Object::DYNAMIC);


//load models
elevatorNode= 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/Elevators.obj");
elevatorShaftNode   = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/ElevatorShafts.obj");
floorNode   = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/Floor.obj");
glassNode   = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/Glass.obj");
pillarNode  = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/Pillars.obj");




//add transformers to root
//rootnode->addChild(rootPAT);
elevatorRoot->addChild(elevatorXform);
elevatorRoot->addChild(elevatorShaftXform);
elevatorRoot->addChild(floorXform);
elevatorRoot->addChild(glassXform);
elevatorRoot->addChild(pillarXform);

//add models to graph
rootPATXform->addChild(elevatorRoot);
elevatorXform->addChild(elevatorNode);
elevatorShaftXform->addChild(elevatorShaftNode);
floorXform->addChild(floorNode);
glassXform->addChild(glassNode);
pillarXform->addChild(pillarNode);


//scale and position elements
float rotate= 3.1415926/2.0;
Vec3d axis  = Vec3d(0,0,1);
Vec3d position  = Vec3d(-2.0,-1.4,-11.00);
Vec3d farPos= Vec3d(5.30,0.0,.00);

//Scale and position the floor
osg::Quat rootElevatorQuat = floorXform->getAttitude();
rootElevatorQuat.makeRotate(rotate

Re: [osg-users] Crashing when calling "viewer->done()"

2011-05-11 Thread Robert Kern
Hi,


> You should run your program in a debugger and see where it crashes.


Thanks, I'll try that.


> In the posted code, several functions are not declared or defined 
> (initTracker(), camUpdate(viewer) ) and I don't even see where the 
> viewer variable is declared. You don't seem to be including any of your 
> own headers so I don't see where those come from. We can have a quick 
> look at some code but that's generally not very useful as it will leave 
> us with more questions than answers. Post the complete code to a small 
> example that reproduces your issue for best results.
> 
> In your particular case I'd be suspicious of the camUpdate(viewer) 
> function, since it's being passed a pointer to the viewer, we can't know 
> what's going on in there but something bad seems to be happening to the 
> viewer.


The functions are there, I just didn't post them because they a bit lengthy and 
I thought it would be a little superflous. Though I guess I could have noted 
that I left them out. I know the problem isn't with the camUpdate() function 
because through a little debugging, I realized that the program was crashing 
before it ever reached that function call. I'll keep working on it.

Thank you!

Cheers,
Robert

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





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


Re: [osg-users] Crashing when calling "viewer->done()"

2011-05-11 Thread Jean-Sébastien Guay

Hello Robert,


I'm having a problem with my application crashing when I try to create a 
while(!viewer->done()) loop. The run time error I am getting is:

Unhandled exception at 0x00361710 in elevator.exe: 0xC005: Access violation 
reading location 0x0415.


You should run your program in a debugger and see where it crashes. This 
kind of message is totally useless, and just running in a debugger will 
likely point out exactly where the problem occurs, and since you have 
the code in front of you, you'll be able to fix it.



Could someone take a look and help me out?


In the posted code, several functions are not declared or defined 
(initTracker(), camUpdate(viewer) ) and I don't even see where the 
viewer variable is declared. You don't seem to be including any of your 
own headers so I don't see where those come from. We can have a quick 
look at some code but that's generally not very useful as it will leave 
us with more questions than answers. Post the complete code to a small 
example that reproduces your issue for best results.


In your particular case I'd be suspicious of the camUpdate(viewer) 
function, since it's being passed a pointer to the viewer, we can't know 
what's going on in there but something bad seems to be happening to the 
viewer.


Then again, you might also be mixing release and debug binaries when 
compiling, we have no way of knowing that either. A lot has been said 
about the need to be sure you link release with release, debug with 
debug when using Visual C++. Have a search in the archives or the forum 
for more details.


Hope this helps,

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] Crashing when calling "viewer->done()"

2011-05-11 Thread Chris 'Xenon' Hanson
On 5/11/2011 12:50 PM, Robert Kern wrote:
> Access violation reading location 0x0415

  Without even reading the code, this usually indicates trying to read a NULL 
pointer as a
pointer to an object.

  Check all your pointers in the debugger at the point you've crashed at.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Crashing when calling "viewer->done()"

2011-05-11 Thread Robert Kern
Hi,

I'm having a problem with my application crashing when I try to create a 
while(!viewer->done()) loop. The run time error I am getting is:

Unhandled exception at 0x00361710 in elevator.exe: 0xC005: Access violation 
reading location 0x0415.

Could someone take a look and help me out?



Code:
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 


int main( int argc, char **argv )
{

initTracker();

// initialize the viewer.
osg::ArgumentParser arguments(&argc,argv);

viewer = new osgViewer::Viewer(arguments);


osg::Group* elevatorRoot = new osg::Group();

//create nodes: later for full tower, consider arrays of nodes
osg::Node* elevatorNode = NULL;
osg::Node* elevatorShaftNode= NULL;
osg::Node* chamberNode  = NULL;


//create transformers
osg::PositionAttitudeTransform* rootPATXform= new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* elevatorXform   = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* elevatorShaftXform  = new 
osg::PositionAttitudeTransform();
osg::PositionAttitudeTransform* chamberXform= new 
osg::PositionAttitudeTransform();

//create textures
osg::Texture2D* elevatorTexture = new osg::Texture2D;
osg::Texture2D* elevatorShaftTexture= new 
osg::Texture2D;
osg::Texture2D* chamberTexture  = new osg::Texture2D;

elevatorTexture->setDataVariance(osg::Object::DYNAMIC);
elevatorShaftTexture->setDataVariance(osg::Object::DYNAMIC);
chamberTexture->setDataVariance(osg::Object::DYNAMIC);



//load models
elevatorNode= 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/ElevatorModelsV2.obj");
elevatorShaftNode   = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/ElevatorShaftsModelV2.obj");
chamberNode = 
osgDB::readNodeFile("C:/3DVisualizer_Ped_Walk/VE_Model/Floor.obj");


//add transformers to root
elevatorRoot->addChild(elevatorXform);
elevatorRoot->addChild(elevatorShaftXform);
elevatorRoot->addChild(chamberXform);


//add models to graph
rootPATXform->addChild(elevatorRoot);
elevatorXform->addChild(elevatorNode);
elevatorShaftXform->addChild(elevatorShaftNode);
chamberXform->addChild(chamberNode);


//scale and position elements
float rotate= 3.1415926/2.0;
osg::Vec3d axis = osg::Vec3d(0,0,1);
osg::Vec3d position = osg::Vec3d(0.0,0.0,.000);
osg::Vec3d farPos   = osg::Vec3d(5.30,0.0,.00);

//Scale and position the chamber
osg::Quat rootElevatorQuat = chamberXform->getAttitude();
rootElevatorQuat.makeRotate(rotate,axis);
chamberXform->setAttitude(rootElevatorQuat);
chamberXform->setPosition(position);

//Scale and position the elevator
rootElevatorQuat = elevatorXform->getAttitude();
rootElevatorQuat.makeRotate(rotate,axis);
elevatorXform->setAttitude(rootElevatorQuat);
elevatorXform->setPosition(position);

//Scale and position the elevator Shaft
rootElevatorQuat = elevatorShaftXform->getAttitude();
rootElevatorQuat.makeRotate(rotate,axis);
elevatorShaftXform->setAttitude(rootElevatorQuat);
elevatorShaftXform->setPosition(position);


//load Textures
osg::Image* elevatorTextureImage = 
osgDB::readImageFile("C:/3DVisualizer_Ped_Walk/VE_Model/ElevatorTexture.jpg");
if (!elevatorTextureImage)
{
cout << " couldn't find elevator texture." << std::endl;
}
else{
elevatorTexture->setImage(elevatorTextureImage);

elevatorNode->getOrCreateStateSet()->setTextureAttributeAndModes( 0, 
elevatorTexture, osg::StateAttribute::ON);
}


osg::Image* elevatorShaftTextureImage = 
osgDB::readImageFile("C:/3DVisualizer_Ped_Walk/VE_Model/ElevatorShaftTextureV2.jpg");
if (!elevatorShaftTextureImage)
{
std::cout << " couldn't find elevator shaft texture." << 
std::endl;
}
else{
elevatorShaftTexture->setImage(elevatorShaftTextureImage);

elevatorShaftNode->getOrCreateStateSet()->setTextureAttributeAndModes( 0, 
elevatorShaftTexture, osg::StateAttribute::ON);
}

viewer->setSceneData(elevatorRoot);


osgViewer::Viewer::Windows windows;


//create Slave Cameras

int xoffset = 0;
int yoffset = 0;