Re: [osg-users] dotosg wrappers not thread safe

2012-06-04 Thread Mikhail I. Izmestev

Hi,

Here is code to reproduce crash:


#include 
#include 
#include 
#include 

static OpenThreads::Condition s_cond;
static OpenThreads::Mutex s_mtx;

class ReadThread : public OpenThreads::Thread
{
public:
  ReadThread() {}

  void run()
  {
{
  OpenThreads::ScopedLock lock(s_mtx);
  s_cond.wait(&s_mtx);
}
osg::ref_ptr node = osgDB::readNodeFile("cow.osg");
  }
};

int main()
{
  ReadThread t1, t2;
  t1.start();
  t2.start();

//  OpenThreads::Thread::microSleep(500);

  {
OpenThreads::ScopedLock lock(s_mtx);
s_cond.broadcast();
  }

  t1.join();
  t2.join();
  return 0;
}


To reproduce you can use this script:

#!/usr/bin/env bash

while(true); do
./test
done


But while testing fix I have new crash at:
ntdll!RtlReportCriticalFailure+0x62
ntdll!RtlpReportHeapFailure+0x26
ntdll!RtlpHeapHandleError+0x12
ntdll!RtlpLogHeapFailure+0xa4
ntdll!RtlpAnalyzeHeapFailure+0x3a8
ntdll!RtlpFreeHeap+0x141f
ntdll!RtlFreeHeap+0x1a6
kernel32!HeapFree+0xa
MSVCR90!free+0x1c
MSVCP90!std::basic_string,std::allocator
MSVCP90!std::basic_string,std::allocator
MSVCP90!std::operator+,std::allocator
osg92_osgDB!osgDB::Registry::createLibraryNameForExtension+0x34b
osg92_osgDB!osgDB::Registry::createLibraryNameForFile+0x42
osg92_osgDB!osgDB::Registry::read+0x1608
osg92_osgDB!osgDB::Registry::readImplementation+0x34c
osg92_osgDB!osgDB::Registry::readNodeImplementation+0x6a
osg92_osgDB!osgDB::Registry::readNode+0xfc
osg92_osgDB!osgDB::readNodeFile+0x4e
dotosgcrash!ReadThread::run+0x79

code:
std::string Registry::createLibraryNameForExtension(const std::string& ext)
{
std::string lowercase_ext;
for(std::string::const_iterator sitr=ext.begin();
sitr!=ext.end();
++sitr)
{
lowercase_ext.push_back(tolower(*sitr));
}

ExtensionAliasMap::iterator itr=_extAliasMap.find(lowercase_ext);
if (itr!=_extAliasMap.end() && ext != itr->second) return 
createLibraryNameForExtension(itr->second);


#if defined(OSG_JAVA_BUILD)
static std::string prepend = 
std::string("osgPlugins-")+std::string(osgGetVersion())+std::string("/java");

#else
static std::string prepend = 
std::string("osgPlugins-")+std::string(osgGetVersion())+std::string("/");

#endif
[..]

same design:
static std::string prepend = 
std::string("osgPlugins-")+std::string(osgGetVersion())+std::string("/");


Mikhail.

04.06.2012 13:17, Mikhail I. Izmestev написал:

Hi Robert,

It is hard to reproduce this problem (as any thread safety problem) in
same state as previous.

I have another crash with same problem at:
ntdll!RtlEnterCriticalSection+0x6
ot12_OpenThreads!OpenThreads::Mutex::lock+0xe
osgdb_deprecated_osg!initGLNames+0x66
osgdb_deprecated_osg!StateSet_readLocalData+0x4f
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x9eb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x28
osgdb_deprecated_osg!Node_readLocalData+0x349
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
osgdb_osg!OSGReaderWriter::readNode+0xfe
osgdb_osg!OSGReaderWriter::readNode+0x31c
osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28
osg80_osgDB!osgDB::Registry::read+0x5e4
osg80_osgDB!osgDB::Registry::readImplementation+0x34c
osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a
osg80_osgDB!osgDB::Registry::readNode+0xfc
osg80_osgDB!osgDB::readNodeFile+0x4e

crashed code:
int Mutex::lock() {
Win32MutexPrivateData *pd =
static_cast(_prvData);

#ifdef USE_CRITICAL_SECTION

// Block until we can take this lock.
EnterCriticalSection( &(pd->_cs) );  CRASH HERE

return 0;
[...]

pd->_cs == NULL

in this case problem at
void initGLNames()
{
static bool first_time = true;
if (!first_time) return;

static OpenThreads::Mutex s_initGLNames;
OpenThreads::ScopedLock lock(s_initGLNames);

[...]

There is lot of other places with same design:
AnimationPath.cpp:201: static osg::ref_ptr s_path =
new osg::AnimationPath;
CoordinateSystemNode.cpp:48: static ref_ptr
s_ellipsoidModel = new EllipsoidModel;
Drawable.cpp:30: static ref_ptr s_drawstate = new osg::StateSet;
Node.cpp:77: static ref_ptr s_drawstate = new osg::StateSet;
Node.cpp:85: static ref_ptr s_nodecallback = new
osg::NodeCallback;
NodeCallback.cpp:31: static osg::ref_ptr s_nc = new
NodeCallback;
OccluderNode.cpp:30: static ref_ptr s_occluder =
new ConvexPlanarOccluder;
Sequence.cpp:26:static bool Sequence_matchLoopMode(const char* str,
Sequence.cpp:45:static const char*
Sequence_getLoopMode(Sequence::LoopMode mode)
Sequence.cpp:57:static bool Sequence_matchSeqMode(const char* str,
Sequence.cpp:76:static const char*
Sequence_getSeqMode(Sequence::SequenceMode mode)
StateAttribute.cpp:32: static ref_ptr s_callback
= new osg::StateAttributeCallback;
StateSet.cpp:80: static bool first_time = true;
StateSet.cpp:83: static OpenThreads::Mutex s_initGLNames;
StateSet.cpp:362: static ref_ptr s_callback = new
osg::StateSet::Callback;
Uniform.cpp

Re: [osg-users] Set Viewport background color as transparent

2012-06-04 Thread shekhar vishwa
Hi,

I want to show the models on semi-transparent backgroud color.  I have
implemented following code

camera1->setViewport( 0, 0, 200, 200 );

camera1->setClearColor( osg::Vec4(0.0f, 1.0f, 1.0f, 0.5f) );

camera1->setRenderOrder( osg::Camera::POST_RENDER );

camera1->setAllowEventFocus( true );

camera1->setClearMask(GL_DEPTH_BUFFER_BIT );//| GL_DEPTH_BUFFER_BIT

camera1->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
But above code is set the background as complete transparent.

Please help me to make the camera background as semi-transparent.

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


Re: [osg-users] Possibility of an OSG bot

2012-06-04 Thread Sterling Somers
Thanks Robert, I'll have a look!


robertosfield wrote:
> Hi Stirling, 
> If you need to reject concluded objects then you will need to use the OpenGL 
> occlusion query feature, see the osgocclusionquery example. 
> Robert On May 28, 2012 5:17 PM, "Sterling Somers" < ()> wrote:
> >  Robert,
> > 
> > Thanks for the reply. I would ideally need to reject fully occluded objects 
> > (but there is a speed tradeoff that I'd consider). When I was thinking 
> > about doing this with the pickhandler (which might be slow?), I was 
> > thinking of using a polytope intersection but I had no real reason for 
> > doing so, other than it seemed appropriate as I could define a region that 
> > cover the camera (that's what other people seemed to be doing). I could not 
> > tell you whether ray based intersections would be appropriate or not.
> > 
> > Sterling
> > 
> > 
> > robertosfield wrote:
> > 
> > > Hi Sterling,
> > > 
> > > How you want to go about the task depends very much of your specific
> > > needs.  Is it sufficient for the any part of the object to be in the
> > > view frustum?  Do you need to reject objects that are in the view
> > > frustum but wholly occluded by other nearer objects?  Is ray based
> > > intersections appropriate?  A polytope based intersections?
> > > 
> > > Robert.
> > > 
> > > On 14 May 2012 16:43, Sterling Somers <> wrote:
> > > 
> > > 
> > > > Hi,
> > > > 
> > > > I am fairly new to OSG and have been slowly learning the basics. I am a 
> > > > student and the basic theme of my research is to model human behaviour. 
> > > > I have been interested in making our models more interesting by 
> > > > immersing them into a 3D environment.  To give the agent SOME sense of 
> > > > vision, I’d like to be able detect which objects are viewable to the 
> > > > (automated, one day) viewer.  I do not know much about OSG but this 
> > > > seems like a plausible project. I suspect I wouldn’t want to do it with 
> > > > the pickhandler, is that correct? Would I have to do some sort of 
> > > > culling callback? I have been grasping at straws. Basically, given a 
> > > > command, I’d like to my program to respond with what objects are 
> > > > viewable, what it’s coordinates are, and if possible, the file location 
> > > > for any sub-graphs. If I could get some opinions on whether this would 
> > > > even be possible, that would be great. Some pointing in the right 
> > > > direction would be ever greater.
> > > > 
> > > > Thank you!
> > > > 
> > > > 
> > > > Sterling
> > > > 
> > > > --
> > > > Read this topic online here:
> > > > http://forum.openscenegraph.org/viewtopic.php?p=47695#47695 
> > > > (http://forum.openscenegraph.org/viewtopic.php?p=47695#47695)
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > ___
> > > > osg-users mailing list
> > > > 
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > >  
> > > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > > 
> > > > 
> > > ___
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > 
> > >  --
> > > Post generated by Mail2Forum
> > > 
> > 
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=47897#47897 
> > (http://forum.openscenegraph.org/viewtopic.php?p=47897#47897)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  --
> Post generated by Mail2Forum


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





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


[osg-users] OpenSceneGraph on the Playbook

2012-06-04 Thread Preet
Hiya,

I managed to compile and deploy a small OSG test application on the
Playbook, but have run into some trouble getting it to work correctly.
I'm not creating my own context or windowing system; instead I'm using
osg's GraphicsWindowEmbedded with Qt. As a test, I set up a scene with
a rotating cube. The application seems to display the viewport
(there's the telltale purple-blue background in OSG), but fails to
render the cube.

The output seems to indicate that creating a shader for the cube
fails, but I can't discern any more than that. It feels like this has
something to do with OpenGL ES2... I compiled OSG for ES2 based on the
instructions I found on the mailing list and the OSG website. I've
pasted the output I think is relevant below, with the full output
here: (http://pastie.org/4027605), and the OSG scene set up here:
(http://pastie.org/4027631). The application works fine and renders as
expected using OpenGL on my desktop. Could anyone suggest something to
get this working?


Preet



glVersion=2, isGlslSupported=YES, glslLanguageVersion=1.016
State::convertShaderSourceToOsgBuiltIns()
++Before Converted source

void main()
{
  gl_Position = ftransform();
  gl_FrontColor = gl_Color;
}


 Converted source
uniform mat4 osg_ModelViewProjectionMatrix;
attribute vec4 osg_Color;
attribute vec4 osg_Vertex;

void main()
{
  gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
  gl_FrontColor = osg_Color;
}



Compiling VERTEX source:
1: uniform mat4 osg_ModelViewProjectionMatrix;
2: attribute vec4 osg_Color;
3: attribute vec4 osg_Vertex;
4:
5: void main()
6: {
7:   gl_Position = osg_ModelViewProjectionMatrix * oVERTEX
glCompileShader "" FAILED
VERTEX Shader "" infolog:
0:8(16): error: `gl_FrontColor' undeclared
0:8(16): error: type mismatch

FRAGMENT glCompileShader "" FAILED
FRAGMENT Shader "" infolog:
0:6(19): error: `gl_Color' undeclared
0:6(19): error: Operands to arithmetic operators must be numeric
0:6(19): error: type mismatch

glLinkProgram "" FAILED
Program "" infolog:
linking with uncompiled shaderlinking with uncompiled shader
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Set Viewport background color as transparent

2012-06-04 Thread Robert Osfield
Hi Vishwa,

On 4 June 2012 20:49, shekhar vishwa  wrote:
> Thanks for help. Now I can make the camera background as transparent. What
> parameters need to set the camera background as semi-transparent.

What do you mean by semi-transparent background?  Everyone has given
you as much guidance as can be given with what you've said about what
you are trying to do so there is nothing else we can add till you
explain what you are actually after.

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


Re: [osg-users] Set Viewport background color as transparent

2012-06-04 Thread shekhar vishwa
Hi,

Thanks for help. Now I can make the camera background as transparent. What
parameters need to set the camera background as semi-transparent.

Please help me.

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


[osg-users] osgOcean: Update cubemap often not working?

2012-06-04 Thread Brad Colbert
Hi folks,

I'm not sure what I'm missing, but I'm trying to update the cubemap used in 
osgOcean (and the example application) with a series of cameras.  The approach 
I've taken is derived from the osgprerendercubemap example.  I'm rendering our 
sky model to the cubemap but, strangely it does not appear to update when the 
time of day is changed?  

I've simplified my updates to the example application so that I can post it 
here.  In a pre-draw callback I call glClear when the camera ID  and the 
current count match.  What I expect to happen is that the clear color should 
iterate through all of the cameras (and cubemap panels), changing about once 
per second.  What I see is no effect of the clear.

If I call clear on all cameras at least once I get all of the panels in the 
cubemap with the clear color, but if the color changes during run-time, I see 
no change in the cubemap.

Debugging, I know that this pre-render call is made for all of the cubemap 
cameras every frame, but after the initial pass, it appears to not have an 
effect, although it is still called.

I appreciate any insight, thanks.

... 

Thank you!

Cheers,
Brad

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




Attachments: 
http://forum.openscenegraph.org//files/updatecameraandcubetexcallback_186.h
http://forum.openscenegraph.org//files/drawskyaspredrawcallback_759.h
http://forum.openscenegraph.org//files/updatecameraandcubetexcallback_737.cpp
http://forum.openscenegraph.org//files/drawskyaspredrawcallback_110.cpp
http://forum.openscenegraph.org//files/application_291.cpp


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


[osg-users] Troubles with the Texture2D serializer when _image is an ImageSequence

2012-06-04 Thread rocco martino
Hello everyone,


I've discovered a problem with the Texture2D serializer that occurs when the
associated image is an instance of an osg::ImageSequence.
I think this happens because the ImageSerializer::read method calls the
InputStream::readImage without ensuring that the object is actually an
osg::Image, producing a read error.

Can someone evaluate my observations?


I use OSG-3.0.1, but in 3.1.2 ChangeLog file I have not found anything
about it.



This is the osgviewer output:

[martino@slack] osg_image_sequence $ osgviewer graph.osgt
InputStream::readObject(): Unsupported wrapper class
osg::StateAttributeCallback
Warning: Could not find plugin to read objects from file "".
AsciiInputIterator::readProperty(): Unmatched property }, expecting Value



I attach two files:

write_graph.cpp produces graph.osgt

graph.osgt contains the ImageSequence that osgDB::readNodeFile cannot
read




Thanks you all,
Martino
#include 
#include 
#include 
#include 

#include 




int
main(int argc, char** argv)
{
osg::ref_ptrroot= NULL ;
osg::Geometry*  geometry= NULL ;
osg::ImageSequence* image_sequence  = NULL ;
osg::Texture2D* texture = NULL ;



geometry = osg::createTexturedQuadGeometry( osg::Vec3(-1,  0, -1),
osg::Vec3( 2,  0,  0),
osg::Vec3( 0,  0,  2)
  ) ;


root = new osg::Geode() ;

root->addDrawable( geometry ) ;




image_sequence = new osg::ImageSequence() ;


for(int i=1; iaddImageFile( argv[i] ) ;
}





texture = new osg::Texture2D( image_sequence ) ;

root->getOrCreateStateSet()->setTextureAttributeAndModes(   0, 
texture,
osg::StateAttribute::ON
) ;



osgDB::writeNodeFile( *root, "graph.osgt" ) ;



return 0 ;
}

graph.osgt
Description: Binary data
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Tessellation

2012-06-04 Thread Robert Osfield
On 4 June 2012 16:01, Bob Slobodan  wrote:
> And what I would like to do now is to get the list of "triangles" from my 
> geometry.

You original asked for vertices... now you want triangles... is that
because you now know how to get the vertices, or is it that you now
know what you want more precisely??

> By looking at the code of the OSG tesselator, I understood that it creates 
> new PrimitiveSet but I can't figure out how exactly how to do it.

How to do what?  Do the tessellation - your code you posted does that
so I presume you mean how do you get the PrimitiveSet's which is
pretty easy just look at the header for osg::Geometry and you'll find
getPrimitiveSets().

Is that you are asking how to get the primitive data from a
PrimitiveSet???  Again go have a look at the headers it'll tell you
how to access the data within.

Might I also ask you for what purpose you want to know the
vertices/primitive data?  What are you trying to do with it?

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


Re: [osg-users] Tessellation

2012-06-04 Thread Bob Slobodan
Hi,
Sorry, my bad.

Basically, I want to "triangulate" polygons. I have polygon with more than 3 
vertices and I want to retrieve the "sub-polygons" (simple triangles) using the 
osg tesselation tool.

Here is some code. In my "surface" class, after creating my geometry, I 
tessellate it if it has more than 3 vertex :


Code:

geometry->addPrimitiveSet(new 
osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,vertices->size()));

tessellator = new osgUtil::Tessellator();

if(vertices.size()>3){

tessellator->setTessellationType(osgUtil::Tessellator::TESS_TYPE_POLYGONS);
tessellator->setWindingType( 
osgUtil::Tessellator::TESS_WINDING_NONZERO);
tessellator->retessellatePolygons(*geometry);
}




And what I would like to do now is to get the list of "triangles" from my 
geometry.

By looking at the code of the OSG tesselator, I understood that it creates new 
PrimitiveSet but I can't figure out how exactly how to do it.

Sorry again and thank you!

Bob

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





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


Re: [osg-users] Tessellation

2012-06-04 Thread Robert Osfield
On 4 June 2012 13:31, Bob Slobodan  wrote:
> Really no one has a clue about how to do it ?

More likely that no one has a real clue what you are asking and after.

Getting a vertex array from an osg::Geometry is easy... just look at
the Geometry header and you'll find a getVertexArray() method, but I'm
guessing this isn't really what you are asking, which then leaves
wonder what you actually mean.

> I tried to look at the getPrimList and the getContours functions of the 
> tessallator but it seems the array are the same as before the tesselation. I 
> also tried to look at the PrimitiveSetList of my geometry but I can only find 
> one after the tessellation (I thought the tesselation would add new 
> PrimitiveSet) and I really don't see where to get the information that I need 
> to create my new surfaces.
> No one has a clue ?

Yep, no one has a clue what you actually mean :-)

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


Re: [osg-users] Multi-touch on osg (Android)

2012-06-04 Thread Rghima Ahlem
Hi,

I know that osg don't support the gesture recognition. 
I have to differentiate between the rotation and zoom to specify button (1 or 
3) for methods mouseButtonReleaseEvent and mouseButtonPressEvent.

Thank you!

Cheers,
Rghima

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





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


Re: [osg-users] Tessellation

2012-06-04 Thread Bob Slobodan
Really no one has a clue about how to do it ?

I tried to look at the getPrimList and the getContours functions of the 
tessallator but it seems the array are the same as before the tesselation. I 
also tried to look at the PrimitiveSetList of my geometry but I can only find 
one after the tessellation (I thought the tesselation would add new 
PrimitiveSet) and I really don't see where to get the information that I need 
to create my new surfaces.
No one has a clue ?

Thank you!

Cheers,
Bob

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





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


Re: [osg-users] Multi-touch on osg (Android)

2012-06-04 Thread Stephan Maximilian Huber
Hi

you'll need to code the logic by yourself. osg has no built-in gesture
recognition.

you can compute both zoom level and rotation from your multi-touch
input, no need to distinguish between them. Just store the start
touch-points and compare them with the current touch-points. compute the
zoom-level and the rotation-value from there.

cheers,
Stephan




Am 04.06.12 11:46, schrieb Rghima Ahlem:
> Hi,
> 
> I work on th osgAndroidExampleGLES1, i want to work with multi -touch with 
> the buton "change Navigation".
> one finger->drag
> two fingers->rotation, zoom.
> the problem is to difference between zoom in , zoom out and rotation
> Please help me to detect the type of moving.
> 
> 
> Thank you!
> 
> Cheers,
> Rghima
> 
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=48018#48018
> 
> 
> 
> 
> 
> ___
> 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] Multi-touch on osg (Android)

2012-06-04 Thread Rghima Ahlem
Hi,

I work on th osgAndroidExampleGLES1, i want to work with multi -touch with the 
buton "change Navigation".
one finger->drag
two fingers->rotation, zoom.
the problem is to difference between zoom in , zoom out and rotation
Please help me to detect the type of moving.


Thank you!

Cheers,
Rghima

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





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


Re: [osg-users] RTT using slave cameras (osgfpdeth example)

2012-06-04 Thread Tim Moore
I'm not sure if this answers your question, but... the only portable
way to get a floating point depth buffer is with an FBO; you can't
attach one to the frame buffer associated with the main display. So
the example renders the geometry to an FBO attached to a slave, then
displays the results as a texture in the main camera.

Tim

On Sun, Jun 3, 2012 at 12:13 AM, Joel Graff  wrote:
> Hello,
>
> I'm trying to learn the intracacies of rendering to textures using osg, and 
> I've dissected the osgfpdepth example to do it.  I've been largely successful 
> at resolving the code into a much simpler example for rendering using the 
> color buffer only.
>
> Anyway, my goal was to have both the main camera and the RTT camera rendering 
> the same geometry.  The RTT camera, of course, would have different state in 
> it's path that would create a different effect on the geometry.
>
> However, it seems the osgfpdepth example isn't set up to do this.  That is, 
> depth buffering is enabled on the root node with the code:
>
>
> Code:
>
>    osg::Depth* depth = new osg::Depth( osg::Depth::GEQUAL, 1.0, 0.0);
>    sceneSS->setAttributeAndModes(depth,(osg::StateAttribute::ON
>                                         | osg::StateAttribute::OVERRIDE));
>
>
>
>
> Why depth buffering has to be enabled for the slave camera to 
> render-to-texture I'm not sure, but I do know that doing so means the 
> geometry isn't rendered by the main camera view.  That is, either the main 
> camera or the RTT camera renders the geometry, but not both.  Thus the need 
> to create a second texture slave camera to render the RTT output to the 
> screen.
>
> Given that I'm new to render-to-texture methods and techniques, I've no doubt 
> there's some obvious reasoning that I've missed.  Nevertheless, I'd 
> appreciate any comments that might illuminate the issue.
>
> Thanks,
>
> Joel
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=48005#48005
>
>
>
>
>
> ___
> 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] dotosg wrappers not thread safe

2012-06-04 Thread Mikhail I. Izmestev

Hi Robert,

It is hard to reproduce this problem (as any thread safety problem) in 
same state as previous.


I have another crash with same problem at:
ntdll!RtlEnterCriticalSection+0x6
ot12_OpenThreads!OpenThreads::Mutex::lock+0xe
osgdb_deprecated_osg!initGLNames+0x66
osgdb_deprecated_osg!StateSet_readLocalData+0x4f
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x9eb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x28
osgdb_deprecated_osg!Node_readLocalData+0x349
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
osgdb_osg!OSGReaderWriter::readNode+0xfe
osgdb_osg!OSGReaderWriter::readNode+0x31c
osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28
osg80_osgDB!osgDB::Registry::read+0x5e4
osg80_osgDB!osgDB::Registry::readImplementation+0x34c
osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a
osg80_osgDB!osgDB::Registry::readNode+0xfc
osg80_osgDB!osgDB::readNodeFile+0x4e

crashed code:
int Mutex::lock() {
Win32MutexPrivateData *pd =
static_cast(_prvData);

#ifdef USE_CRITICAL_SECTION

// Block until we can take this lock.
EnterCriticalSection( &(pd->_cs) );  CRASH HERE

return 0;
[...]

pd->_cs == NULL

in this case problem at
void initGLNames()
{
static bool first_time = true;
if (!first_time) return;

static OpenThreads::Mutex s_initGLNames;
OpenThreads::ScopedLock lock(s_initGLNames);

[...]

There is lot of other places with same design:
AnimationPath.cpp:201:static osg::ref_ptr s_path 
= new osg::AnimationPath;
CoordinateSystemNode.cpp:48:static ref_ptr 
s_ellipsoidModel = new EllipsoidModel;
Drawable.cpp:30:static ref_ptr s_drawstate = new 
osg::StateSet;

Node.cpp:77:static ref_ptr s_drawstate = new osg::StateSet;
Node.cpp:85:static ref_ptr s_nodecallback = new 
osg::NodeCallback;
NodeCallback.cpp:31:static osg::ref_ptr s_nc = new 
NodeCallback;
OccluderNode.cpp:30:static ref_ptr s_occluder 
= new ConvexPlanarOccluder;

Sequence.cpp:26:static bool Sequence_matchLoopMode(const char* str,
Sequence.cpp:45:static const char* 
Sequence_getLoopMode(Sequence::LoopMode mode)

Sequence.cpp:57:static bool Sequence_matchSeqMode(const char* str,
Sequence.cpp:76:static const char* 
Sequence_getSeqMode(Sequence::SequenceMode mode)
StateAttribute.cpp:32:static ref_ptr 
s_callback = new osg::StateAttributeCallback;

StateSet.cpp:80:static bool first_time = true;
StateSet.cpp:83:static OpenThreads::Mutex s_initGLNames;
StateSet.cpp:362:static ref_ptr s_callback = new 
osg::StateSet::Callback;
Uniform.cpp:212:static ref_ptr s_callback = new 
osg::Uniform::Callback;


Mikhail.

04.06.2012 12:44, Robert Osfield написал:

Hi Mikhail,

I have moved the static into the global scope of the
osgWrappers/deprecated-dotosg/Drawable.cpp, file attached, could try
it out?

Robert.

On 2 June 2012 11:12, Mikhail I. Izmestev  wrote:

Hi,

I noticed crashing in dotosg wrappers when try to use osgDB::readNodeFile
from multiple threads.
Crash occurs when I try to load .osg file from two threads.

For example callstack of crashed thread:
osg80_osgDB!concrete_wrapper::matches+0x4
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x527
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x28
osgdb_deprecated_osg!Drawable_readLocalData+0xa1
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1
osgdb_deprecated_osg!Geode_readLocalData+0x90
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
osgdb_deprecated_osg!Group_readLocalData+0x71
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
osgdb_deprecated_osg!Group_readLocalData+0x71
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
osgdb_osg!OSGReaderWriter::readNode+0xfe
osgdb_osg!OSGReaderWriter::readNode+0x31c
osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28
osg80_osgDB!osgDB::Registry::read+0x5e4
osg80_osgDB!osgDB::Registry::readImplementation+0x34c
osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a
osg80_osgDB!osgDB::Registry::readNode+0xfc
osg80_osgDB!osgDB::readNodeFile+0x4e
[...]

second thread callstack:
msvcp90!std::basic_istream
msvcp90!std::basic_istream
osg80_osgDB!osgDB::FieldReader::_readField+0x3f8
osg80_osgDB!osgDB::FieldReaderIterator::field+0x19d
osgdb_deprecated_osg!Array_readLocalData+0xbfb
osgdb_deprecated_osg!Geometry_readLocalData+0x991
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1
osgdb_deprecated_osg!Geode_readLocalData+0x90
osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::

Re: [osg-users] Set Viewport background color as transparent

2012-06-04 Thread Robert Osfield
Hi Shekhar,

On 2 June 2012 12:30, shekhar vishwa  wrote:
> I am using the OSG, but I unable to set the viewport or view backgraund
> color as transparent.

Do you actually mean that you want it completely transparent? As in
disable the clear of the colour buffer completely?  If so then use the
Camera's ClearMask property set to GL_DEPTH_BUFFER_BIT rather than the
normal default of GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT

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


Re: [osg-users] Getting Webcam feed - From OpenCV to OSG

2012-06-04 Thread Robert Osfield
Hi Praveena,

You say the program crashes but provide absolutely no guidance on
where and when it crashes.  This gives us nothing to go on.  Please
use a debugger to get a stack trace of where it is crashing and then
pass on this info.

Robert.

On 4 June 2012 06:52, Praveena Sarathchandra  wrote:
> Hi,
>
> So far I've been successful in showing the first captured frame using
> OpenCV, in OSG.
>
>> // IplImage* cvImg is the webcam output image captured using
>> cvQueryFrame(capture)
>> osg::ref_ptr osgImage = new osg::Image;
>> osgImage->setImage(cvImg->width,cvImg->height, 3,
>>                GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,
>>                (BYTE*)(cvImg->imageData),
>>                osg::Image::AllocationMode::NO_DELETE,1);
>
>
>>
>> osg::ImageStream* imageStream = dynamic_cast(
>> osgImage.get() );
>> if( imageStream ) imageStream->play();
>
>
>>
>> osg::ref_ptr texture = new osg::Texture2D;
>> texture->setImage( osgImage.get() );
>
>
>>
>> osg::ref_ptr quad = osg::createTexturedQuadGeometry(
>>         osg::Vec3(), osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f,
>> 1.0f) );
>> quad->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture.get()
>> );
>
>
>>
>> osg::ref_ptr geode = new osg::Geode;
>> geode->addDrawable( quad.get() );
>
>
>
> But I want the entire webcam stream in OSG, after preprocessing in OpenCV.
> After googling I found this answer as a guide:
> http://markmail.org/message/txqiv4plykf3bm3r#query:+page:1+mid:txqiv4plykf3bm3r+state:results
>
> According to that I made my Camera class inherit from osg::ImageStream and
> called dirty() whenever a new frame is captured. But when I run the program
> it crashes! How can I get this to work?
>
>> class Camera : public QObject, public osg::ImageStream
>> {
>>     Q_OBJECT
>> public:
>>     Camera();
>>     ~Camera();
>>     IplImage* getFrame();
>> private:
>>     CvCapture* capture;
>>     IplImage* frame;
>>     int timerId;
>> public slots:
>>     void timerEvent(QTimerEvent *);
>> private slots:
>>     void initialize();
>> };
>
>
>> Camera::Camera() : QObject(), osg::ImageStream()
>> {
>>     capture = cvCreateCameraCapture(0);
>>     frame = cvQueryFrame(capture);
>>     QTimer::singleShot(0,this,SLOT(initialize()));
>> }
>>
>> void Camera::initialize(){
>>     frame = cvQueryFrame(capture);
>>     timerId = startTimer(10);
>> }
>> void Camera::timerEvent(QTimerEvent *){
>>    frame = cvQueryFrame(capture);
>>
>>    dirty();
>> }
>
>
> Thanks
>
>
> ___
> 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] Shared Vertex Arrays with multiple Geodes?

2012-06-04 Thread Robert Osfield
Hi Jason,

On 4 June 2012 00:40, Jason Anderssen  wrote:
> I would like to know what is the best way to go about having a shared vertex 
> array that is shared between multiple Geode's with indexes into the vertex 
> array?

Simply assign the same vertex array to each osg::Geometry and use
different DrawElementsUShort/UInt to index them.

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


Re: [osg-users] Getting Webcam feed - From OpenCV to OSG

2012-06-04 Thread Sergey Polischuk
 Hi You can doosgImage->setImage(cvImg->width,cvImg->height, 3,               GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,                (BYTE*)(cvImg->imageData),               osg::Image::AllocationMode::NO_DELETE,1); every time new image comes from opencv, and you should be ok Cheers. 04.06.2012, 09:52, "Praveena Sarathchandra" :Hi,So far I've been successful in showing the first captured frame using OpenCV, in OSG. // IplImage* cvImg is the webcam output image captured using cvQueryFrame(capture)osg::ref_ptr osgImage = new osg::Image;osgImage->setImage(cvImg->width,cvImg->height, 3,               GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,                (BYTE*)(cvImg->imageData),               osg::Image::AllocationMode::NO_DELETE,1); osg::ImageStream* imageStream = dynamic_cast( osgImage.get() );if( imageStream ) imageStream->play(); osg::ref_ptr texture = new osg::Texture2D;texture->setImage( osgImage.get() ); osg::ref_ptr quad = osg::createTexturedQuadGeometry(        osg::Vec3(), osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f, 1.0f) );quad->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture.get() ); osg::ref_ptr geode = new osg::Geode; geode->addDrawable( quad.get() );But I want the entire webcam stream in OSG, after preprocessing in OpenCV. After googling I found this answer as a guide:http://markmail.org/message/txqiv4plykf3bm3r#query:+page:1+mid:txqiv4plykf3bm3r+state:resultsAccording to that I made my Camera class inherit from osg::ImageStream and called dirty() whenever a new frame is captured. But when I run the program it crashes! How can I get this to work?class Camera : public QObject, public osg::ImageStream {    Q_OBJECTpublic:    Camera();    ~Camera();    IplImage* getFrame();private:    CvCapture* capture;    IplImage* frame;    int timerId;public slots:    void timerEvent(QTimerEvent *); private slots:    void initialize();};Camera::Camera() : QObject(), osg::ImageStream(){    capture = cvCreateCameraCapture(0);    frame = cvQueryFrame(capture);    QTimer::singleShot(0,this,SLOT(initialize()));}void Camera::initialize(){     frame = cvQueryFrame(capture);    timerId = startTimer(10);}void Camera::timerEvent(QTimerEvent *){   frame = cvQueryFrame(capture);    dirty();} Thanks___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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] dotosg wrappers not thread safe

2012-06-04 Thread Robert Osfield
Hi Mikhail,

I have moved the static into the global scope of the
osgWrappers/deprecated-dotosg/Drawable.cpp, file attached, could try
it out?

Robert.

On 2 June 2012 11:12, Mikhail I. Izmestev  wrote:
> Hi,
>
> I noticed crashing in dotosg wrappers when try to use osgDB::readNodeFile
> from multiple threads.
> Crash occurs when I try to load .osg file from two threads.
>
> For example callstack of crashed thread:
> osg80_osgDB!concrete_wrapper::matches+0x4
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x527
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObjectOfType+0x28
> osgdb_deprecated_osg!Drawable_readLocalData+0xa1
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1
> osgdb_deprecated_osg!Geode_readLocalData+0x90
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x71
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x71
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_osg!OSGReaderWriter::readNode+0xfe
> osgdb_osg!OSGReaderWriter::readNode+0x31c
> osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28
> osg80_osgDB!osgDB::Registry::read+0x5e4
> osg80_osgDB!osgDB::Registry::readImplementation+0x34c
> osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a
> osg80_osgDB!osgDB::Registry::readNode+0xfc
> osg80_osgDB!osgDB::readNodeFile+0x4e
> [...]
>
> second thread callstack:
> msvcp90!std::basic_istream
> msvcp90!std::basic_istream
> osg80_osgDB!osgDB::FieldReader::_readField+0x3f8
> osg80_osgDB!osgDB::FieldReaderIterator::field+0x19d
> osgdb_deprecated_osg!Array_readLocalData+0xbfb
> osgdb_deprecated_osg!Geometry_readLocalData+0x991
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readDrawable+0xe1
> osgdb_deprecated_osg!Geode_readLocalData+0x90
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x71
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x9a
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x9a
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_deprecated_osg!Group_readLocalData+0x71
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readObject+0x8fb
> osg80_osgDB!osgDB::DeprecatedDotOsgWrapperManager::readNode+0xe1
> osgdb_osg!OSGReaderWriter::readNode+0xfe
> osgdb_osg!OSGReaderWriter::readNode+0x31c
> osg80_osgDB!osgDB::Registry::ReadNodeFunctor::doRead+0x28
> osg80_osgDB!osgDB::Registry::read+0x5e4
> osg80_osgDB!osgDB::Registry::readImplementation+0x34c
> osg80_osgDB!osgDB::Registry::readNodeImplementation+0x6a
> osg80_osgDB!osgDB::Registry::readNode+0xfc
> osg80_osgDB!osgDB::readNodeFile+0x4e
> [...]
>
> code:
> struct concrete_wrapper: basic_type_wrapper
> {
>    virtual ~concrete_wrapper() {}
>    concrete_wrapper(const osg::Object *myobj) : myobj_(myobj) {}
>    bool matches(const osg::Object *proto) const
>    {
>        return myobj_->isSameKindAs(proto);   HERE<<<
>    }
>    const osg::Object *myobj_;
> };
>
> crash occurs because myobj_ is NULL.
>
> myobj_ passed from osgdb_deprecated_osg!Drawable_readLocalData as
> s_drawstate
>
> bool Drawable_readLocalData(Object& obj, Input& fr)
> {
>    bool iteratorAdvanced = false;
>
>    Drawable& drawable = static_cast(obj);
>
>    static ref_ptr s_drawstate = new osg::StateSet;
>    if (StateSet* readState =
> static_cast(fr.readObjectOfType(*s_drawstate)))
>    {
>        drawable.setStateSet(readState);
>        iteratorAdvanced = true;
>    }
> [...]
>
>
> so problem is in
>    static ref_ptr s_drawstate = new osg::StateSet;
>
> MSVC 2008 x64 compiler (maybe gcc too) generate this code as:
>
> static bool s_drawstate_init = false;
> static ref_ptr s_drawstate = NULL;
>
> bool Drawable_readLocalData(Object& obj, Input& fr)
> {
>    bool iteratorAdvanced = false;
>
>    Drawable& drawable = static_cast(obj);
>
>    if(!s_drawstate_init)
>    {
>        s_drawstate_init = true;
>        s_drawstate = new osg::StateSet;
>    }
>
>    if (StateSet* readState =
> static_cast(fr.readObjectOfType(*s_drawstate)))
>    {
>        drawable.setStateSet(readState);
>        iteratorAdvanced = true;

[osg-users] Tessellation

2012-06-04 Thread Bob Slobodan
Hi,

The idea is simple, I have a class named "Surface" that handles polygons (each 
instance handles one polygon). Basically, when a surface has more than 3 
vertices, I tessellate it to be sure that it will be properly rendered. My 
problem is that I now need to separate the different polygons created by the 
tesselation. If I understood how it works, when OSG tessellates, it modifies 
the geometry.

So my question is simple : How can I retrieve the different vertex array from 
the geometry. I don't completely understand how it works.

Thank you!

Cheers,
Bob

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





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


Re: [osg-users] Set Viewport background color as transparent

2012-06-04 Thread Gio
Hi Shekhar,

to set a transparent background you have to enable alpha when you set your 
traits 

When you set the graphic context traits 
osg::ref_ptr traits = new 
osg::GraphicsContext::Traits;
you can just add the line to your configuration:
traits->alpha = 1;
after you create a graphiccontext and associate your traits
osg::ref_ptr graphicsContext = 
osg::GraphicsContext::createGraphicsContext(traits.get());
you can set it in your camera like this
_viewer = new osgViewer::Viewer();
_viewer->getCamera()->setGraphicsContext(graphicsContext);


On Jun 4, 2012, at 8:21 AM, shekhar vishwa wrote:

> Hi,
>  
> I am trying to implement the 3D overlay above current view. I am trying to 
> set the camera background color as transparent. I am using following code.
>  
> osg::Node* node= osgDB::readNodeFile( "Models/cessna.osg"); 
> osg::Camera* camera = new osg::Camera;
> camera->setViewport( 0, 0, 200, 200 );
> camera->setClearColor(osg::Vec4(1.0f,1.0,0.8f,0.2f));
> osg::StateSet* stateset = camera1->getOrCreateStateSet();
> stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> camera->setStateSet(stateset);
> camera->setRenderOrder( osg::Camera::POST_RENDER );
> camera->setAllowEventFocus( true );
> camera->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
> camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
> camera->addChild( node1 );
>  
>  
> Above code only set the white background. Please help to set the camera 
> backgroud color as transparent.
>  
> Thanks
> Vishwa
> -- Forwarded message --
> From: shekhar vishwa 
> Date: Sat, Jun 2, 2012 at 5:00 PM
> Subject: Set Viewport background color as transparent
> To: osg-users@lists.openscenegraph.org
> 
> 
> Hi,
>  
> I am using the OSG, but I unable to set the viewport or view backgraund color 
> as transparent.
>  
> Please help me to resolve this issue.
>  
> Thanks
> Vishwa
> 
> ___
> 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