Re: [osg-users] SpeedTree Example for late version of OSG?

2009-10-28 Thread Jean-Sébastien Guay

Hello Wyatt,

I would like to integrated SpeedTree 5.0 into an osg application.  
Having searched the mailing list archives the most recent mention of a 
SpeedTree example that I found was over a year ago.  Has anyone been 
using SpeedTree with OSG and possibly put together an example that would 
show how to use SpeedTree with a later version of OSG?


Have you tried what that message said?

Even if the most recent mention was a year ago, I doubt OSG has changed 
enough in one year that it won't work anymore. So why don't you try that 
and see if it works? If it doesn't, then you can always come back here 
with specific questions.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.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 for late version of OSG?

2009-10-28 Thread Pierre Bourdin (gmail)
Hi Wyatt,
I would be very interested by this integration...

Is there a possibility to have a free version of SpeedTree ?

Pierre.

Le mardi 27 octobre 2009 à 17:43 -0500, Wyatt Earp a écrit :
 I would like to integrated SpeedTree 5.0 into an osg application.
 Having searched the mailing list archives the most recent mention of a
 SpeedTree example that I found was over a year ago.  Has anyone been
 using SpeedTree with OSG and possibly put together an example that
 would show how to use SpeedTree with a later version of OSG?
 
 Wyatt
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Pierre BOURDIN
I.M.E.R.I.R.
Av. Pascot BP 90443
66004 PERPIGNAN
tél: 04 68 56 84 95
fax: 04 68 55 03 86
email: bour...@imerir.com


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


Re: [osg-users] SpeedTree Example for late version of OSG?

2009-10-28 Thread Wyatt Earp
Actually I haven't tried any of these for various reasons:

According to the post with the most info,

“There are serveral ways to do it:

1. alternative: Just use the opengl example from speedtree and wrap it
with a custom drawable. Using this solution there are many
pros:
* easy to integrate
cons:
* your are using the texture loading/management of speedtree
* you loose the ability of multithreading/multicontext stuff of osg,
because the speedtree example uses CG in a non-multicontext version

2. alternative: Create a osg wrapper for CG (as custom
stateattributes) in osg and use the example to build the appropiate
osg geometry.
pros:
* no need to touch the speedtree shader
* useable in multicontext/multithreaded environment.
cons:
* Integrating CG into osg is a daunting task. However CG does not make
any guaranties about the opengl state after it has been applied, so
you can't use it with other stateattributes or in a hierarchy of
statesets.  So I wouldn't recommend using CG at all in OSG.
3. alternative: Like above you port all the geometry to osg as well as
the CG shaders to GLSL. Porting the shaders to GLSL is easy. I haven't
done anything with shaders before, but if you take a look at Mike
Weiblen GLSL quickrefernce it should be really easy to port the CG
shader.
pros:

* now is pure osg, you don't have any custom drawable or wrappers in it,
EXCEPT: SpeedWind - Speedtree provides a class for creating wind. Just
build a basic wrapper which gets called in the update cycle. “


Further Comments
I assume that the above methods involve SpeedTree prior to v5, which
is what I am using.  According to the SpeedTree website v5 includes a
reorganization of the SDK.  How much, I do not know, but maybe someone
has experience with it and OSG.
I assume that the above reference to CG means nvidia Cg?
3 Isn't an option because we want to integrate SpeedTree, not rewrite
it.  Our goal is to use SpeedTree not develop a copy.  Having seen the
source code, there is much more to it than porting geometry and
shaders.


Wyatt



On Wed, Oct 28, 2009 at 7:48 AM, Jean-Sébastien Guay
jean-sebastien.g...@cm-labs.com wrote:

 Hello Wyatt,

 I would like to integrated SpeedTree 5.0 into an osg application.  Having 
 searched the mailing list archives the most recent mention of a SpeedTree 
 example that I found was over a year ago.  Has anyone been using SpeedTree 
 with OSG and possibly put together an example that would show how to use 
 SpeedTree with a later version of OSG?

 Have you tried what that message said?

 Even if the most recent mention was a year ago, I doubt OSG has changed 
 enough in one year that it won't work anymore. So why don't you try that and 
 see if it works? If it doesn't, then you can always come back here with 
 specific questions.

 J-S
 --
 __
 Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] SpeedTree Example for late version of OSG?

2009-10-28 Thread Jean-Sébastien Guay

Hi Wyatt,


I assume that the above methods involve SpeedTree prior to v5, which
is what I am using.  According to the SpeedTree website v5 includes a
reorganization of the SDK.  How much, I do not know, but maybe someone
has experience with it and OSG.


I hope you get some answers about this, I personally have never used 
SpeedTree so I wouldn't know. But of course, in the mean time you can 
always research how much has changed between v5 and previous versions 
and see if their SDK provides any support/documentation/API for hooking 
it into a third party rendering engine...



I assume that the above reference to CG means nvidia Cg?


I assume so too.


3 Isn't an option because we want to integrate SpeedTree, not rewrite
it.  Our goal is to use SpeedTree not develop a copy.  Having seen the
source code, there is much more to it than porting geometry and
shaders.


Option 3 didn't imply rewriting SpeedTree. It's more akin to writing a 
new renderer for it. SpeedTree would do the simulation and whatever it 
does to generate the trees and their geometry, and you would take that 
geometry (or the description of the geometry, i.e. vertices, primitives, 
etc.) and copy/use them to OSG data structures to get them displayed as 
part of an OSG scene graph. As the poster of the quoted message 
mentioned, since OSG would do the rendering, you would need to 
reimplement the SpeedTree shaders in GLSL so that OSG could use them.


This is very different from rewriting SpeedTree... I hope you don't 
think SpeedTree only does rendering of the trees, it does much more than 
that, and in fact the more difficult parts are generating the trees from 
specifications and tree types, making them react to wind, etc. and these 
would still be done by SpeedTree. Only the last step, rendering itself, 
would need to be reimplemented in OSG.


Note that option 2 might be possible too, the osgNV nodekit provides 
support for Cg shaders in OSG, though it's been a while since I've heard 
any news about it so I don't know if it's up to date anymore or if the 
author(s) abandoned it in favor of OSG's built-in support for GLSL.


Sorry, apart from that I can't really help. As I mentioned, I've never 
used SpeedTree myself nor integrated it into an OSG-based app.


J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] SpeedTree Example for late version of OSG?

2009-10-27 Thread Wyatt Earp
I would like to integrated SpeedTree 5.0 into an osg application.  Having
searched the mailing list archives the most recent mention of a SpeedTree
example that I found was over a year ago.  Has anyone been using SpeedTree
with OSG and possibly put together an example that would show how to use
SpeedTree with a later version of OSG?

Wyatt
___
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