[osg-users] Camera on a PAT?

2008-09-06 Thread benben

Hello everyone,

Can I add an osg::Camera to an osg::PositionAttitudeTransform node to 
render the scene? The idea is to use the transform node to move and 
orientate the camera.


I tried this myself but all i get is a black screen.

Regards,
Ben

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


Re: [osg-users] ply or off model format

2008-09-06 Thread Robert Osfield
2008/9/6 YangXiao [EMAIL PROTECTED]:
 Hi
Can osg plugin  read .ply or off model format?

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


Re: [osg-users] Camera on a PAT?

2008-09-06 Thread Robert Osfield
Hi Ben,

On Sat, Sep 6, 2008 at 8:28 AM, benben [EMAIL PROTECTED] wrote:
 Can I add an osg::Camera to an osg::PositionAttitudeTransform node to render
 the scene? The idea is to use the transform node to move and orientate the
 camera.

The Camera isn't an ordinary object like a car or house that you
position in the scene, the relationship is that the Camera sits above
the scene that you wish to render, this applies to high level Viewe
Camera's just as it does to ones in the scene graph.  The next special
relationship is that the OpenGL modelview matrix the world underneath
the camera positions the world in the local coordinates of the camera,
rather than positioning the camera in world coordinates - this is just
how OpenGL works and OSG works with.

In your own application you need to Camera to contain the scene you
want to render, if it was a leaf of your scene graph then it wouldn't
have anything to render.  You could add you scene to the Camera but
this would cause a circular cycle in the scene graph and bag you'd end
up reccursing till your memory blows... so that certainly work either.

Second you want to set the Camera's view matrix to be the inverse of
the model matrix, rather than the the model matrix that will be
inherited down to the Camera that you have in your setup.  So again we
are getting the opposite of what you want by placing the Camera as a
leaf.

So this brings us to how do you solve the task of following nodes in
the scene?  The osgGA::NodeTrackerManipulator is one solution, as is
holding the NodePath from the root of your scene to the node you want
to set the position by, and then computing the world to local
transform using osg::computeWorldToLocal(NodePath) (this is what
NodeTracker does internally).  If you set the viewer's Camera's view
matrix yourself don't attach a camera manipulator, and just set the
view matrix each frame like:


   while(!viewer.done())
   {
   // break frame into it's constituent parts
   viewer.advance();
   viewer.updateTraversal();
   viewer.eventTraversals();

   viewer.getCamera()-setViewMatrix(osg::computeWorldToLocal(myNodePath);

   viewer.renderingTraversals();
   }


Or just write your own version of NodeTrackerManipulator.

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


Re: [osg-users] Bug in osg text in certain circonstance

2008-09-06 Thread Robert Osfield
Hi Cedric,

I get an 403 Forbidden error on accessing your file:

http://www.plopbyte.net/tmp/osgText.ogg

Robert.

On Fri, Sep 5, 2008 at 11:33 PM, Cedric Pinson [EMAIL PROTECTED] wrote:
 Hi guys,
 Strange bug with osgText, with the current configuration:

   std::string fontName = ../data/Vera.ttf;
   VarsEditor::instance()-get(fontPlayerName, fontName);
   osgText::Font* font = osgText::readFontFile(fontName.c_str());
   _seatNumber-setFont(font);
   _seatNumber-setCharacterSize(25);
   _seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
   _seatNumber-setAlignment(osgText::Text::CENTER_CENTER);
   _seatNumber-setFontResolution(30,30);
   _seatNumber-setAxisAlignment(osgText::Text::SCREEN);
   std::stringstream ss;
   ss  Seat   data._seatNumber;
   _seatNumber-setText(ss.str());

 I added a video because i don't how to explain it. A text should be display
 and it is not, it's a bit random, sometimes it works
 sometime it does not. I dump the osg tree and the osgText was in the file,
 then if i re read the file with osgviewer it works.
 I found a trick to make it display again in my application, moving the
 camera very near, then it appears. I don't have any idea appart accusing
 osgText.
 I tried in SingleThreaded and the problem and it does not change.
 I guess it's related to the camera position when i create the text. Because
 i susupect that, i tried a configuration

  std::string fontName = ../data/Vera.ttf;
   VarsEditor::instance()-get(fontPlayerName, fontName);
   osgText::Font* font = osgText::readFontFile(fontName.c_str());
   _seatNumber-setFont(font);
   _seatNumber-setCharacterSize(0.25);
 //_seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
   _seatNumber-setAlignment(osgText::Text::CENTER_CENTER);
   _seatNumber-setFontResolution(30,30);
   _seatNumber-setAxisAlignment(osgText::Text::SCREEN);
   std::stringstream ss;
   ss  Seat   data._seatNumber;
   _seatNumber-setText(ss.str());

 So the character size mode is now the default, and with that i cant
 reproduce the bug. So last information i have is when i create the text the
 text is behind the camera
 so maybe it does not help for the
 _seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS) mode.

 here the video http://www.plopbyte.net/tmp/osgText.ogg

 --
 +33 (0) 6 63 20 03 56  Cedric Pinson mailto:[EMAIL PROTECTED]
 http://www.plopbyte.net


 ___
 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] ply or off model format

2008-09-06 Thread Erik den Dekker

I have written a .ply reader plugin for a customer's project about one year
ago. I recently contacted the customer about contributing the code to osg
and received permission. The only thing that needs to be done is to
synchronize the original code with SVN trunk.

However, I am on the point of leaving for a one-week vacation abroad, and my
girlfriend insists I don't bring my laptop to the beach :) So, it will be
approximately 2 weeks from now before that submission can be made...


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert
Osfield
Sent: Saturday, September 06, 2008 09:31
To: OpenSceneGraph Users
Subject: Re: [osg-users] ply or off model format

2008/9/6 YangXiao [EMAIL PROTECTED]:
 Hi
Can osg plugin  read .ply or off model format?

No.
___
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] z-up camera position osgthirdpersonview

2008-09-06 Thread Fabian Bützow

Hi everybody,

i played a bit around with the osgthirdpersonview..

my goal was to draw an additional line for the up vector (Vec3(0.0, 0.0, 
1.0))-

hence i added the fllowing code to the example:

camera-getViewMatrixAsLookAt(*eye, *center, *up); //gives the up vector

//draws a line from origin to up vector
(*v)[9].set(*up);
GLushort idxLoops2[2] = {9, 0 };
geom-addPrimitiveSet( new osg::DrawElementsUShort( 
osg::PrimitiveSet::LINE_LOOP, 2, idxLoops2 ) );


This didnt bring the desired effect,
and I disabled the inverse viewmatrix tranformation to see where the 
orginal viewfrustum would be drawn.
Surpringsliy (for me ;)) the camera looks along the negative z-axis as 
in std opengl...

My up vector however pointed still to z up (and not as expected to y north)

what do i have to do to draw the upvector approprietly?

cheers  a nice weekend
Fabian




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


Re: [osg-users] Bug in osg text in certain circonstance

2008-09-06 Thread Cedric Pinson

Oops sorry, i fixed the permission.


Robert Osfield wrote:

Hi Cedric,

I get an 403 Forbidden error on accessing your file:

http://www.plopbyte.net/tmp/osgText.ogg

Robert.

On Fri, Sep 5, 2008 at 11:33 PM, Cedric Pinson [EMAIL PROTECTED] wrote:
  

Hi guys,
Strange bug with osgText, with the current configuration:

  std::string fontName = ../data/Vera.ttf;
  VarsEditor::instance()-get(fontPlayerName, fontName);
  osgText::Font* font = osgText::readFontFile(fontName.c_str());
  _seatNumber-setFont(font);
  _seatNumber-setCharacterSize(25);
  _seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
  _seatNumber-setAlignment(osgText::Text::CENTER_CENTER);
  _seatNumber-setFontResolution(30,30);
  _seatNumber-setAxisAlignment(osgText::Text::SCREEN);
  std::stringstream ss;
  ss  Seat   data._seatNumber;
  _seatNumber-setText(ss.str());

I added a video because i don't how to explain it. A text should be display
and it is not, it's a bit random, sometimes it works
sometime it does not. I dump the osg tree and the osgText was in the file,
then if i re read the file with osgviewer it works.
I found a trick to make it display again in my application, moving the
camera very near, then it appears. I don't have any idea appart accusing
osgText.
I tried in SingleThreaded and the problem and it does not change.
I guess it's related to the camera position when i create the text. Because
i susupect that, i tried a configuration

 std::string fontName = ../data/Vera.ttf;
  VarsEditor::instance()-get(fontPlayerName, fontName);
  osgText::Font* font = osgText::readFontFile(fontName.c_str());
  _seatNumber-setFont(font);
  _seatNumber-setCharacterSize(0.25);
//_seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS);
  _seatNumber-setAlignment(osgText::Text::CENTER_CENTER);
  _seatNumber-setFontResolution(30,30);
  _seatNumber-setAxisAlignment(osgText::Text::SCREEN);
  std::stringstream ss;
  ss  Seat   data._seatNumber;
  _seatNumber-setText(ss.str());

So the character size mode is now the default, and with that i cant
reproduce the bug. So last information i have is when i create the text the
text is behind the camera
so maybe it does not help for the
_seatNumber-setCharacterSizeMode(osgText::Text::SCREEN_COORDS) mode.

here the video http://www.plopbyte.net/tmp/osgText.ogg

--
+33 (0) 6 63 20 03 56  Cedric Pinson mailto:[EMAIL PROTECTED]
http://www.plopbyte.net


___
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
  


--
+33 (0) 6 63 20 03 56  Cedric Pinson mailto:[EMAIL PROTECTED] 
http://www.plopbyte.net


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


Re: [osg-users] Speeding Up osgText?

2008-09-06 Thread E. Wing
 void Text::computePositions()
 {
 unsigned int size =
 osg::maximum(osg::DisplaySettings::instance()-getMaxNumberOfGraphicsCon
 texts(),_autoTransformCache.size());

 // FIXME: OPTIMIZE: This would be one of the ideal locations to
 // call computeAverageGlypthWidthAndHeight(). It is out of the
 contextID loop
 // so the value would be computed fewer times. But the code will
 need changes
 // to get the value down to the locations it is needed. (Either pass
 through parameters
 // or member variables, but we would need a system to know if the
 values are stale.)

 for(unsigned int i=0;isize;++i)
 {
  computePositions(i);
 }
 }

So I am not an expert on the osgText implementation, but I think I am
the one that wrote that comment. I wrote that when I added the
backdrop text and gradient feature to osgText. My strategy was to make
the least amount of structural changes as possible because the
implementation was sufficiently complicated enough, so optimization
wasn't my goal.

I think that above block already existed in some form before my
changes, but as I was refactoring trying to fit in the new features, I
think I took note of that block of code and added that comment
realizing it could be faster. I suggest if you are looking for a way
to speed things up, you could try to do exactly what that comment
says. I honestly don't remember the code at this point, and I never
really profiled how much time was spent in that loop. But I think it
is one of the more staightforward and obvious places that can be
optimized (but probably tedious).

Another thing to note is with the backdrop feature on, it isn't
terribly efficient if I recall, because it needs to repeat for every
direction of the shadow. So if you do outline text, you multiply by 8
or 9 passes. So don't turn on backdrop text if there are performance
problems.

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


Re: [osg-users] z-up camera position osgthirdpersonview

2008-09-06 Thread Paul Martz
The geometric data for the view volume in osgthirdpersonview is in OpenGL
eye coordinate space, and is transformed by the inverse modelview to put it
into world (object) space.

The up vector your code gets from the camera is already in world space.
However, your code treats it like it's in eye space, and incorrectly
back-transforms it (like the rest of the eye space view volume).

So, you've made a mistake in your linear algebra. You'll need to rethink the
coordinate spaces you are working with and fix your code accordingly.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466




 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf 
 Of Fabian Bützow
 Sent: Saturday, September 06, 2008 3:16 AM
 To: osg-users@lists.openscenegraph.org
 Subject: [osg-users] z-up  camera position  osgthirdpersonview
 
 Hi everybody,
 
 i played a bit around with the osgthirdpersonview..
 
 my goal was to draw an additional line for the up vector 
 (Vec3(0.0, 0.0,
 1.0))-
 hence i added the fllowing code to the example:
 
 camera-getViewMatrixAsLookAt(*eye, *center, *up); //gives 
 the up vector
 
 //draws a line from origin to up vector
 (*v)[9].set(*up);
 GLushort idxLoops2[2] = {9, 0 };
 geom-addPrimitiveSet( new osg::DrawElementsUShort(
 osg::PrimitiveSet::LINE_LOOP, 2, idxLoops2 ) );
 
 This didnt bring the desired effect,
 and I disabled the inverse viewmatrix tranformation to see where the 
 orginal viewfrustum would be drawn.
 Surpringsliy (for me ;)) the camera looks along the negative 
 z-axis as 
 in std opengl...
 My up vector however pointed still to z up (and not as 
 expected to y north)
 
 what do i have to do to draw the upvector approprietly?
 
 cheers  a nice weekend
 Fabian
 
 
 
 
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce
 negraph.org

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


Re: [osg-users] VPB error

2008-09-06 Thread Michael W. Hall
Got OSG/trunk and VPB/trunk both compiled and both installed.  However,
I still get the error when I try to run osgdem.  

osgdem:  error while loading shared libraries:  libvpb.so.8: cannot open
shared object file:  No such file or directory

I looked in /usr/local/lib64 and here is what I have:

lrwxrwxrwx 1 root root  11 2008-09-06 15:57 libvpb.so - libvpb.so.8
-rwxr-xr-x 1 root root 3577150 2008-09-06 15:57 libvpb.so.0.9.9
lrwxrwxrwx 1 root root  15 2008-09-06 15:57 libvpb.so.8 -
libvpb.so.0.9.9

Not sure why I am getting the error, when it appears that the install
did creat the symlink.

Any ideas?

Michael

On Fri, 2008-09-05 at 20:59 +0100, Robert Osfield wrote:
 On Fri, Sep 5, 2008 at 8:26 PM, Michael W. Hall [EMAIL PROTECTED] wrote:
  I looked at the front page and nothing is mentioned about OSG 2.6.
 
 And yet you still wanted to make the assumption that implictly
 SVN/trunk meant OSG 2.6...  the VPB wiki front page tells you
 everything that is to know.
 
  I
  have tried VPB 0.9.7 and make fails with several errors.  The SVN
  version compiles, but gives the the error when I try to run it.  Can you
  tell me which version of VPB I need?
 
 There is no VPB dev release that maps to OSG-2.6.
 
 VPB is in development, and isn't far away from its 1.0.  To pick up on
 the latest VPB you'll need VPB svn/trunk and OSG svn/trunk as some of
 the recent additions to VPB required mods to osgTerrain in OSG, since
 2.6.
 
 Once VPB is ready for its next dev release I'll match a VPB dev
 release with a corresponding OSG dev release.  I'm not ready for this
 yet.
 
 Robert.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

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


Re: [osg-users] SpeedTree example

2008-09-06 Thread Albino Rodrigues
My apologizes for the late reply. You've no doubt got something working by
now.

 

The following is what I did to work out quickly how to get speed tree
working in OSG using a custom drawable. The lead coder has since taken this
and implemented it a much nicer fashion.

 

First of all, I recommend reading all the documentation. There's not too
much of it to go through. But it will help you plan the best way to
integrate osg for your needs and develop a workflow around it. Also go
through the reference application OpenGL example line by line. Make changes
here and there and see the effect of it.

 

If you plan on going down the custom drawable route, check out -
http://www.openscenegraph.org/projects/osg/attachment/wiki/Support/Tutorials
/Tuto10.zip 

It's a good tutorial on custom drawables.

 

In essence, the implementation can be distilled like so:

 

-  Create a speed tree forest

-  Create a custom drawable to draw speed tree forest using the
reference application code

-  Add custom drawable to a geode

-  Add it to the scene

 

This implementation is by no means the best way of doing things. I chose
this for the following reasons:

 

-  Easy to implement

-  Suited my employer's immediate needs

 

We anticipate it will have troubles when we start creating scene with a lot
of alpha transparencies on objects. So if anyone reading has solved this
problem, I'd love to hear your method.

 

Before coding, I recommended creating a simple terrain model, and a
SpeedTree forest for this model in your modeling tool of choice.

 

Custom Drawable (ignore the dodgy formatting from copy\pasting):

 

virtual void drawImplementation(osg::RenderInfo renderInfo) const

{

float afProjection[16];

float afModelView[16];



glGetFloatv(GL_PROJECTION_MATRIX, afProjection); 

glGetFloatv(GL_MODELVIEW_MATRIX, afModelView);

 

glPushAttrib(GL_ALL_ATTRIB_BITS);



//for obvious reasons, IDV code isn't shown. 

//Update the forest camera

//Update time

//Draw



glPopAttrib();

 

//renderInfo.getState()-apply(); //needed?

 

}

 

//Based on Robert's advice. Return a default bounding box so that osg
doesn't cull this forest drawable

//This implementation relies solely on SpeedTree's culling and LODing

virtual osg::BoundingBox computeBound() const

{

  osg::BoundingBox b;

  return b;

}

 

Test Application (will just paste the relevant code):

 

int main()

{

 

  //Create your osg stuff, root node etc

  //Setup terrain model

 

  //I couldn't find a way around this. You have to init glew.

//I can't remember what happens if you don't do this. but I suspect it's
less than ideal.

viewer-getCamera()-getGraphicsContext()-makeCurrent(); 

   if (!bGlewInitialized)

   {

 GLenum err = glewInit( );

 if (err != GLEW_OK)

 {

   printf(GLEW initialization failed: %s\n,
glewGetErrorString(err));

   exit(-1);

 }

   }

 

//create your speed tree forests (again IDV code, so look at the reference
application). Store them in the supplied //vector if you need.

//you could of course do this in the custom drawable. I just happened to do
it here as I was following the reference

//application.

 

//set forest lighting

 

//populate from forest file

 

//set fog - horrible looking!

 

//set lod

 

//set projection

 

//set lod distances

 

//I then created an OSG stateset that replicated the reference app. But I
found it wasn't needed using

//the custom drawable code. Experiment.

 

//Create a Forest Drawable

forestDrawable-setUseDisplayList(false);

osg::Geode *fGeode = new osg::Geode();

  //fGeode-setStateSet(speedTreeState);

  fGeode-addDrawable(forestDrawable);

root-addChild(fGeode);

 

while(!viewer-done() )

  {   

viewer-frame();

}

}

 

You'll probably come across weird problems, but that's the probably the
easiest way to get SpeedTree into OSG. But keep in mind it's far from ideal.
So evaluate it to see if it meets your needs. Best of luck!

 

Bino

 

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Seppo
Laukkanen
Sent: Saturday, August 23, 2008 9:19 PM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] SpeedTree example

 

Hi!

 

I read from posts that people have been successful to integrate SpeedTree to
OSG at least by 1. alternative: Just use the opengl example from speedtree
and wrap it with a custom drawable..

Is it possible for someone who have accomplished this to put some short
example etc how to get started?

 

 

Thanks!

Seppo 

 

 

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


[osg-users] z-up camera position osgthirdpersonview

2008-09-06 Thread Fabian Bützow

Hi,
let me summarise my thoughts about the osg-opengl-coordinate system issue:
(and please comment on that)

Thinking in local coordinate systems, every geometry has its own coordinate system, 
starting in WCS (0,0,0). For each coordinate system is X east, Y north and Z up.
When you add transformation nodes into the scenegraph between root and geometry, 
each transformation adds up to a model matrix(top-down) that transforms the coordinate system.

(imagine: the geometry is drawn into that modified coordinate system)

After that, the view Matrix of the camera is applied. (camera coordinates are 
in osg Z-up)
Basically, that means that the local coordinates are transformed into the eye 
coordinates.

Still, z is up?!
(virtual camera is in origin, looking along positive y, right-hand-system)


I found this quote from Robert:
Once the scene is transformed into eye space by the View matrix of the
Camera the coordinate system of the eye space is standard OpenGL, +ve
Y up the screen, +ve X to the right, +Z out from the screen.

And now im getting a little confused..
Now an addtional rotation (x, 90°) should be applied, 
to rotate the coordinate system from osg into X east, Y up, Z south.


That would mean camera still looks along positive y.?? 
that would be strange when it comes to the viewing volume and the perspective division..?

(Y non linear scaled??, something's wrong here..)

see, im confused ;)
im sure you can help me,

cheers
Fabian






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