[osg-users] [osgPPU] Render lower Resolution with unitOut than wandow / fullscreen

2011-06-06 Thread Peter Wrobrl
Hi,

I would like to render my scene in a lower resolution than the viewport 
resolution, but want it stretched afterwards. When I scale the texture(s) that 
are attached to to the camera, e.g. half res, the render output is only half 
the size ( in x and y ) and placed in the lower left corner, and not stretched 
over the viewport.
Think that with this method:
unitOut - setInputTextureIndexForViewportReference( inputindex )

one can tell ppu which unit/texture is the reference scale for the output, but 
in my pipleine there is no viewport sized texture.

Is there another way to tell unitOut to scale its resulting texture to viewport 
size ?


Thank you!

Cheers,
ParticlePeter

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





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


Re: [osg-users] Looking at OSGExp and maya2osg (3dsmax and Maya export plugins)

2011-05-06 Thread Peter Wrobrl
Hi J-S, 

jumping in to say hello, and sorry that I coudn't answer your post earlier. I'm 
student, and as Javier mentioned my time is very limitted these days and for 
the next two months. At Holiday time I contribute frequently, and I think this 
won't cahnge  too soon. So for now this is it, I'll join discussions about 
topics regarding Animation/Character Export and the current Polygon Export.

Cheers,
PP

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





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


Re: [osg-users] Looking at OSGExp and maya2osg (3dsmax and Maya export plugins)

2011-05-06 Thread Peter Wrobrl
Hi,

about the crash, I tried the file and it crashes on my system as well in 
release mode. The polygon Export creates a Log nemad Maya2OSG_Write.log, stored 
in the same directory of exported file. This might help a little. It exports 
the mesh as geometry, but than creashes. I guss in Shading stage, hope this 
helps a little, but can't dive deeper.

Thank you!

Cheers,
Peter

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





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


[osg-users] [build] Build Issues Trunk 2.9.12 and GL3

2011-04-01 Thread Peter Wrobrl
Hi,

there are Build Issues with the current Trunk and the GL3 Option

osgText does not build due to glPushAttrib / glPopAttrib in 
Text::renderWithDelayedDepthWrites. 
osgSim OverlayNode Serializer uses Deprecated glTexEnv GL_DECAL Enum.




Fix for Text::renderWithDelayedDepthWrites:

void Text::renderWithDelayedDepthWrites(osg::State state, const osg::Vec4 
colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE)  !defined(OSG_GLES2_AVAILABLE)  
!defined(OSG_GL3_AVAILABLE)
glPushAttrib( _enableDepthWrites ? (GL_COLOR_BUFFER_BIT | 
GL_DEPTH_BUFFER_BIT) : GL_DEPTH_BUFFER_BIT);
// Render to color buffer without writing to depth buffer.
glDepthMask(GL_FALSE);
drawTextWithBackdrop(state,colorMultiplier);

// Render to depth buffer if depth writes requested.
if( _enableDepthWrites )
{
glDepthMask(GL_TRUE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
drawTextWithBackdrop(state,colorMultiplier);
}
glPopAttrib();

#else
OSG_NOTICE  Warning: Text::renderWithDelayedDepthWrites(..) not 
implemented.  std::endl ;
#endif
}



Fix for osgSim::OverlayNode Serializer ( not sure if this one is sufficient, 
but works )

#include osgSim/OverlayNode
#include osgDB/ObjectWrapper
#include osgDB/InputStream
#include osgDB/OutputStream

REGISTER_OBJECT_WRAPPER( osgSim_OverlayNode,
 new osgSim::OverlayNode,
 osgSim::OverlayNode,
 osg::Object osg::Node osg::Group osgSim::OverlayNode 
)
{
BEGIN_ENUM_SERIALIZER( OverlayTechnique, 
OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY );
ADD_ENUM_VALUE( OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY );
ADD_ENUM_VALUE( VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY );
ADD_ENUM_VALUE( VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY );
END_ENUM_SERIALIZER();  // _overlayTechnique

ADD_OBJECT_SERIALIZER( OverlaySubgraph, osg::Node, NULL );  // 
_overlaySubgraph
#if !defined(OSG_GLES1_AVAILABLE)  !defined(OSG_GLES2_AVAILABLE)  
!defined(OSG_GL3_AVAILABLE)
ADD_GLENUM_SERIALIZER( TexEnvMode, GLenum, GL_DECAL );  // _texEnvMode
#endif
ADD_UINT_SERIALIZER( OverlayTextureUnit, 1 );  // _textureUnit
ADD_UINT_SERIALIZER( OverlayTextureSizeHint, 1024 );  // _textureSizeHint
ADD_VEC4_SERIALIZER( OverlayClearColor, osg::Vec4() );  // 
_overlayClearColor
ADD_BOOL_SERIALIZER( ContinuousUpdate, false );  // _continuousUpdate
ADD_DOUBLE_SERIALIZER( OverlayBaseHeight, -100.0 );  // _overlayBaseHeight
}




Moreover, think it would be a good Idea to add an Option to CMakeLists whether 
to build osgQT, as QT includes GL.h. No fix for that :-)



For completeness, this Thread explains how to build OSG with GL3 option on 
Windows ( tweak of osg/GL , tweak of CMakeLists.txt ) :
http://forum.openscenegraph.org/viewtopic.php?t=7322




Cheers,
ParticlePeter

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





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


Re: [osg-users] [build] Build Issues Trunk 2.9.12 and GL3

2011-04-01 Thread Peter Wrobrl
Hi,

hm ... current Trunk Version is 2.9.9 after it was 2.9.11 already ???
My mistake with the topic ... ?

Cheers,
Peter

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





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


Re: [osg-users] osg::Geometry and GL_PRIMITVE_RESTART

2011-03-31 Thread Peter Wrobrl
Hi,

I found this sceniX forum post

http://developer.nvidia.com/forums/index.php?showtopic=5357pid=16495mode=threadedstart=

and wonder if this is akin to the osg approach.
If so, how can osg be extended in the right way so that currently not supported 
GL3 features are accessible ?
 
Thank you!

Cheers,
Peter

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





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


Re: [osg-users] osg::Geometry and GL_PRIMITVE_RESTART

2011-03-31 Thread Peter Wrobrl
Thank you very much, that helps a lot in understanding. So I assume there is no 
example for this one ...

Anyway, many thanks.

Cheers,
Peter

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





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


[osg-users] osg::Geometry and GL_PRIMITVE_RESTART

2011-03-28 Thread Peter Wrobrl
Hi,

Topics like GL Funktions in osg have been discussed in other posts, but still 
not getting the essence.
I wonder which steps are required to make e.g. GL_PRIMITIVE_RESTART work within 
osg ?

Could you point me to an example, more elaborated than osgTeapot ?


Thank you!

Cheers,
Peter

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





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


[osg-users] Error: 0xc0150002 Win7 x64, VS2010, osg 2.9.11 current Trunk, wrong dependency in osgDBd.dll Manifest ?

2011-02-12 Thread Peter Wrobrl
Hi,

this is an information and sollution hack about a strange issue with the Debug 
build from source of SVN Trunk 2.9.11 throwing the error code 0xc0150002

I confirmed this on two different Win7 x64 machines, any Debug example and my 
osg apps linked to Debug libs throw this error.
Traced it down through Dependency Walker and sxsTrace to osgDBd.dll, telling me 
that the side-by-side configuration is incorrect.

I also build the 2.8.3 stable from source on the same systems, the error is not 
present there and all Debug apps are running.

So I compared the Manifests of both dlls ( replace _ with Space, ( with 
less than, ) with greater than ):

osgDBd.dll 2.8.3 Manifest:
(?xml_version=1.0_encoding=UTF-8_standalone=yes?)
(assembly_xmlns=urn:schemas-microsoft-com:asm.v1_manifestVersion=1.0)
__(trustInfo_xmlns=urn:schemas-microsoft-com:asm.v3)
(security)
__(requestedPrivileges)
(requestedExecutionLevel_level=asInvoker_uiAccess=false)(/requestedExecutionLevel)
__(/requestedPrivileges)
(/security)
__(/trustInfo)
(/assembly)

osgDBd.dll 2.9.11 Manifest:
(?xml_version=1.0_encoding=UTF-8_standalone=yes?)
(assembly_xmlns=urn:schemas-microsoft-com:asm.v1_manifestVersion=1.0)
__(trustInfo_xmlns=urn:schemas-microsoft-com:asm.v3)
(security)
__(requestedPrivileges)
(requestedExecutionLevel_level=asInvoker_uiAccess=false)(/requestedExecutionLevel)
__(/requestedPrivileges)
(/security)
__(/trustInfo)
__(dependency)
(dependentAssembly)
__(assemblyIdentity_type=win32_name=Microsoft.VC90.DebugCRT_version=9.0.21022.8_processorArchitecture=amd64_publicKeyToken=1fc8b3b9a1e18e3b)(/assemblyIdentity)
(/dependentAssembly)
__(/dependency)
(/assembly)

Notice that the 2.8.3 dll has no dependencies defined, the 2.9.11 has and this 
results in my problem.
Does anybody know what the issue is, and how to fix it the right way ?

My Hack to fix it:
I removed the dependency entry from the 2.9.11 dll manifest and it works.

Detailed steps for those who are facing the same issue:
Backup osgDBd.dll
drag and drop osgDBd.dll on Visual Studio
Open RT_MANIFEST in the Document View
DoubleClick the entry bellow ( my version: 2 [English (United States)] )
Copy the Hex content of the newly oppened document RCDATA into a Text editor 
that can read Hex Data
Remove lines ( including ) dependency to /dependency
Copy and paste back to RCDATA
Save

Done, all Debug apps working again.

Cheers,
ParticlePeter

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





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


[osg-users] osgAnimation deform TangentSpace ( osgUtil::TangentSpaceGenerator ) for BumpMapping

2010-12-18 Thread Peter Wrobrl
Hi,

I have a Normal Map for an animated Character. To my understanding, I need to 
transfrom the Tangent and BiNormal which I got from 
osgUtil::TangentSpaceGenerator with the osgAnimation::RigTransform( 
Implementation ), otherwise Bump Mapping will not look correct. The 
RigTransform computeNormal method should do the job.

Is there a way to access RigTransfrom in RigGeometry and transform the 
additional VertexAttributes per update cycle ?
Any other Ideas how I could properly calculate the TangentSpace ?


Thank you!

Cheers,
ParticlePeter

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





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


Re: [osg-users] Curves/splines

2010-12-15 Thread Peter Wrobrl

pamakela wrote:
 Hi 
 
 
 I'd like to use curves, particularly simple 2d control point based splines to 
 drive variables of scene graph objects over time. I'd also like to use both 
 linear and cubic interpolated curves. So for example the curve could be sharp 
 sawtooth, a cubic curve with smooth knee/shoulder, etc. A smooth curve could 
 be used to control the fade-in or fade-out of a text object for example. 
 
 Is there a (fast) library for doing this? Or is there another approach for 
 doing this?
 
 
 Paavo


Yes, osgAnimation.

Cheers, ParticlePeter

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





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


Re: [osg-users] [osgPPU] Usage of osg::Uniform::Callback with osgPPU::ShaderAttribute ?

2010-12-09 Thread Peter Wrobrl
Hi,

well, this code is properly updating my Uniform: 
osg::Uniform * uniform = new osg::Uniform( Vector , osg::Vec4f( 0.0f , 0.0f , 
0.0f , 0.0f ) ) ;
uniform - setUpdateCallback( new UniformCallback ) ;
stateSet - addUniform( uniform ) ;

So the update call back does reach the Uniform.
My guess is, that you cannot attach the UniformUpdateCallback to an 
osgPPU::ShaderAttribute, as this one is derived from osg::Programm, but the 
UniformUpdateCallback is meant to be attached to an osg::Uniform.

Cheers,
ParticlePeter

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





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


Re: [osg-users] Please test svn/trunk in prep for 2.9.10 dev release

2010-12-07 Thread Peter Wrobrl
Hi,

Issues with osgWidget
My System: Widows 7 x64, VS2010
Building for x64
osgWidget couldn't build ( Input.cpp ) due to: 'inserter' : is not a member of 
'std'
fixed that with #include iterator

Cheers,
ParticlePeter

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





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



Re: [osg-users] Please test svn/trunk in prep for 2.9.10 dev release

2010-12-07 Thread Peter Wrobrl
Hi Robert, 

I don't think that this is a valid fix, just mentioned what worked for me and 
my system. File attached.

Cheers,
ParticlePeter

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




Attachments: 
http://forum.openscenegraph.org//files/input_582.cpp


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


Re: [osg-users] osgAnimation : feeding MorphGeometry into RigGeometry

2010-12-06 Thread Peter Wrobrl
Thanks for your help, this will do for now.

However, I would be very interested that this functionality becomes part of 
osgAnimation, as I am writing on a maya osg exporter. I'll try to look deeper 
into osgAnimation functionality. The opossite case, morphing two RigGeometries 
with different Skelettons, is also very usefull. 

So just for my understanding, a MorphCallback gets attached to  a Geode which 
holds MorphGeometry.
Which function searches the Drawables, to link them with the MorphCallback ?
Could it be extend it, so that it would also look inside children of 
RigGeometry ?

Got your point with the MorphChannelNames.


Thank you!

Cheers,
ParticlePeter

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





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


[osg-users] osgAnimation : feeding MorphGeometry into RigGeometry

2010-12-05 Thread Peter Wrobrl
Hi,

I'm feeding a MorphGeometry into RigGeometry, to achieve Character Animation 
with Facial Morphing. The system works, but it is unclear where to attach the 
osgAnimation::UpdateMorph.

Two cases ( Source Attached ) :

1.) Animation for UpdateMorph does not work
GroupRoot ( with BasicAnimtionManager and an animation )
--Skeleton
Geode ( with UpdateMorph )
--RigGeometry
MorphGeometry ( Morph Base )
--Geometry ( Morph Target )

2.) Animation Works, but skinned and unskinned ( both morphing ) is Visible
GroupRoot ( with BasicAnimtionManager and an animation )
--Skeleton
GeodeRig
--RigGeometry
MorphGeometry ( Instanced bellow )
--GeodeMorph ( with UpdateMorph )
MorphGeometry ( Morph Base )
--Geometry ( Morph Target )

I cannot turn off the NodeMask for the GeodeMorph, as then the UpdateMorph does 
not calculate.

So how can I attach the UpdateMorph so that the skin gets morphed ( before 
Bone Influence ) and only one geometry been visible ?

Btw, Cedric, should a FloatLinearChannel not be rather named morph than 0 ?
Moreover, I'm writing out the file, there are issues in reading it back with 
the osganimationviewer.
I'm using SVN Version 2.9.10


Thank you!

Cheers,
ParticlePeter

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




Attachments: 
http://forum.openscenegraph.org//files/osgmorphskin_102.zip


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


Re: [osg-users] Blur effect on a dynamic scene

2010-12-05 Thread Peter Wrobrl
Hi,

Kim is right, check out osgPPU, its straigth forward to use, and there is an 
example doing exactly what you want, bluring on key press.

Cheers,
ParticlePeter

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





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


Re: [osg-users] [build] How to properly use the OSG_GL3_AVAILABLE CMake option?

2010-11-25 Thread Peter Wrobrl
Hi,
I am having exactly the same issues, please could you post your suggestion how 
to fix this ?


Thank you!

Cheers,
ParticlePeter

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





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


[osg-users] How to avoid / minimize overdraw of osg::PrimitiveSet::POINTS

2010-11-24 Thread Peter Wrobrl
Hi,

this is rather a technique question then related to an osg feature.
I create a VBO from lot of Points ( ( 50-100 ) ^ 3 ) in the shape of a cube. I 
create them with three nested loops, one per Axis, so that first I get a line 
of Points in x-Direction, then draw the next lines to shape the xy plane, and 
finally draw the volume in z direction with the next xy point planes.Rotating 
arround this cube with the camera, my Frame Rate drops significantly, when the 
Points get drawn from Back to front due to Overdraw.
I can't just flip the whole entity in 90 degree steps dependent on the camera 
position as the Points have different Vertex Colors set, so one would nottice 
the flipping.

How can I build an efficient structure so that those points get always drawn 
from Front to Back ? Are there any helpful utilities for sorting, or maybe 
other Tricks ?
 

Thank you!

Cheers,
ParticlePeter

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





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


Re: [osg-users] How to avoid / minimize overdraw of osg::PrimitiveSet::POINTS

2010-11-24 Thread Peter Wrobrl
Hi,

do you assume, that I have only six Planes of Points, one per Cube side ? 
That's not the case, its a filled Volume with points. 
Or do you suggest to built 6 Pyramids of points one per Cube side ?

Thank you!

Cheers,
ParticlePeter

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





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


[osg-users] [osgPPU] Usage of osg::Uniform::Callback with osgPPU::ShaderAttribute ?

2010-11-23 Thread Peter Wrobrl
Hi,

I have an osg::Uniform::Callback which is working fine with osg::Programm, but 
I don't get it working with osg::ShaderAttribute.
The Uniform Value used in Constructor is correctly passed to my Shader, but the 
Values don't get update, as if the UpdateVisitor would not reach the Uniform.

osgPPU::ShaderAttribute * shaderAttribute = new osgPPU::ShaderAttribute() ;
osg::Uniform * uniform = new osg::Uniform( Color , osg::Vec4f( 1.0f , 0.0f , 
0.0f , 1.0f ) ) ;
uniform - setUpdateCallback( new UniformCallback ) ;
shaderAttribute - add( uniform ) ;

UniformCallback is derived from osg::Uniform::Callback

While this code is working ( at another place )
osg::Uniform * uniform = new osg::Uniform( Vector , osg::Vec4f( 0.0f , 0.0f , 
0.0f , 0.0f ) ) ;
uniform - setUpdateCallback( new UniformCallback ) ;
stateSet - addUniform( uniform ) ;

What do I miss ?


Thank you!

Cheers,
ParticlePeter

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





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


Re: [osg-users] Multitexture Issue in GLSL Fragment Shader

2010-10-21 Thread Peter Wrobrl
Hi,

yes, it should use texture 0, but how do I specify this ? The 1 in this code 
line :
stateSet - addUniform( new osg::Uniform( osg::Uniform::SAMPLER_2D , 
stTexture , 1 ) ) ; 

does not choos a texture, but sets the number of elemets in the uniform ( one 
sampler2D ).

The texture unit association happens ( to my understanding ) with this :
stateSet - setTextureAttributeAndModes( 1 , projectionTexture , 
osg::StateAttribute::ON ) ;

But I can't do this for texture 0 ( stTexture ) as it is defined inside the 
.osg file.

So basically the question is, how to assotiate a sampler2D uniform with a 
certain texture Unit ( from an .osg file ) ?



Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Multitexture Issue in GLSL Fragment Shader

2010-10-21 Thread Peter Wrobrl
Figured it out finally.

Need to use :
stateSet - addUniform( new osg::Uniform( stTexture , 0 ) ) ;
stateSet - setTextureAttributeAndModes( 1 , projTexture , 
osg::StateAttribute::ON ) ;
stateSet - addUniform( new osg::Uniform( projectionTexture , 1 ) ) ;

Instead of :
stateSet - addUniform( new osg::Uniform( osg::Uniform::SAMPLER_2D , 
stTexture , 1 ) ) ;
stateSet - setTextureAttributeAndModes( 1 , projTexture , 
osg::StateAttribute::ON ) ;
stateSet - addUniform( new osg::Uniform( osg::Uniform::SAMPLER_2D , 
projectionTexture , 1 ) ) ;


Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


Re: [osg-users] Multitexture Issue in GLSL Fragment Shader

2010-10-21 Thread Peter Wrobrl
Hi,

that was classic, thx Fredric :-)

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


[osg-users] Multitexture Issue in GLSL Fragment Shader

2010-10-20 Thread Peter Wrobrl
Hi,

Am following osgstereomatch example, but can't find my mistake.
Trying to use two Textures in a Fragment Shader, with one set of geometry 
texCoordArray and one with Screen Projected Coordinates.

I include an .osg file in my programm which has properly textured geometry. The 
.osg file has following lines :

Geometry {
 DataVariance STATIC
 StateSet {
   rendering_hint DEFAULT_BIN
   renderBinMode INHERIT
textureUnit 0 {
GL_TEXTURE_2D ON
Texture2D {
name  ... 
file  ... 
...
}
TexEnv {
mode REPLACE
}

Its bound to texture Unit 0 to a StateSet attached to my Geometry. When render 
just this file, everything is as expected ( the geometry has ST Coords ).

Now I tweak the rendering, I want to project ( camera projection ) another 
texture ontop of this loaded and textured file.
The SG Structer inside this .osg file is simply : 
Group  - Geode - Geometry
So first I generate a StateSet for my Group Node and just add a sampler 2D 
Uniform, so that the original fileTexture ( should be ) is available in my 
Shader :
stateSet - addUniform( new osg::Uniform( osg::Uniform::SAMPLER_2D , 
stTexture , 1 ) ) ;

Then I add the projectionTexture to my StateSet into Texture Unit 1 and add the 
corresponding Uniform :
stateSet - setTextureAttributeAndModes( 1 , projTexture , 
osg::StateAttribute::ON ) ;
stateSet - addUniform( new osg::Uniform( osg::Uniform::SAMPLER_2D , 
projectionTexture , 1 ) ) ;

In my GLSL Fragment Program I Define :
in  vec2texCoord ;  
// Interpolated gl_MultiTexCoord0.st
const   vec2screenRes = ... ;   // Screen 
Resolution
uniform sampler2D   stTexture ;
uniform sampler2D   projectionTexture ;

and in Main Function :

vec4 color1 = texture2D( stTexture , texCoord ) ;
vec4 color2 = texture2D( projectionTexture , gl_FragCoord.st / 
screenRes ) ;// Projet based on Fragment Coordinate

gl_FragColor = mix( color1 , color2 , mixValue ) ;

The result is, that stTexture gets also projected onto the Geometry, not using 
the geometry texCoordArray, but the Fragment Coordinates.
Also the mixValue doesn't work as expected. Looks like both the Textures are 
Projected and mixed uniformly with same weigth.
What am I missing, or doing wromg ?
I feel that I don't associate the stTexture Sampler with the right texture 
unit, but how can I do it with an loaded .osg file ?


Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


Re: [osg-users] Extract ModelView Projection Matrix for GLSL Program version 150 and higher

2010-09-30 Thread Peter Wrobrl
Hi,

To Wojciech, that would be a workaround, but not a ( correct ) solution, right ?

To Robert, nice, this was my hoped-for answer, will try building right away.

Thank you!

Cheers,
ParticlePeter

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





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


[osg-users] Extract ModelView Projection Matrix for GLSL Program version 150 and higher

2010-09-29 Thread Peter Wrobrl
Hi,

gl_ModelViewProjectionMatrix and ftransform() are deprecated since GLSL Version 
120 ( but still working ), in Version 150 not working at all.
Is there a straight forward way to extract the current ModelView and Projection 
Matrices ( e.g. from StateSet ? ), without having to pass around the Camera 
through the SG, or extract osg::Transform World Matrix ?

Moreover, gl_Vertex is depreciated as well, so how to create a VBO ? Is it 
possible to use only VertexAttribArray, without VertexArray, NormalArray, etc. 
? 


Thank you!

Cheers,
ParticlePeter

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





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


[osg-users] osgAnimation : keyframe osg::Switch

2010-07-07 Thread Peter Wrobrl
Hi,

i need to switch on and off objects through an animation clip. The Idea is to 
use a switch node, but there is no boolean interpolator type, and also no 
keyword name for this kind of channel if I'm not wrong.

More over my constraint is to use osg 2.8.3 as it is, and I need to write out 
the animation data into an osg file.

How can this be accomplished ? 

Thank you!

Cheers,
PP

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





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


Re: [osg-users] Usage of Vertex Buffer Objects

2010-06-16 Thread Peter Wrobrl
Hi, thanks for your answer.


robertosfield wrote:
 ... no use of the
 deprecated vertex indicies arrays that osg::Geometry support for
 backwards compatibility


I don't think that this also includes Index Buffer Objects. Do those get 
specified with Geometry::setVertexAttribArray ? Thank you.

Cheers, ParticlePeter

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





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


Re: [osg-users] Usage of Vertex Buffer Objects

2010-06-16 Thread Peter Wrobrl
Hi,

Think I'm talking about glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ... )

http://www.opengl.org/wiki/Vertex_Buffer_Objects

 
 I suggest that you make a VBO for your vertices (vertex, normals, texcoords, 
 perhaps other things) and another VBO for indices (IBO).
 


Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Usage of Vertex Buffer Objects

2010-06-16 Thread Peter Wrobrl
Hi,

sorry, the process is still not clear for me. So just to summerize: I create 
arrays for Vertices, Normals and UVs, all of them have the same length and I 
set them with Geometry::Vertex/Normal/TexCoordArray.
The Triangles I want to render share some of these VertexData. So I would like 
to pass an Index Array  ( I guess the EBO ), which builds the triangles from 
the Index Array. How do I specify this Index Array ?

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Usage of Vertex Buffer Objects

2010-06-16 Thread Peter Wrobrl
Hi, thank you for all your help. I found that what I was looking for in the 
osggeometry example, its a property of PrimitveSet:

polyGeom-addPrimitiveSet(new 
osg::DrawElementsUShort(osg::PrimitiveSet::QUADS,numIndices,myIndices));

myIndicies is the IndexArray which I need to pass.

Thank you!

Cheers,
ParticlePeter

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





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


Re: [osg-users] osganimation skinning

2010-06-16 Thread Peter Wrobrl
Hi,


Emy wrote:
 And also why you think using hardware is a better start than software. 


Well, you'll find the skinning shader under osgAnimation. You should be able to 
tweak it, the input for linear palette blending should be the same as for dq. 
So there is no need to extend or derive from any osgAnimation class.

Cheers, ParticlePeter

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





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


[osg-users] Usage of Vertex Buffer Objects

2010-06-15 Thread Peter Wrobrl
Hi, I have several questions regarding osg and the usage of VBOs.

1.) How do I ensure usage of vertex buffer object ? When I set osg::Geometry 
setUseVertexBufferObject to true does this allways create a VBO from the 
structure I passed to osg::Geometry ? E.G. In the OSG Quick Start Guide by Paul 
Martz we create a Quad, with four Verts, four Colors and one Normal. Setting 
osg::Geometry setUseVertexBufferObject to true, would this create convert the 
data to four Verts/Colors/Normals ?

2.) A Textured Cube has 8 Vertices and at least 12 UVs. How to create this 
geometry as VBO ? The right Way would be to duplicate Vertices, to have as many 
as UVs, but how do I create this structure and put this into a geometry ? Same 
approach as above from the Quick Start guide ?

3.) Lets say I have a geometry like a human, with multiple UV Shells ( UV 
islands, the usual approach to texture a human ), e.g. Head, Chest, Arms, Legs. 
How and where do I specifiy these arrays and do I need a geometry per array ? I 
guess I cannot set multiple Vertex/Normal/UV Arrays into one geometry, so 
should I stich all those arrays and pass it as one ? But this would mean that I 
cannot use Triangle Strips, wouldn't it ?

4.) What is the Usage of osg::VertexBufferObject ? Its not a Drawable, and 
osg::Geometry has no setVertexBufferObject method. It can be set into a 
osg::Array, where the size of each element is constraint to enums. If I 
understood VBOs right I can define any Data of any size as one Array element, 
e.g. Vertex, Normal, and UV which would be 8 floats. There is no option for 8 
floats, so isn't this a limitation ?
 
Thanks for any help and advice

Cheers, ParticlePeter

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





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


Re: [osg-users] osgAnimation speed control

2010-05-27 Thread Peter Wrobrl
Hi,

Thx, but if I understand the simuation time right, it is a global value for the 
complete SG. I am seraching rather for individual Animation Control per 
Animation Manager.
I import different Characters into the osg environment, each of them has its 
own AnimationManager and I would like to control the animation speed separatly 
on per Character baseis.

Thank you!

Cheers,
Peter

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





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


[osg-users] osg::Refererenced issue with osgAnimation : writing UniqueIDs at _refCount of min 2

2010-04-07 Thread Peter Wrobrl
Hi,

The FileWrite Systems puts an entry of UniqueIds into osg files only if the 
_refCount of a referenced object is equal or greater then 2. Those Ids are 
required in osgAnimation Skinning System, so that the linkVisitor can link 
bones, skeletton and rigGeomtry.

Usually all the bones in a skeletton have a _refCount of 1, if their 
ref_pointer have been destroyed, so no IDs in file.

Is there any clean sollution to this issue, or do I have to traverse the scene 
graphe and increase the _refCounter manually before writting out ?

Thank you!

Cheers,
PP !!!

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





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


[osg-users] osgAnimation : 02AE6A28 RigTransformSoftware::UniqBoneSetVertexSet no bones found

2010-04-05 Thread Peter Wrobrl
Hi,

but how can this be a version issue ? I have created both the osg files with 
OpenSceneGraph 2.9.6.

Figured out something, those Unique_Ids get written only if ref_ptr is used 
instead of normal pointers ( for e.g. BasicAnimationManager ), can this be this 
true ?

I will try your trunk.

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


Re: [osg-users] Suggesting Forum Category and Wiki for osgAnimation

2010-04-05 Thread Peter Wrobrl
Hi,

Uh, I did not know that this one can be extended by users. How can I add stuff 
there, and who gives me the permission to do this ?

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


[osg-users] osgAnimation : 02AE6A28 RigTransformSoftware::UniqBoneSetVertexSet no bones found

2010-04-05 Thread Peter Wrobrl
Hi,

The change in the bone class was on my feature request list for osgAnimation 
:-) as its quite confortable to get the inverseBindMatrix from Maya, especially 
if the Charecter is animated and not in bindPose.

But in any case, the issue that I have is still there with your trunk. I 
created a minimal scengraph to demostrate missing UniqueIDs. Notice that if 
animationManager is not a ref_ptr, the UniqueIDs don't get written into files. 
The same is true for skeletton and bone. With unique IDs I get no error. 
Isn't this wrong behaviour ?


// UniqueIDs
// --
#include osgDB/WriteFile
#include osgAnimation/BasicAnimationManager

int main ( int argc, char * argv[] )
{
osg::Group * scene = new osg::Group ;
osg::ref_ptr osgAnimation::BasicAnimationManager  manager = new 
osgAnimation::BasicAnimationManager ;
scene - setUpdateCallback( manager.get() ) ;
osgDB::writeNodeFile(  * (  scene  ) , osgAnimationSkinning.osg  )  ;
return 0 ;
}


// No UniqueIDs
// --
#include osgDB/WriteFile
#include osgAnimation/BasicAnimationManager

int main ( int argc, char * argv[] )
{
osg::Group * scene = new osg::Group ;
osgAnimation::BasicAnimationManager * manager = new 
osgAnimation::BasicAnimationManager ;
scene - setUpdateCallback( manager ) ;
osgDB::writeNodeFile(  * (  scene  ) , osgAnimationSkinning.osg  )  ;
return 0 ;
}

Thank you!

Cheers, PP

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





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


[osg-users] osgAnimation : 02AE6A28 RigTransformSoftware::UniqBoneSetVertexSet no bones found

2010-04-04 Thread Peter Wrobrl
Hi,

I'm writing a Maya to osg Exporter, so I need to write Animation and Skinning 
into osg files. I examined the example osgAnimationSkinning and tweaked it so 
that it writes an osg file as well.
My osg files look quite similar to that from osgAnimationSkinning ( both 
attached ) , but still I'm getting this error when running with 
osgAnimationViewer :

02AE6A28 RigTransformSoftware::UniqBoneSetVertexSet no bones found

repetedly ( 02AE6A28 seems to be the timer ), while the osgAnimationSkinning 
file works fine with this message :

Skinning.osg
LinkVisitor links 0 for root
LinkVisitor links 1 for right0
LinkVisitor links 1 for right1
uniq groups 3 for
Play

The only difference I see between the files is that my osg entities omit 
UniqueID entries ( e.g. UniqueID Bone_4 ). I can't find the piece of code in 
osgAnimationSkining, which writes those UniqueIDs into an osg file, and I'm 
also not sure if this is my error source ( my only guess ).

How can get those IDs into my file ( please point me to the code in 
osgAnimationSkining ), or how can I fix my Problem ?

Are there some other simple Examples about osgAnimation skinning ? 

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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




Attachments: 
http://forum.openscenegraph.org//files/osganimationskinning_911.osg
http://forum.openscenegraph.org//files/myskinning_252.osg


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


[osg-users] Suggesting Forum Category and Wiki for osgAnimation

2010-04-04 Thread Peter Wrobrl
Hi,

Would like to suggest an own Categry for osgAnimation in this Forum, and also a 
user driven Wiki. Examples and Documentation ( if any ) are quite tough to 
read, so community could share experience, explain functionality, post examples.

If this already exists, I couldn't find it, so please point me there.  

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


[osg-users] osgAnimation, possible to play multiple animations ?

2010-02-26 Thread Peter Wrobrl
Hi,

I would like to crossfade Animations, maybe even mix certain channels of 
multiple Animations. Is this possible ? The weight attribute of animation and 
channel seems to be made for this purpose.

The osganimationviewer stops an Animation befor it starts a new one. Reading 
its sourcecode, in particular the stop() and play() methods, the current 
animation does not get stopped befor a new animation gets started, but still 
only one animation gets played.

So, is it possibe to let run multiple animations within one manager at all ?

One more thing, is there any difference ( maybe in purpose ) between 
BasicAnimtionManager and AnimationManager ? Look pretty much the same ...

Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


[osg-users] How does a osg::Drawable::UpdateCallback Work ?

2009-12-05 Thread Peter Wrobrl
Hi,

I'm trying to set up an Update Callback in osg::Geometry to dynamically change 
the color of a vertex. I get no error, but my code is not evaluated ( cout in 
Callback is not printing ). I attached my Callback to osg::Geometry ( a simple 
Quad ) and setDataVariance( osg::Object::DYNAMIC ) ;


// Geometry Update Callback - Not Working //

class GeomCallback : public osg::Drawable::UpdateCallback
{
public :
GeomCallback() : _ramp( 0.0f ) {} ;

void operator()( osg::Node * node , osg::NodeVisitor * nodeVisitor )
{
std::cout  in Callback !  std::endl ;
osg::Geometry  * geom = dynamic_cast osg::Geometry  * ( node 
) ;
// geometry-getColorArray gives me an osg::Array, but I need a 
osg::Vec4Array
// so I try to cast it, don't know if this works, but get no 
error
osg::Vec4Array * cols = dynamic_cast osg::Vec4Array * ( geom 
- getColorArray() ) ;

// As Cols is my Pointer to the Vec4Array I should be able to 
assign different values
cols - assign( 0 , osg::Vec4f( 0.5f + 0.5f * sin( _ramp ) , 
0.0f , 0.0f , 1.0f ) ) ;
_ramp += 0.01f ;
}

private :
float _ramp ;

} ;


Thank you!

Cheers,
Peter

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





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


Re: [osg-users] How does a osg::Drawable::UpdateCallback Work ?

2009-12-05 Thread Peter Wrobrl
Hi,

to Paul:

 Did you accidentally leave display lists on?


Well, I set my Drawable to useVertexBufferObjects, which should overide 
useDisplayLists.
Btw, setting useDisplayLists( false ) throws a null Pointer Exception in 
threadex.c on my system.

To Skylarke:
Yes that was one problem, thx, but the expected is still not happening. At 
least the cout is printing now after I changed the method to update(). Any 
Ideas why its still not working ?


Thank you!

Cheers, searching for the Pivot of my Soul, PP !!!

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





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


Re: [osg-users] How does a osg::Drawable::UpdateCallback Work ?

2009-12-05 Thread Peter Wrobrl
Source Code, thx.

Cheers, searching for the Pivot of my Soul, PP !!!

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




Attachments: 
http://forum.openscenegraph.org//files/geom_callbackmain_392.cpp


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


Re: [osg-users] Export osgAnimation callbacks into osg files

2009-11-23 Thread Peter Wrobrl
Hi, and thanks for your fast answer.

To reconstruct my problem I take the osgAnimationNode Example and tweak its 
main, so that it writes an osg file instead of creating the viewer ( 
Attachment ).
When I open the osg file with an text editor, the UpdeteCallbacks are empty, 
and the file crashes the osganimationviewer with the error message: no 
osgAnimation::AnimationManagerBase found in the subgraph, no animations 
available 

Files that I export from Blender do have osgAnimation::BasicAnimationManager 
and keyframe data in the UpdateCallback Block.

I think the problem is, that in my case AnimtkUpdateCallback should be derived 
from osgAnimation::BasicAnimationManager insted of osg::NodeCallback, but I 
don't get it to work.

Could you tweak this file so that it works ? That would be a great help, thx.


Cheers, searching for Pivot of my Soul, PP !!! ( - ParticlePeter )

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



/*  -*-c++-*- 
 *  Copyright (C) 2008 Cedric Pinson morni...@plopbyte.net
 *
 * This library is open source and may be redistributed and/or modified under  
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * OpenSceneGraph Public License for more details.
*/

#include iostream
#include osg/Geometry
#include osg/Shape
#include osg/ShapeDrawable
#include osgViewer/Viewer
#include osgGA/TrackballManipulator
#include osg/MatrixTransform
#include osg/Material
#include osgAnimation/Sampler
#include osgDB/WriteFile
#include stdio.h

class AnimtkUpdateCallback : public osg::NodeCallback
{
public:
META_Object(osgAnimation, AnimtkUpdateCallback);

AnimtkUpdateCallback() 
{
_sampler = new osgAnimation::Vec3CubicBezierSampler;
_playing = false;
_lastUpdate = 0;
}
AnimtkUpdateCallback(const AnimtkUpdateCallback val, const osg::CopyOp 
copyop = osg::CopyOp::SHALLOW_COPY):
osg::Object(val, copyop),
osg::NodeCallback(val, copyop),
_sampler(val._sampler),
_startTime(val._startTime),
_currentTime(val._currentTime),
_playing(val._playing),
_lastUpdate(val._lastUpdate)
{
}

/** Callback method called by the NodeVisitor when visiting a node.*/
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{ 
if (nv-getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR  
nv-getFrameStamp()  
nv-getFrameStamp()-getFrameNumber() != _lastUpdate) {

_lastUpdate = nv-getFrameStamp()-getFrameNumber();
_currentTime = osg::Timer::instance()-tick();

if (_playing  _sampler.get()  _sampler-getKeyframeContainer()) 
{
osg::MatrixTransform* transform = 
dynamic_castosg::MatrixTransform*(node);
if (transform) {
osg::Vec3 result;
float t = osg::Timer::instance()-delta_s(_startTime, 
_currentTime);
float duration = _sampler-getEndTime() - 
_sampler-getStartTime();
t = fmod(t, duration);
t += _sampler-getStartTime();
_sampler-getValueAt(t, result);
transform-setMatrix(osg::Matrix::translate(result));
}
}
}
// note, callback is responsible for scenegraph traversal so
// they must call traverse(node,nv) to ensure that the
// scene graph subtree (and associated callbacks) are traversed.
traverse(node,nv);
}

void start() { _startTime = osg::Timer::instance()-tick(); _currentTime = 
_startTime; _playing = true;}
void stop() { _currentTime = _startTime; _playing = false;}

osg::ref_ptrosgAnimation::Vec3CubicBezierSampler _sampler;
osg::Timer_t _startTime;
osg::Timer_t _currentTime;
bool _playing;
int _lastUpdate;
};


class AnimtkStateSetUpdateCallback : public osg::StateSet::Callback
{
public:
META_Object(osgAnimation, AnimtkStateSetUpdateCallback);

AnimtkStateSetUpdateCallback() 
{
_sampler = new osgAnimation::Vec4LinearSampler;
_playing = false;
_lastUpdate = 0;
}

AnimtkStateSetUpdateCallback(const AnimtkStateSetUpdateCallback val, const 
osg::CopyOp copyop = osg::CopyOp::SHALLOW_COPY):
osg::Object(val, copyop),
osg::StateSet::Callback(val, copyop),
_sampler(val._sampler),
_startTime(val._startTime),
_currentTime(val._currentTime),
_playing(val._playing),
_lastUpdate(val._lastUpdate)
{
}

/** Callback method called by the