Re: [osg-users] OSG depth peeling and multisampling

2016-11-16 Thread Peter Bako
Thank you Sebastian for the information.

It seems to be over my capabilities but I will try to make some research in 
this area.
Thank you once more.

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





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


Re: [osg-users] OSG depth peeling and multisampling

2016-11-16 Thread Peter Bako
No idea anyone?
Thanks in forward

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





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


[osg-users] OSG depth peeling and multisampling

2016-09-08 Thread Peter Bako
Hi,

In my application, I have implemented true transparency using the depth peeling 
method described in osg examples.

But now I got a problem, because I want to use multisampling but this doesnt 
work with the depth peeling transparency implementation.

Then I found out that by attaching the color buffer to the main DepthPeeling 
camera, you can specify the multisamplesamples, but then the transparency 
rendering is not correct

I dont have many skills with osg, but hopefully you can give me some ideas.



Thank you!

Cheers,
Peter

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




Attachments: 
http://forum.openscenegraph.org//files/transptest_video_160.zip
http://forum.openscenegraph.org//files/4xaa_187.png
http://forum.openscenegraph.org//files/noaa_149.png


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


[osg-users] Polygon offset for line geometries, Z-fighting of edges and triangles

2016-07-14 Thread Peter Bako
Hi,

In my application, I am manipulating solid 3D models with edges represented by 
GL_LINES primitiveSet on an osg::Geometry.
The problem is that I cannot use osg::PolygonOffset, to "highlight" the edges 
(to avoid dashed edges caused by Z-fighting). This was not working at all, I 
don't see any difference.

Then I checked the osgFX::Scribe effect and I have realized that there is a 
triangle model renedered with LINE polygon mode

Code:
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);



I've tried to simulate the edges using triangles with (almost) no surface and 
set the polygon mode to LINE ...
The result is that now I see complete and "not dashed" lines, but the edges are 
sometimes blinking and "highlighted" through triangles, even they shouldn't be 
visible. Please check the attached video.

If it is possible, I would like to avoid using offects with multiple passes to 
achieve my goal.

I am using osg 3.1.3

Thank you!

Cheers,
Peter

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




Attachments: 
http://forum.openscenegraph.org//files/edge_rendering_problem_191.zip
http://forum.openscenegraph.org//files/dashed_255.png


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


Re: [osg-users] draw callbacks

2016-04-19 Thread Peter Bako
I've found the problem, Javier's code is correct.
I was missing this command:


Code:
osg::DisplaySettings::instance()->setMinimumNumStencilBits(1);



Maybe it helps someone

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





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


Re: [osg-users] draw callbacks

2016-03-30 Thread Peter Bako
Hi,

I tried Javier's example, but I don't know how to modify the code, so that the 
stencil plane covers the "holes" on the clipped geometry.
In this case the plane is renedered over the whole scene. 
I tried to remove the transformation and projection, then the plane was 
rendered on the correct position but it was still a square.

I know, how should it work, but I cannot find a solution..
How should I change it? can you help me?
Thank you!


Code:


#include 
#include 
#include 
#include 

class CappingTechnique : public osgFX::Technique {

private:
osg::ref_ptr _capPlane;

public:
virtual bool validate(osg::State&) const
{ return true; }

META_Technique("CappingTechnique","Pimpel capping technique");
/// Constructor
CappingTechnique()
{
// Build the plane to draw with the stencil mask
osg::Geometry *geometry = new osg::Geometry();
osg::Vec3Array *vertices = new osg::Vec3Array();
osg::Vec4Array *colors = new osg::Vec4Array();

vertices->push_back(osg::Vec3(-1.0, -1.0, 0.0));
vertices->push_back(osg::Vec3(-1.0, 1.0, 0.0));
vertices->push_back(osg::Vec3(1.0, 1.0, 0.0));
vertices->push_back(osg::Vec3(1.0, -1.0, 0.0));
geometry->setVertexArray(vertices);
colors->push_back(osg::Vec4(1.0, 0.0, 1.0, 1.0));
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));

osg::Geode *geode = new osg::Geode();
geode->addDrawable(geometry);

osg::Transform *trans = new osg::Transform();
trans->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
trans->addChild( geode );

osg::Projection *proj = new
osg::Projection(osg::Matrix::ortho2D(-1,1,-1,1));
proj->addChild( trans );

_capPlane = proj;

}
protected:
virtual void define_passes()
{
// pass #0
{
osg::ref_ptr ss = new osg::StateSet;
osg::Stencil *stencil = new osg::Stencil;
stencil->setFunction(osg::Stencil::ALWAYS, 0x0, ~0);
stencil->setOperation(osg::Stencil::INVERT, 
osg::Stencil::INVERT, osg::Stencil::INVERT);
ss->setAttributeAndModes(stencil, 
osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE);
ss->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
addPass(ss.get());
}
// pass #1
{
osg::ref_ptr ss = new osg::StateSet;
osg::Stencil *stencil = new osg::Stencil;
stencil->setFunction(osg::Stencil::NOTEQUAL, 0x0, ~0);
stencil->setOperation(osg::Stencil::ZERO, 
osg::Stencil::ZERO,osg::Stencil::ZERO);
ss->setAttributeAndModes(stencil, 
osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE);
osg::Depth *depth = new osg::Depth();
depth->setWriteMask(false);
ss->setAttributeAndModes( depth, 
osg::StateAttribute::ON );
addPass(ss.get());
}
}

virtual osg::Node *getOverrideChild(int pass){
switch(pass) {
case 1:// Second pass (pass #1) draws the cap plane
return _capPlane;
break;
default:
return NULL;
break;
}
}
};

class CappingEffect : public osgFX::Effect {
public:
CappingEffect() : osgFX::Effect() {}
CappingEffect( const CappingEffect& copy, const osg::CopyOp 
op=osg::CopyOp::SHALLOW_COPY )
:   osgFX::Effect(copy, op) {}

META_Effect( osgFX, CappingEffect, "CappingEffect", "", "" );
protected:
virtual bool define_techniques(){
CappingTechnique* technique = new CappingTechnique();
addTechnique(technique);
return true;
}
};

int main( int argc, char** argv )
{
//load any node
osg::ref_ptr scene = new osg::Geode;
scene->addDrawable( new TeapotDrawable(1.0f) );

osg::ClipNode* clipnode = new osg::ClipNode; 
osg::ref_ptr clipplane = new osg::ClipPlane(); 
clipplane->setClipPlane(0, 0, -1, 0); 

clipnode->addClipPlane(clipplane); 
clipnode->addChild(scene.get()); 

CappingEffect* capping_effect = new CappingEffect(); 
  

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] Resetting buttonMask of GUIEvents

2014-10-08 Thread Peter Bako
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?
Thanks!

Cheers,
Peter

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





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


Re: [osg-users] snapshot with fixed size

2014-04-16 Thread Peter Bako
Hello Flallaur.

Try to use the osgPoster example. It can create screenshots with any size. I 
was recently doing a very similar thing and osgPoster helped me much. I don't 
know how will it act with your night vision but I would definitely give it a 
try.

Cheers,
Peter

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





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


[osg-users] Text with border

2014-04-16 Thread Peter Bako
Hello!

Does anyone have an idea, how to create osgText with border? for example white 
text with black border. I need this, because I want to make screenshots of 
scenes with texts but the background can be any color so the white text as I 
use it now, is not readable every time.

My only idea is to create two osgText::text objects, one with normal font 
(white), one with bold (black) and put the black text a little bit behind the 
white. The problem is that the text is always facing to the camera eye 
(setAutoRotateToScreen(true)), so this wouldn't work. 
If there is no other solution, I can switch this option off.

Thank you for your ideas.

Cheers,
Peter

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





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


[osg-users] Virtual simulation of CNC machine - problem with intersections and setMatrix() probably

2013-10-03 Thread Peter Bako
Hello guys,

I am programming a virtual simulation of CNC milling machines. I created a 
model which contains the kinematics - axes with limits etc.
I also implemented a function, which calculates the axis values, so that the 
tool follows the mouse which points to the surface of the workpiece. This works 
fine, the problem is only when the workpiece is moving together with the table 
and not only the head around the workpiece (one axis is on the table which the 
workpiece is on). In this case, the workpiece moves so in the next step, the 
mouse points to another place of the workpiece. This results into an 
uncontrolled jumping of the machine axis. 

I tried to handle this with moving the camera the same vector as the workpiece 
moves, so that then it looks like that the workpiece stays always in the same 
position (and the machine is moving around) - watch video.
This is working ALMOST fine, but sometimes there is still jumping of the tool. 
Here are the steps what I do in the MOUSE DRAG event handler
1. I store original axis values.
2. I make an intersection on the workpiece using 
osgUtil::LineSegmentIntersector.
3. I set all axis values to 0 and apply them using setMatrix() on axis nodes 
(which actually inherit from osg::MatrixTransform).
4. I calculate the new axis values and apply them using setMatrix() on axis 
nodes.
5. I perform a camera movement dependent from the axis value change.

I assume that there can be a problem with intersection - is it possible that I 
get an intersection from a frame before? I found out that If I make faster 
movements, the jumping is bigger. Or can it be maybe caused by multitreading? I 
don't know the background exactly.

If you watch the video attached, you will see that the workpiece is never 
jumping, only the tool.

Thank you for reading and watching! I look forward for your suggestions.

Cheers,
Peter

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




Attachments: 
http://forum.openscenegraph.org//files/machine_tool_jumping_773.zip
http://forum.openscenegraph.org//files/screenshot_103.png


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


Re: [osg-users] Virtual simulation of CNC machine - problem with intersections and setMatrix() probably

2013-10-03 Thread Peter Bako
Hello Alberto.

I will try your suggestion with the intersection points.

regarding the framework - I use .NET, Windows forms, WPF, OSG, OpenCascade and 
some other technologies.
The graphic frame what you see is created in WPF, the graphic window of osg 
is rendered on a windows forms window, which is over the WPF window. The bottom 
transparent menu is also a separate window renedered over the osg window. And 
the mouse pointer is set on the .NET windows forms window, which the osg is 
renederd on.

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





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


Re: [osg-users] Virtual simulation of CNC machine - problem with intersections and setMatrix() probably

2013-10-03 Thread Peter Bako
Hello again.

My assumptions were correct: here is a list of points


Code:
Point: -152.9, 216.3, -21.5
Point: -148.9, 215.4, -21.5
Point: -152.4, 214.6, -21.5
Point: -155.7, 213.7, -21.5
Point: -158.7, 212.8, -21.5
Point: -151.6, 211.9, -21.5
Point: -151.4, 211.0, -21.5
Point: -150.8, 210.2, -21.5
Point: -150.8, 209.3, -21.5
Point: -150.6, 208.4, -21.5
Point: -150.1, 207.5, -21.5
Point: -150.1, 206.6, -21.5
Point: -149.8, 205.8, -21.5
Point: -149.5, 204.9, -21.5
Point: -149.0, 204.0, -21.5
Point: -149.0, 203.1, -21.5
Point: -148.5, 201.4, -21.5
Point: -147.7, 200.5, -21.5
Point: -146.7, 199.6, -21.5
Point: -145.4, 198.7, -21.5
Point: -143.8, 197.8, -21.5
Point: -147.2, 197.0, -21.5
Point: -150.3, 196.1, -21.5
Point: -152.9, 194.3, -21.5
Point: -155.3, 193.4, -21.5
Point: -157.4, 192.5, -21.5
Point: -145.6, 191.7, -21.5
Point: -145.4, 190.8, -21.5
Point: -143.6, 191.2, -21.5
Point: -140.3, 191.7, -21.5
Point: -135.2, 191.3, -21.5
Point: -128.5, 191.7, -21.5
Point: -121.6, 190.9, -21.5
Point: -137.0, 190.4, -21.5
Point: -150.8, 190.9, -21.5
Point: -163.1, 191.4, -21.5
Point: -175.1, 190.5, -21.5 //Here it starts to jump
Point: -132.2, 190.9, -21.5
Point: -87.7, 191.4, -21.5
Point: -59.1, 190.5, -21.5
Point: -29.1, 191.0, -21.5
Point: -9.6, 171.0, -67.7
Point: 298.0, 146.6, -124.2
Point: 298.0, 146.6, -125.4
Point: 298.0, 145.6, -125.7
Point: 298.0, 144.5, -125.9
Point: 298.0, 144.5, -127.1
Point: 298.0, 143.4, -127.4
Point: 298.0, 142.3, -127.6
Point: -124.1, 185.8, -21.5   // here it is again correct
Point: -119.7, 176.6, -21.5
Point: -131.3, 175.8, -21.5
Point: -126.4, 174.9, -21.5
Point: -121.3, 174.0, -21.5
Point: -132.1, 173.1, -21.5
Point: -126.4, 172.3, -21.5
Point: -136.7, 171.4, -21.5
Point: -130.5, 170.5, -21.5
Point: -124.1, 169.6, -21.5
Point: -133.6, 168.8, -21.5
Point: -117.1, 167.9, -21.5
Point: -116.6, 167.0, -21.5
Point: -116.6, 166.2, -21.5



so the intersections are calculated wrong. In the rendering it seems to be OK, 
but the real intersection point is got from a different place.

Maybe Robert can have an idea how to fix this problem?

Thanks a lot.

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





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


Re: [osg-users] Virtual simulation of CNC machine - problem with intersections and setMatrix() probably

2013-10-03 Thread Peter Bako
Hello Alberto.

Actually I've found the problem.
The reason, why it didn't work, was, that I was changing only the matrix of my 
camera manipulator. I have to change also the viewMatrix of the camera, not 
only the manipulator. Now IT WORKS! Thank you!

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





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


Re: [osg-users] Changing material of geodes/drawables during rendering - crash

2013-09-03 Thread Peter Bako
Thank you for your answers!
It looks like it works.

Peter

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





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


[osg-users] Changing material of geodes/drawables during rendering - crash

2013-08-29 Thread Peter Bako
Hello guys.

What is the correct way to change materials during rendering? What callbacks 
should I use, update callback?
Sometimes I get a crash and I assume it is becasue of changing the material.

Should I use special updateCallback on every geode/geometry I am changing, or 
it is enough to use the callback on a parent and change the state attributes 
also on children?

Should the data variance be DYNAMIC on these nodes?

Thank you!

Cheers,
Peter

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





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


[osg-users] osg::Text setText - changing text during rendering

2013-06-12 Thread Peter Bako
Hi,

I have problems with changing text during rendering. I am trying to change the 
text in the update callback of the text node, but sometimes I get a crash 
(operator not incrementable) in the osg::osgText.

Here is what I do in the update callback (Call the updateText() function on a 
different object):

Code:

void PiMeasurementGeomCallback::update( osg::NodeVisitor* nv, 
osg::Drawable* geom){
 if(textDirty){
textDirty = false;
PiMeasurement* mes = 
dynamic_castPiMeasurement*(measurementGroup.get());
if(!mes) return;
mes-updateText();
};
};


and here is the updateText() function:

Code:
bool PiMeasurementLine::updateText(){
double length = (_endPoint-_startPoint).length();
length = 
vectorAlongVector(PiSolidComponent::getv3(_movePlane),(_endPoint-_startPoint));
if(length/2-(20*ratio)  12*ratio){
textGeom-setAlignment(osgText::TextBase::CENTER_BOTTOM 
);
}else{
textGeom-setAlignment(osgText::TextBase::CENTER_CENTER 
);
}
char s[20];
sprintf(s,%.2f,length);
osgText::String str = osgText::String(s);
textGeom-setText(str); / if I comment out this, I get 
no crash but I have to change the text anyhow


textGeom-setPosition(PiSolidComponent::getv3(_movePlane)*(length/2));
return true;
}



The textGeom is actually the object where the update callback is attached(the 
same as in geom parameter of the update function),

What is the correct way to change the text of an osgText::Text geometry?

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] osg::Text setText - changing text during rendering - What is the correct way to change the text in osgText::Text?

2013-06-12 Thread Peter Bako
Hello Robert and Pjotr.
Actually, I was sure that the data variance is set to Dynamic. But now after a 
closer look I've found out that instead of 
text-setDataVariance(DYNAMIC); 
I wrote 
this-setDataVariance(DYNAMIC);

Thanks to you I've found the problem!
Have a nice day and thank you very much!

Peter

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





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


Re: [osg-users] HowTo use UPDATE_TO_VERSION for custom osg::Object separate from osgVersion()

2013-04-24 Thread Peter Bako
Hi Wang

Yes you are right, later I've found out that I merged the serialization stuff 
in my local osg project and I used it. now I had to recompile it becuase I was 
missing some things and then I found out that its not in the 3.1.5 version or 
any other version.
never mind... My problem is fixed now.

Good luck to your business ;) ... and I hope you can improve the serialization 
versioning soon :-), so that we can get it in the next osg versions..

Good luck and thanks a lot!

Cheers,
Peter

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





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


Re: [osg-users] HowTo use UPDATE_TO_VERSION for custom osg::Object separate from osgVersion()

2013-04-18 Thread Peter Bako
Hello Wang.

Recently, I downloaded osg version 3.1.5 and I found out, that my 
UPDATE_TO_USER_VERSION macros don't work anymore. I digged into the osg source 
and found out that it is not there anymore, so I searched the forum but I 
didn't find any reason why was it removed.

I used osg 3.1.1 before. I don't want to force you, I just want to ask, why was 
it removed if it was already there once?

Thank you!

Cheers,
Peter

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





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


[osg-users] Camera manipulator zoomFactor

2013-03-21 Thread Peter Bako
Hi,

Is there an easy way to invert the wheel zoom factor on 
TrackballCameraManipulator? I have a feeling that once I've seen a property 
where you can set this, and if you set it to -1, the zoom scrolling will behave 
opposite.
I have a cameraManipulator derived from TrackballCam..Man.. the second way will 
be to handle the mouse wheel event, but i hope there is an easier way.
I've searched on the forum but didn't find a solution.

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Camera manipulator zoomFactor

2013-03-21 Thread Peter Bako
I am sorry about the useless topic.
I was searching the property on a wrong object

manipulator-setWheelZoomFactor()

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





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


Re: [osg-users] Remove node runtime from another thread

2013-01-28 Thread Peter Bako
Hi,

I solved my problem in this way:

I have a loop, where I call the frame() method. Everytime, I want to make a 
change in the scene graph, I wait, until frame() is finished and then if a flag 
changeStructure is true, I make the change in the scene graph structure. I 
check this flag in every loop after frame() is finished.

I hope, this way is safe,  I read it somewhere here on the forum, ah here: 
http://forum.openscenegraph.org/viewtopic.php?t=9227

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Sharing some screenshots of my present work :-)

2013-01-28 Thread Peter Bako
Good job! 
It's looking really nice!

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





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


[osg-users] Remove node runtime from another thread

2013-01-25 Thread Peter Bako
Hi,

I want to remove and add a child from/to a group runtime, while rendering is 
running, moreover, I am doing this from a different thread. What is the thread 
safe way to do it? Which callback should I use, or how would you do it? 

If I remove the node in the update callback I get crashes. On adding, it works.

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Remove node runtime from another thread

2013-01-25 Thread Peter Bako
Hi robert, thank you for the reply


 If using an update callback you have to be careful
 about invalidating iterators for the thread calling the update
 callback.

Do you have an example, where this is done? what iterators should I check? Yes, 
as I do it now - sometimes it crashes, and the message is : iterator not 
incrementable. The exception comes deep from osg libraries.

... 

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] LineSegmentIntersector gives incorrect results (intersections missing)

2012-11-16 Thread Peter Bako
Hello Robert.

I digged a bit into the OSG source code and I found out that its a precision 
problem. I use big models where the vertex coordinate values are 1000.
I don't know the exact process of the intersection search, but I assume that 
the lineSegment is clipped in the  

lineSegmentIntersector.cpp

Code:
bool LineSegmentIntersector::intersectAndClip(osg::Vec3d s, osg::Vec3d 
e,const osg::BoundingBox bbInput)

 
function to the values, where the lineSegment is slightly longer, than the 
bounding sphere of the geometry. 

Code:
 osg::Vec3d bb_min(bbInput._min);
osg::Vec3d bb_max(bbInput._max);

#if 1
double epsilon = 1e-4;
bb_min.x() -= epsilon;
bb_min.y() -= epsilon;
bb_min.z() -= epsilon;
bb_max.x() += epsilon;
bb_max.y() += epsilon;
bb_max.z() += epsilon;
#endif



There is an epsilon value, which is currently set to 1e-4. I would suggest to 
set it bigger (1e-2 f. ex.). If I change it to 1e-2, I don't get this problem 
anymore.

What is the exact reason of lineSegment clipping?

Thank you!

Cheers,
Peter
Code:




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





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


[osg-users] Custom cursors and OSG used from .NET

2012-11-13 Thread Peter Bako
Hello!

I am creating an osg scene, which is rendered to a .NET picture box on a 
windows forms scene.


Code:

void startInFormWinCpp(int wh){ //wh is a window handle
HWND hwnd = (HWND)wh;
baseViewer = new osgViewer::Viewer();
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits();

traits-inheritedWindowData = new osgViewer::GraphicsWindowWin32::WindowData( 
hwnd );
traits-setInheritedWindowPixelFormat = true;
traits-supportsResize = true;

RECT rect;
::GetWindowRect( hwnd, rect );

traits-x = 0;
traits-y = 0;
traits-width = rect.right - rect.left;
traits-height = rect.bottom - rect.top;
traits-windowDecoration = false;
traits-doubleBuffer = true;
traits-sharedContext = 0;


osg::ref_ptrosg::GraphicsContext graphicsContext = 
osg::GraphicsContext::createGraphicsContext( traits.get() );
baseViewer-getCamera()-setGraphicsContext( graphicsContext.get() );
baseViewer-getCamera()-setViewport( new osg::Viewport( 0, 0, traits-width, 
traits-height ) );
baseViewer-getCamera()-setProjectionMatrixAsPerspective(30.0f, 
static_castdouble(traits-width)/static_castdouble(traits-height), 1.0f, 
1.0f);
baseViewer-setCameraManipulator(new osgGA::TrackballManipulator()); 
camera=baseViewer-getCamera();
camera-setClearColor(osg::Vec4(0.7f, 0.7f, 0.7f, 1.0f));
osg::ref_ptrosg::Group rootViewGroup= new osg::Group();
rootViewGroup-addChild(rootGroup);
baseViewer-setSceneData( rootViewGroup.get() );
_beginthread(renderStatic, 0, (void*)this);
}




I want to use some custom cursors depending from what am I doing. But on these 
objects, there are no functions to set the cursor (only if I would get a 
osgViewer::GraphicsWindowWin32). So I tried to change the cursor in .NET, this 
works only sometimes (on mouseDown I change the cursor - this is OK, on mouse 
up I change it again, but the default arrow is shown istead of my custom 
cursor).
I also tried to set traits-useCursor = false; but then the cursor 
disappeared (after mouseUp).

So the question is -  how can I disable the overriding of the cursor in osg? OR 
how can I use a custom cursor - in OSG, when I use a HWND from .NET to render 
the scene? Has anyone experience with this?

Thank you for your answers!

Cheers,
Peter[/code]

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





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


Re: [osg-users] LineSegmentIntersector gives incorrect results (intersections missing)

2012-10-23 Thread Peter Bako
I use the LineSegmentIntersector in my application to select planar faces. The 
problem is that sometimes when I click on the face facing to you (check the 
red Xes on the picture), I get no intersection of this face. I get only an 
intersection on the face which is not visible from this view - the bottom 
face. 
Then sometimes it happens, that the user wants to select a face, but an 
invisible face is selected instead, but he doesn't know it because he doesn't 
see it, even if its highlighted.

i made this sample application to simulate my problem - when I click on the 
positions where the red crosses are, normally I should get 2 intersections - 
first the face where I drew the red crosses and then to bottom face which we 
don't see. Sometimes, I get only the second (see the debug output on the 
picture).

I think this is a problem.

Thank you!

Cheers,
Peter

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





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


[osg-users] LineSegmentIntersector gives incorrect results (intersections missing)

2012-10-17 Thread Peter Bako
Hi,

I've got a problem with line segment intersector. Sometimes I get only one 
intersection (on the bootom side of the table), while I should get two. 
Please check the screenshot.

Do you have any idea why this happens? What should I do?
STLFILE.stl (ZIPPED) is attached
Thank you!

Cheers,
Peter

Hold CTRL key to activate intersection output.
This is the code I use:

Code:
#include stdafx.h
#include osgViewer/Viewer
#include osgDB/ReadFile
#include osgUtil/LineSegmentIntersector


class PickHandler : public osgGA::GUIEventHandler
{
public:
  
virtual bool handle( const osgGA::GUIEventAdapter ea, 
osgGA::GUIActionAdapter aa )
{
if ( ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE ||
 ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ||
 !(ea.getModKeyMask()osgGA::GUIEventAdapter::MODKEY_CTRL) )
return false;

osgViewer::Viewer* viewer = dynamic_castosgViewer::Viewer*(aa);
if ( viewer ){
osg::ref_ptrosgUtil::LineSegmentIntersector intersector =
new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), 
ea.getY());
osgUtil::IntersectionVisitor iv( intersector.get() );
iv.setTraversalMask( ~0x1 );
viewer-getCamera()-accept( iv );

if ( intersector-containsIntersections() ){
const 
osgUtil::LineSegmentIntersector::Intersection result =
*(intersector-getIntersections().begin());
printf(Intersection count:%d. Coordinates: %.2f, %.2f, 
%.2f\n, 
intersector-getIntersections().size(), 
result.getWorldIntersectPoint().x(),result.getWorldIntersectPoint().y(),result.getWorldIntersectPoint().z());

}
}
return false;
}

};

int main( int argc, char** argv )
{
osg::ref_ptrosg::Node model1 = osgDB::readNodeFile( STLFILE.stl );
osg::ref_ptrosg::Group root = new osg::Group;
root-addChild( model1.get() );
osg::ref_ptrPickHandler picker = new PickHandler;
osgViewer::Viewer viewer;
viewer.setSceneData( root.get() );
viewer.addEventHandler( picker.get() );
return viewer.run();
}




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




Attachments: 
http://forum.openscenegraph.org//files/intersection_errors_639.png
http://forum.openscenegraph.org//files/stlfile_974.zip


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


Re: [osg-users] OSG Serialization - changes on custom Classes

2012-08-21 Thread Peter Bako
Hi mr. Wang Rui.

Thank you for your response. I am actually an owner of your OSG book :-).
I tried your suggestion, it works, but the limitation is that we can have only 
2 versions of osgb files (old format - with the schema) and the new (actual 
format).
Does this mean that there is no way to make more versions readable for my 
application? For example, could we generate schema for every version and try to 
load the file with the schema from the oldest version, if not succeed, then 
with the newer version, then with newer and so on until the load is successful 
(loaded component is not NULL).
I don't see under the hood of binary serialization, I couldn't find the correct 
file.

I need this functionality because I know, that my application will grow after 
release and maybe we will need to change the serialization after the release to 
the customers.
Do you have any other idea to make this possible?

Thank you once more!

Cheers,
Peter

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





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


[osg-users] OSG Serialization - changes on custom Classes

2012-08-20 Thread Peter Bako
Hello guys,

I am using OSG serialization on my custom classes derived from 
osg::MatrixTransform and osg::Geometry.
I already use this serialization for some time, so I have many .osgb files 
exported on my disk, but now, I want to add some new properties to my Class and 
serialize them (new ADD_BOOL_SERIALIZER). The problem is, that I cannot load 
the old .osgb files anymore. It works only on .osgt files.
Is there any way, how to extend my serialization, while the old files will be 
still loadable?

Thank you!

Cheers,
Peter

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





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


Re: [osg-users] Is it possible to do boolean operations with objects (primitives)?

2012-08-20 Thread Peter Bako
Hi,

This is not possible to do with native osg function. What you say, is an 
operation on Solid models, osg scene is mainly vertices and triangles, there 
is no information about volume.

If you want to do this, try OpenCASCADe. It is also free, but there is a little 
documentation about it and its a very complex library I think.

Thank you!

Cheers,
Peter

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





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


[osg-users] VS2010 64bit compile problem

2012-01-04 Thread Peter Bako
Hi,

I get errors, when I try to compile my project on visual studio for 64bit 
platform. Before on ANYCPU configurations I had no problems. The error which I 
get is 

 variable WINGDIAPI is not a type name 
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h 

and other 150 errors because of this wingdiapi.

I changed the platform, preprocessor definitions to WIN64;_WIN64;_DEBUG, the 
path to 64bit dlls, libs and include directory.

What else should I change?

I am sending my project in the attachment.

One more question: Is there any performance or other advantage if compiled for 
64bit instead of anyCPU?

Thank you!

Cheers,
Peter

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




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


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


Re: [osg-users] VS2010 64bit compile problem

2012-01-04 Thread Peter Bako
Yes, sorry, I'm using VS2010 on Windows 7 64bit
Peter

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





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


Re: [osg-users] VS2010 64bit compile problem

2012-01-04 Thread Peter Bako
Hi!
Thank you very much, you were right, I have to include windows.h on the very 
beginning.

So now I am able to compile my app but now I get an error after launch :-(.

The application was unable to start correctly (0xc07b). Click OK to close 
the application.

Does anyone have an idea what should I do?

Thank you once again!

Cheers,
Peter

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




Attachments: 
http://forum.openscenegraph.org//files/error_596.png


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


Re: [osg-users] VS2010 64bit compile problem

2012-01-04 Thread Peter Bako
Hello zonk and others!
Thank you for the idea to use dependency walker, I haven't used it before. Now 
I found out, that x86 libraries are used at runtime instead of x64, because I 
forgot to put the path to x64 dlls into the %PATH% variable.

Thank you very much!
Peter

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





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


[osg-users] Implementing clone() on class derived from osg::Geometry and osg::MatrixTransform

2011-12-11 Thread Peter Bako
Hello guys! 
I have run a search over the topics, but I didn't find an answer for my 
question, so here it is:

I have my own derived class called PiFaceGeometry, which is derived from 
osg::Geometry class, I use this to work with faces of solids - so I have the 
type of face - cylinder, plane, and other which I store within this class and 
also some other properties.
I have a different class called SolidComponent, which is derived from 
osg::MatrixTransform and represent machinery workpieces and tools.

The problem is that sometimes I need to clone the SolidComponent (which 
contains Geode as child with PiFaceGeometries, and can also contain other 
SolidComponents as children). I think, I need a deep copy, because sometimes I 
have to change the color of triangles, or am I wrong? The question is, how 
should I reimplement the clone() function? I looked also into the osg source 
code but I didn't understand the way, how to do this.

How can I force the program to call PiFaceGeometry::clone() if this is only a 
child of object, on which I called clone()?
I am sorry If this question is silly, I am not a good C++ programmer and I hate 
C++ :-P.

Thank you for your responses!

Cheers,
Peter
Code:

class PiFaceGeometry: public osg::Geometry {
public:
 osg::ref_ptrosg::IntArray edges;
 PiSurfaceType surfType;
 void changeFaceColor(osg::Vec4 color){...};
 PiFaceGeometry * clone(const osg::CopyOp copyop ){
  //how can I reuse Geometry::Clone(), if it returns a Geometry but I need 
PiFaceGeometry?
 }
};




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





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