Re: [osg-users] Resetting buttonMask of GUIEvents

2014-10-09 Thread Robert Osfield
Hi Peter,

On 8 October 2014 17:35, Peter Bako osgfo...@tevs.eu wrote:

 Hi,

 What is the best way to reset the button mask (no button is pressed)?
 I tried to use Viewer-getEventQueue()-mouseButtonRelease(1,1,1); but
 this doesn't reset the button mask.

 The problem is that sometimes the users press more mouse buttons at the
 same time and release it out of the graphic area, so OSG doesnt get the
 release event.
 Then on mouse move the scene is dragged or zoomed, depending from
 button. It can be stopped only by pressing this (right or middle) button
 again. And this is confusing.
 I want to reset this in code, when the user presses ESC key.
 Do you have any suggestion how to do it?


The button mask state is stored in the osgGA::EventQueue::CurrentEventState
property that you can get access to via
eventqueue-getCurrentEventState().  You can directly set the current state
there.

Each GraphicsWindow has an EventQueue, this is where the events are placed
when the OS's windowing system generates events.

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


[osg-users] Issue with StateSet::setUpdateCallback and Drawable

2014-10-09 Thread Damian Stewart
Hi,

I have some code where I would like to adjust some attributes in an update 
callback on a StateSet. When I tried to test my code, it worked in several 
tests but not on others, and I spent some time debugging my code to figure out 
what I had done wrong.

It turns out that in osg 3.2 (and in trunk) that update callbacks are not 
supported on StateSets that are attached to Drawables.

There's some code in StateSet::setUpdateCallback that is commented out:

Code:

osg::Drawable* drawable = dynamic_castosg::Drawable*(*itr);
if (drawable)
{
//drawable-setNumChildrenRequiringUpdateTraversal(drawable-getNumChildrenRequiringUpdateTraversal()+delta);
}




Uncommenting that line fixed the issue, but I have a couple of questions I am 
hoping someone can answer:

1) I couldn't see anything in the source files history on git indicating why 
this line was commented out, but I assume there was a reason. Anyone know why?

2) Does anyone know why StateSets only support a single update callback when 
other classes support multiple callbacks (with addUpdateCallback instead of 
just setUpdateCallback)?

Thanks,
Damian
[/code]

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





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


Re: [osg-users] Resetting buttonMask of GUIEvents

2014-10-09 Thread Peter Bako
Hello Robert.

Thanks for the answer. 
It is working perfect!

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





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


[osg-users] avatar animation

2014-10-09 Thread Cledja Rolim
Hi guys,

I'm new in OSG and I have a question.
I have a 3D model (avatar) in FBX format, and I'd like to move the model arms.
The movement of the shoulders, and wrist seem fine, but the hands/finger don't 
move. 
I figured out that the hands have, each one, 15 bones (3 bones for each finger) 
+ one bone for the parent - hand. I multiplied the matrix of each bone for its 
parent (hand rotation matrix) and after I applied in the model with:

bone-setMatrixInSkeletonSpace(boneTransforms[num]*bone-getMatrixInSkeletonSpace());

But, the all hand still doesn't move. Did I do something wrong? Or I missed 
something? 

Thanks!

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





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


[osg-users] Access loaded model's textures.

2014-10-09 Thread Sander Meessen
Hi,

I am new to OSG (and rusty with GLSL) and am having some problems, I hope 
someone can help since I cannot find any posts about it. It is a bit difficult 
to explain, I will do my best:

- I have two models; one .flt (a tank) and one .3ds (a plane).
- Both have multiple textures to cover the entire model. The .flt model has two 
different sets (one normal and the other a heat map).
- The models are loaded into an osg::Node via osgDB::readNodeFile.
- They display fine via the default render setup.

Now I want to write a custom shader for some special effects. Somehow for each 
model the textures are already bound to the shader, without any coding from my 
side. I can access them by declaring a uniform sampler2D in the fragment shader 
and calling texture2D(samplerName, gl_TexCoord[0].st). The models display fine 
via this method. So even though I index one texture I am rendering all the 
textures from a set.
I cannot figure out how to access the other texture set of the .flt model in 
the shader. 
Additionally I cannot find any textures in the nodes in normal code; 
getTextureAttributeList returns zero size.

So how do I do this?

Also I would like to know how it is possible that the shader renders all the 
textures in a set while only indexing one, does OSG automatically combine them 
into one texture during import?


Thank you in advance!

Cheers,
Meessen

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





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


Re: [osg-users] two cameras(master and render to depth image)

2014-10-09 Thread Manos Mastorakis
Hi,
sorry for that Mr Robert.. totally understandable. so here is my code and 
the thing is that i dont get the depth image as i want to but a white image so 
i believe i am close to my solution but there must be something missing... any 
suggestion or advice would be great... thank you...
... 

includes... and osg::Group* _root;

int main(int argc, char **argv)
{
_root = new osg::Group();
osgViewer::CompositeViewer* viewer = new osgViewer::CompositeViewer(); 
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x=0;
traits-y=0;
traits-width = 2400;
traits- height =1200;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;
osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());
gc-setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
osgViewer::View* view1 = new osgViewer::View;
viewer-addView(view1);
view1-setName(Visualization);
osg::Node* node = osgDB::readNodeFile();
_root-addChild(node);
view1-setSceneData(node);
view1-setCameraManipulator(new osgGA::TrackballManipulator());
osg::Vec3 LookFrom,LookAt,Up;
LookFrom = osg::Vec3(1,1,1);
LookAt = osg::Vec3(0,0,0);
Up = osg::Vec3(0,0,3);
view1-getCameraManipulator()-setHomePosition(LookFrom,LookAt,Up);
view1-setUpViewAcrossAllScreens();
osgViewer::View* view2 = new osgViewer::View;
view2-setName(DepthCamera);
view2-setSceneData(view1-getSceneData());
view2-setCameraManipulator(new osgGA::TrackballManipulator());
osg::ref_ptrosg::Camera camera2 = new osg::Camera;
view2-setCamera(camera2);
view2-setCameraManipulator(new osgGA::TrackballManipulator());
view2-getCamera()-setViewport(new osg::Viewport 
(0,0,traits-width,traits-height));
view2-getCamera()-setGraphicsContext(gc.get());
camera2-setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera2-setClearMask(GL_DEPTH_BUFFER_BIT);
camera2-setRenderOrder(osg::Camera::POST_RENDER);
camera2-setAllowEventFocus(false);
osg::Vec3 LookFrom2,LookAt2,Up2;
LookFrom2 = osg::Vec3(3,3,3);
LookAt2 = osg::Vec3(0,0,0);
Up2 = osg::Vec3(0,0,1);
view2-getCameraManipulator()-setHomePosition(LookFrom2,LookAt2,Up2);
osg::ref_ptrosg::Image depthReadP = new osg::Image;
depthReadP-allocateImage(2400,1200,1,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE);
camera2-attach(osg::Camera::DEPTH_BUFFER, depthReadP.get());
viewer-addView(view2);
_root-addChild(camera2);
camera2-addChild(node);
viewer-setDataVariance(osg::Object::DYNAMIC);
viewer-setThreadingModel(osgViewer::CompositeViewer::AutomaticSelection);
viewer-realize();
while (!viewer-done()){
 viewer-frame();
double time = osg::Timer::instance()-time_m();
std::cout  TIME:   time  std::endl;
std::stringstream sst;
sst  ../images/depthReadP  time  .bmp;
osgDB::writeImageFile(*depthReadP.get(),sst.str());
}
} 

Thank you!

Cheers,
Manos

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





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


[osg-users] multi-thread of osgviewer on Android

2014-10-09 Thread 夏清然 Xia Qingran
Hi,
I am new to OSG and have developed my own osgviewer client on Android
OpenGL ES 2.0 based on osgAndroidExampleGLES2.

Now I want the osgviewer of android to access network files like http:// by
curl plugin. However I found a big problem of it: when the network
transmission time is too long, the FPS of my app is too slow, less than 1.

I think it is because it is a single-threaded client, http curl will block
the rendering. Through the online docs,
http://www.openscenegraph.org/index.php/documentation/platform-specifics/android/43-building-openscenegraph-for-android-3-0-2,
the Android viewer does not support multi-thread. So I only
use:_viewer-setThreadingModel(osgViewer::ViewerBase::SingleThreaded) in my
code.

How to solve my problem? Is there a very elegant solution of it?

Thanks.


regards,
夏清然
Xia Qingran
qingran@gmail.com
http://www.qingran.net
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgAndroidExampleGLES2 can not drag and zoom the model cow.osg.

2014-10-09 Thread Xia Qingran
Hi, Sergey

First thanks for your reply. I have solved this problem :) 


Sergey Kurdakov wrote:
 Hi Xia,
 
 
 for loading cow.osg there was answer - there is need to write your own 
 loader, which will pass textures to respective  shaders
 
 
 to save osg models in OpenGL ES 2.0 friendly format there is a write plugin 
 https://github.com/cedricpinson/osg/tree/master/src/osgPlugins/osgjs 
 (https://github.com/cedricpinson/osg/tree/master/src/osgPlugins/osgjs) 
 
 
 but you would have to write a loader yourself 
 
  though older files from https://code.google.com/p/hogbox/ 
 (https://code.google.com/p/hogbox/) - you can retrieve older versions of 
 files via source control app, as new code has little code for loaders,  have 
 some hints to help to write your own loader.
 
 
 
 Regards
 Sergey
 
 
 On Sun, Sep 28, 2014 at 7:06 AM, Xia Qingran  () wrote:
 
  And there is another problem, the texture of cow.osg can not be loaded. I 
  have copied the Images directory to my phone.
  
  ...
  
  Thank you!
  
  Cheers,
  Xia
  
  --
  Read this topic online here:
  http://forum.openscenegraph.org/viewtopic.php?p=61191#61191 
  (http://forum.openscenegraph.org/viewtopic.php?p=61191#61191)
  
  
  
  
  
  ___
  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=61269#61269





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


Re: [osg-users] OpenGL ES 2.0 can not load texture of model, OpenGL ES 1.0 can load smoothly

2014-10-09 Thread Xia Qingran
Hi,
I have solved this. Thanks everyone.
... 

Thank you!

Cheers,
Xia

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





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