Re: [osg-users] Get position when using animation path

2011-10-20 Thread Robert Kern
I think I might have some bigger issues.

The ouput of the following lines of code is consistantly coinPos 0 0 0


coinTranslate-setPosition(osg::Vec3d(-26.402, 4.991, 0));
osg::Vec3d coinPos = coinTranslate-getPosition();

coutcoinPos coinPos[0]' 'coinPos[1]' 
'coinPos[2]endl;

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





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


[osg-users] Get position when using animation path

2011-10-19 Thread Robert Kern
Hi,

I have a positionAttitudeTransform node that I've put an animation path 
callback function on. As the object is moving I need to know its position. I 
can see my object moving in my scene however when I call 
positionAttitudeTransform::getPosition() it always returns the coordinates 
(0,0,0). How can I get the position of my object? 

Thank you!

Cheers,
Robert

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





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


[osg-users] How to use CameraView

2011-07-27 Thread Robert Kern
Hi,

I need to change the FOV for the two slave cameras that I have and I have 
figured out that I need to use the CameraView class but I cannot figure out how 
to use it. Could I get some help please.

Thank you!

Cheers,
Robert

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





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


Re: [osg-users] How to use CameraView

2011-07-27 Thread Robert Kern
I just need to change the fov to match the specs of the HMD I am using for a 
virtual reality application.

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





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


[osg-users] Flat Shading

2011-06-29 Thread Robert Kern
Hi,

I've been trying to figure out how to switch to flat shading but I can't quite 
figure out how. Could someone help me out?

Thank you!

Cheers,
Robert

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





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


Re: [osg-users] Flat Shading

2011-06-29 Thread Robert Kern
Hi,

Yes, but how do I use osg::ShadeModel? Do I get it from a viewer or camra? Do I 
make it my self and then pass it off to something?

Thank you!

Cheers,
Robert

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





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


[osg-users] Crashing when building scene

2011-05-20 Thread Robert Kern
Hi, I'm expanding an application so that instead of one level of elevators, 
there can be several. However, when I am building my scene, one of my for loops 
causes the program to crash. I have a loop that assigns the models to their 
respective PositionAttitudeTransform pointers. However, after the very first 
call of elevatorShaftXforms[i]-addChild(elevatorShaftNodes[i]) the value of i 
jumps from 0 to 30934149 and numFloors changes from 7 to 5 and on the following 
line, I get the error:

Unhandled exception at 0x01d80485 in fltviewer.exe: 0xC096: Privileged 
instruction.



Code:
int numFloors = 7;

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;

//node arrays
osg::Node** elevatorShaftNodes  = new osg::Node *[numFloors];
osg::Node** floorNodes  = new osg::Node *[numFloors];
osg::Node** glassNodes  = new osg::Node *[numFloors];
osg::Node** pillarNodes = new osg::Node *[numFloors];


//create transformers
//osg::Group* rootPAT   
= 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();

//transformer arrays
osg::PositionAttitudeTransform** elevatorShaftXforms=   new 
osg::PositionAttitudeTransform *[numFloors];
osg::PositionAttitudeTransform** floorXforms=   
new osg::PositionAttitudeTransform *[numFloors];
osg::PositionAttitudeTransform** glassXforms=   
new osg::PositionAttitudeTransform *[numFloors];
osg::PositionAttitudeTransform** pillarXforms   =   
new osg::PositionAttitudeTransform *[numFloors];

//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);

//assign models to nodes

for(int i=0; inumFloors; i++){
elevatorShaftNodes[i]   = elevatorShaftNode;
floorNodes[i]   = floorNode;
glassNodes[i]   = glassNode;
pillarNodes[i]  = pillarNode;
}



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

for(int i=0; inumFloors; i++){
elevatorRoot-addChild(elevatorShaftXforms[i]);
elevatorRoot-addChild(floorXforms[i]);
elevatorRoot-addChild(glassXforms[i]);
elevatorRoot-addChild(pillarXforms[i]);
}

//add models to graph
rootPATXform-addChild(elevatorRoot);
  

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-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 osg/Geode
#include osg/Group
#include osg/MatrixTransform
#include osg/NodeVisitor
#include osg/Notify
#include osg/PositionAttitudeTransform
#include osg/Quat
#include osg/TexGen

#include osgDB/DatabasePager
#include osgDB/ReadFile
#include osgDB/Registry

#include osgUtil/IntersectVisitor
#include osgUtil/Optimizer

#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers

#include gl/gl.h
#include GL/glu.h
#include GL/glut.h
#include stdlib.h
#include iostream



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  = 

[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 osg/Geode
#include osg/Group
#include osg/MatrixTransform
#include osg/NodeVisitor
#include osg/Notify
#include osg/PositionAttitudeTransform
#include osg/Quat
#include osg/TexGen

#include osgDB/DatabasePager
#include osgDB/ReadFile
#include osgDB/Registry

#include osgUtil/IntersectVisitor
#include osgUtil/Optimizer

#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers

#include gl/gl.h
#include GL/glu.h
#include GL/glut.h
#include stdlib.h
#include iostream


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, 

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] Move Default Near Culling Plane

2011-03-07 Thread Robert Kern
Changing the near/far ratio seems to be doing little (if any) change. I'm still 
clipping out objects 2 feet away from me when I set the ratio to .0001. How 
low is too low to make a difference?

Here is how I am using it. Let me know if I am using the call incorrectly. 
Other than that, can you think of any other suggestions?

// left window + left slave camera
{
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = xoffset + 0;
traits-y = yoffset + 0;
traits-width = 1280;
traits-height = 1040;
traits-windowDecoration = false;
traits-doubleBuffer = true;
traits-sharedContext = 0;
osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc.get());
camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);

//fix culling plane
camera-setNearFarRatio(.0001);


// add this slave camera to the viewer, with a shift left of 
the projection matrix
viewer-addSlave(camera.get(), 
osg::Matrixd::translate(-0.030,0.0,0.0), osg::Matrixd::rotate(-.13962625, 
Vec3f(0,1,0))); //0.2268928

}

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





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


[osg-users] Move Default Near Culling Plane

2011-03-04 Thread Robert Kern
Hi,

I'm trying to figure out how to move the near culling plane closer to the 
camera for a VR application I'm working on. Currently, parts of my models are 
being culled before they reach the viewing plane of the HMD. Can anyone help me 
out with this?

Thank you!

Cheers,
Robert

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





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


[osg-users] Rotating slave camera brings clipping plane into view.

2011-01-28 Thread Robert Kern
Hi,

The specs on the HMD that I am working with calls for the view on each eye be 
rotated outward by 13 degrees. However when I do this I can see what appears to 
be a clipping plane. If both cameras are looking straight ahead, there is not a 
problem. However I do need to rotate them outward.

int xoffset = 40;
int yoffset = 40;

// left window + left slave camera
{
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = xoffset + 0;
traits-y = yoffset + 0;
traits-width = 600;
traits-height = 480;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc.get());
camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);

this-addSlave(camera.get(), osg::Matrixd::rotate(-13, 
Vec3f(0,1,0)), osg::Matrixd());
}
   
// right window + right slave camera
{
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = xoffset + 600;
traits-y = yoffset + 0;
traits-width = 600;
traits-height = 480;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc.get());
camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);
this-addSlave(camera.get(), osg::Matrixd::rotate(13, 
Vec3f(0,1,0)), osg::Matrixd());
}


Thank you!

Cheers,
Robert

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





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


[osg-users] Slave Camera not following Master's position

2011-01-24 Thread Robert Kern
Hi,

I've been having trouble implementing slave cameras for an application I'm 
working on. The camera gets its position and orientation from a motion tracking 
system or through joystick input. When I don't set up slave cameras, the camera 
properly responds to input. However, when I implement slave cameras, they do 
not update their position or orientation with input from the motion tracking or 
joy stick.

In the code below, if I comment out the code that sets up the slave cameras, 
the viewer responds properly to input from the joystick or the motion tracker. 
If it is not commented, the slave cameras will display, but they will not 
respond to the motion tracker or joystick. If anyone could provide any 
suggestions, they would be much appreciated.

Thank you!
rjkern

Code:

viewer = new FLTViewer(arguments); //FLTViewer is and extension of the 
osgViewer::Viewer class. It receives the camera position and orientation from a 
server program.

//Here is where I set up the slave camera
int xoffset = 40;
int yoffset = 40;

// left window + left slave camera
{
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = xoffset + 0;
traits-y = yoffset + 0;
traits-width = 600;
traits-height = 480;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc.get());
camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);

// add this slave camera to the viewer, with a shift left of 
the projection matrix
viewer-addSlave(camera.get(), 
osg::Matrixd::translate(1.0,0.0,0.0), osg::Matrixd::rotate(45, Vec3f(1,0,0)));
}
   
// right window + right slave camera
{
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = xoffset + 600;
traits-y = yoffset + 0;
traits-width = 600;
traits-height = 480;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext(gc.get());
camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
camera-setDrawBuffer(buffer);
camera-setReadBuffer(buffer);

// add this slave camera to the viewer, with a shift right of 
the projection matrix
//viewer-addSlave(camera.get(), 
osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd());
viewer-addSlave(camera.get(), 
osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd::rotate(45, Vec3f(1,0,0)));
}


//create socket and set up connections.
viewer-initRecvSocket();

//Load the scene model
viewer-setScene(viewer-file_name);

osg::Group* rootnode;

rootnode = viewer-getRootNode();
if (!rootnode)
{
return -1;
}  

viewer-initPerspective();  //initialize the perspective
viewer-startDataTransfer();

viewer-setCamera(osg::Vec3(0,0,1),osg::Vec3(0,1,0),osg::Vec3(-1,0,0),osg::Vec3(0,0,1));

while( !viewer-done() )
{
viewer-frame();
}

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





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


[osg-users] Rotating stereo view frustums for wide FOV

2010-11-10 Thread Robert Kern
Hi,

I am currently working on getting OpenSceneGraph to work with our new wide 
field of view head mounted display. To take advantage of the wide FOV 
capabilities of the HMD, the viewing frustum for each eye must be turned 
outwards by 13 degrees. Is there a way to rotate the left and right stereo 
cameras individually outward?

Thank you!

Cheers,
Robert

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





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