[osg-users] computeIntersections function when window size changes

2011-02-03 Thread Mathieu Scorpionis
Hello

I've got trouble by using the computeIntersections function with OSG.

In my whole application I use a callback when the user clicks in the current 
window. With this callback, I receive two integers (x  y), corresponding to 
the mouse cursor position.
Afterwards, I compute two floats X  Y corresponding to the cursor position in 
the scale [-1.0;1.0] :
X = (2.f * x / width ) - 1.f;
Y = (-2.f * y / height ) + 1.f;
where:
width = windows[0]-getTraits()-width;
height = windows[0]-getTraits()-height;
I use windows like this:
osgViewer::Viewer::Windows windows;
Viewer-getWindows(windows);

For each click I do:
osgUtil::LineSegmentIntersector::Intersections intersections;
m_pViewer-computeIntersections(X, Y, intersections);

And this seems to be OK.

The problem occurs when i change the size of the window. If I increase it, even 
if I click around an object, some pixels farther, it still gets an 
intersection, while it shouldn't. So the object seems to be bigger than it is.

Do you have an idea of what i must do in order the function to be still 
operative ? I probably have to change something in the traits, isn'it ?

Thanks in advance for your help...

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





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


[osg-users] Transparency Invisibility

2010-11-23 Thread Mathieu Scorpionis
Hello OSG Community

I am currently playing with opacity/transparency capabilities of geodes in a 
model.
In that way, i use:

material = (osg::Material *) 
Geode-getStateSet()-getAttribute(osg::StateAttribute::MATERIAL);
Geode-getStateSet()-setMode( GL_BLEND, osg::StateAttribute::ON );
material-setTransparency(osg::Material::FRONT, 1.-opacity);
Geode-getStateSet()-setAttributeAndModes(material, 
osg::StateAttribute::OVERRIDE);

It works, the geode becomes transparent.

But is there a way to see objects behind this geode ?
I mean : if i use Geode-setNodeMask(0x00); the geode is invisible and I 
can see what is behind, but not with the transparency effect.

Please, do you have an idea how managing the code if i want to see what is 
behind a transparent object ?


Cheers,
Mathieu

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





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


Re: [osg-users] Transparency Invisibility

2010-11-23 Thread Mathieu Scorpionis
Hi Juan

Thank you very much for the precise answer.
I try this !

Cheers,
Mathieu

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





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


Re: [osg-users] To freeze an AnimationPath to a desired time

2010-07-23 Thread Mathieu Scorpionis
Good morning,

I didn't find the solution yet... Impossible to go to a static desired point of 
the animation. If you have an idea...

Thanks a lot.

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





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


[osg-users] To freeze an AnimationPath to a desired time

2010-07-20 Thread Mathieu Scorpionis
Hello community

Given a model with an AnimationPath predefined in a file, with about 200 points 
(6.6 seconds of animation), I would like my application to allow the user to go 
to one of those points and freeze the animation.
Typically, it would be with a slider.

For that, I thought that I had to pause the animation by:
pAnimationPathCallback-setPause(true);

But I don't know how to indicate the animation to go to the desired time (or to 
the desired point).
Maybe by defining an offset, but it didn't work.

You understood, it is like a video player...

Thanks in advance.

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





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


Re: [osg-users] StateSet and changes

2010-07-19 Thread Mathieu Scorpionis
Hello

Yes, great job ! 
There was an other problem : I did an optimize() of my model  ; at that moment, 
all stateSet lost their geode parent... and all of them were suddenly linked to 
the same and main parent (the cabine of the aircraft).

Now is much better !
Thanks again.

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





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


Re: [osg-users] I'm lost the UpdateCallbacks

2010-07-19 Thread Mathieu Scorpionis
I update thattopic, because I have the same problem as LittleG () : one OSG 
file with an AnimationPathCallback:

num_children 1
  MatrixTransform {
DataVariance DYNAMIC
name bugklappe01
nodeMask 0x
cullingActive TRUE
UpdateCallbacks {
  AnimationPathCallback {
pivotPoint 0 0 0
timeOffset 0
timeMultiplier 1
AnimationPath {
  LoopMode LOOP
  ControlPoints {
0 -15580.4365234375 482791.625 4228893.5 0.876726806163788 0 0 
-0.48098878698 0.99940395355 1 1
0.033350718021 -15580.4365234375 482791.625 4228893.5 
-0.829647123813629 0 0 0.558288156986237 0.99940395355 1 1
0.066701436043 -15580.4365234375 482791.625 4228893.5 
-0.775771200656891 0 0 0.631014347076416 0.99940395355 1 1
...
...
...


The object moves after the node has been loaded.
However, impossible to access the callback in order to change the 
timeMultiplier (I would like to accelerate or decelerate the motion with a 
slider on the screen... and go to a static position with an other slider).

Thanks.

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





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


Re: [osg-users] I'm lost the UpdateCallbacks

2010-07-19 Thread Mathieu Scorpionis
Oops sorry, I found the reason, just after written the post.
Please don't take into account

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





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


Re: [osg-users] StateSet and changes

2010-07-18 Thread Mathieu Scorpionis
Hello Ulrich

Thanks a lot for your answer.
You're probably right. The fault may come from the first Geode's stateSet.

When you say to give each geode the copy of its stateset, could you please 
indicate me how to do ?
Do we still use getOrCreateStateSet() method for each node ?

Thanks a lot for your help.
Regards.

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





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


Re: [osg-users] Misunderstanding NODE / DRAWABLE notions

2010-07-16 Thread Mathieu Scorpionis
I finally used a OSG file, and everything is solved.
Thank you  :D

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





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


[osg-users] StateSet and changes

2010-07-16 Thread Mathieu Scorpionis
Dear OSG community,

I try to manage with the model of an aircraft. I whish my 3d model to react to 
the mouse cursor when one of its sub-models is intersected by this cursor.

This is the simplified architecture of the OSG file :

*SceneRoot (MatrixTransform) : 1 children
***ExteriorCab (Group) : 4 children
*ExteriorCab-OFFSET (Group) : 1 children
***ExteriorCab-GEODE (Geode) : 8 drawables
*Tail (group) : 3 children
***Tail-OFFSET (Group) : 1 children
*Tail-GEODE (Geode) : 3 drawables
***RearRotor (Group) : 1 children
*RearRotor-GEODE (Geode) : 2 drawables
***Cylinder (Group) : 1 children
*Cylinder-OFFSET (Group) : 1 children
***Cylinder_GEODE (Geode) : 1 drawable
*RightWheel (Group) : 2 children
***RightWheel-OFFSET (Group) : 1 children
*RightWheel-GEODE (Geode) : 1 drawable
***RightWheelCylinder (Group) : 1 children
*RightWheelCylinder-GEODE (Geode) : 1 drawable
*LeftWheel (Group) : 2 children
***LeftWheel-OFFSET (Group) : 1 children
*LeftWheel-GEODE (Geode) : 1 drawable
***LeftWheelCylinder (Group) : 1 children
*LeftWheelCylinder-GEODE (Geode) : 1 drawable



(very simplified aircraft !)
the model comes from a file, i can't change it

What I do :

osg::ref_ptrosg::Group mRoot;
osg::ref_ptrosg::Node mModel;
mModel = osgDB::readNodeFile(m_ModelName);
mRoot-addChild(mModel.get());


osg::Group *groupSceneRoot;
osg::Group *ExteriorCab;
osg::Group *ExteriorCab_OFFSET;
osg::Group *Tail;
osg::Group *RightWheel;
osg::Group *LeftWheel;
osg::Geode *ExteriorCab_GEODE;
osg::Group *Tail_OFFSET;
osg::Group *RearRotor;
osg::Group *Cylinder;
osg::Group *Cylinder_OFFSET;
osg::Geode *Tail_GEODE;
osg::Geode *RearRotor_GEODE;
osg::Geode *Cylinder_GEODE;
osg::Group *RightWheel_OFFSET;
osg::Group *RightWheelCylinder;
osg::Geode *RightWheel_GEODE;
osg::Geode *RightWheelCylinder_GEODE;
osg::Group *LeftWheel_OFFSET;
osg::Group *LeftWheelCylinder;
osg::Geode *LeftWheel_GEODE;
osg::Geode *LeftWheelCylinder_GEODE;

groupSceneRoot = mModel-asGroup();
ExteriorCab = groupSceneRoot-getChild(0)-asGroup();

ExteriorCab_OFFSET  = ExteriorCab-getChild(0)-asGroup();
Tail = ExteriorCab-getChild(1)-asGroup();
RightWheel = ExteriorCab-getChild(2)-asGroup();
LeftWheel   = ExteriorCab-getChild(3)-asGroup();

ExteriorCab_GEODE = ExteriorCab_OFFSET-getChild(0)-asGeode();
Tail_OFFSET = Tail-getChild(0)-asGroup();
RearRotor = Tail-getChild(1)-asGroup();
Cylinder = Tail-getChild(2)-asGroup();
Cylinder_OFFSET = Cylinder-getChild(0)-asGroup();
Tail_GEODE = Tail_OFFSET-getChild(0)-asGeode();
RearRotor_GEODE = RearRotor-getChild(0)-asGeode();
Cylinder_GEODE = Cylinder_OFFSET-getChild(0)-asGeode();

RightWheel_OFFSET = RightWheel-getChild(0)-asGroup();
RightWheelCylinder = RightWheel-getChild(1)-asGroup();
RightWheel_GEODE = RightWheel_OFFSET-getChild(0)-asGeode();
RightWheelCylinder_GEODE = RightWheelCylinder -getChild(0)-asGeode();
LeftWheel_OFFSET = LeftWheel-getChild(0)-asGroup();
LeftWheelCylinder = LeftWheel-getChild(1)-asGroup();
LeftWheel_GEODE = LeftWheel_OFFSET-getChild(0)-asGeode();
LeftWheelCylinder_GEODE = LeftWheelCylinder -getChild(0)-asGeode();


// I have thus access to all geodes ()
// Now i create an array of stateset, and an array of geodes
osg::StateSet *ListGeodeStateSet[8];
osg::Geode *ListGeode[8];

ListGeode[0] = ExteriorCab_GEODE;
ListGeode[1] = Tail_GEODE;
ListGeode[2] = RearRotor_GEODE;
ListGeode[3] = Cylinder_GEODE;
ListGeode[4] = RightWheel_GEODE;
ListGeode[5] = RightWheelCylinder_GEODE;
ListGeode[6] = LeftWheel_GEODE;
ListGeode[7] = LeftWheelCylinder_GEODE;

for (int i=0;i8;i++)
ListGeodeStateSet[index] = ListGeode[i]-getOrCreateStateSet();

// What I want is to display only polygons if the cursor mouse picks a 
sub-model (here, one of the 8 geodes that decompose the whole aircraft):

osg::PolygonMode *PolyModeObj[8];
for (int i=0;i8;i++)
{
PolyModeObj[i] = dynamic_cast osg::PolygonMode* 
( ListGeodeStateSet[i]-getAttribute( 
osg::StateAttribute::POLYGONMODE ));
if ( !PolyModeObj[i] ) 
{ 
PolyModeObj[i] = new osg::PolygonMode;
ListGeodeStateSet[i]-setAttribute( PolyModeObj[i]);
}
}


// In the pick callback, I check which geode was selected by the cursor:
osgUtil::LineSegmentIntersector::Intersections::iterator hitr;
if (Viewer-computeIntersections(x, y, intersections))
{
hitr = intersections.begin();
osg::Geode *GeodeParent = hitr-drawable-getParent(0)-asGeode();
for (int d=0;d8;d++)
{
if (GeodeParent == ListGeode[d])
{
PolyModeObj[d]-setMode( osg::PolygonMode::FRONT_AND_BACK, 
osg::PolygonMode::LINE );
break;
}
}
}


But... when the cursor selects the geode ExteriorCab_GEODE, the whole aircaft 
moves to polygon display (even wheels, tail and the rest...). Only the cabin 
should appear as polygons.
When the cursor selects a wheel, nothing appears. The setMode( 
osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE ); function has no 
effect.
ExteriorCab_GEODE has an effect on 

Re: [osg-users] Newbie question about osg::Vec3Array

2010-07-14 Thread Mathieu Scorpionis
Thanks a lot, Alberto.

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





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


[osg-users] Misunderstanding NODE / DRAWABLE notions

2010-07-14 Thread Mathieu Scorpionis
Hello

This is my problem :

I load a *.3ds file (an aircraft). I don't have the software 3dsMax so I don't 
know how it was created...
From that file, I do bascially :

osg::ref_ptrosg::Node Model;
osg::ref_ptrosg::Group Root;
Model = osgDB::readNodeFile(name of the file.3ds);
Root  = new osg::Group;
Root-addChild(Model.get());

I add other stuff in mRoot... (3 osg::ShapeDrawable like cylinders and 3 like 
cones, to simulate 3 axis X Y Z ; a osgText::Text to write some info) In short, 
nothing extraordinary !

I have a pick function. When I move the mouse, I check if the cursor intersects 
with a part of the aircraft.
I used the examples of OSG :

osgUtil::LineSegmentIntersector::Intersections intersections;
osg::ref_ptrosg::Drawable HitDrawable;
osg::Geometry * HitGeometry;
CString strName;
CString strNameParent;
if (m_pViewer-computeIntersections(x, y, intersections))
{
   // I keep only the 1st intersection :
   osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin();
   HitDrawable = hitr-drawable;
   HitGeometry = HitDrawable-asGeometry();
   strName = CString(hitr-drawable-getName().c_str());
   strNameParent = CString(hitr-drawable-getParent(0)-getName().c_str());

   // After that I put the drawable in a transparent state :

   float transparency = 0.3;
   osg::StateSet * stateset = HitDrawable-getOrCreateStateSet();
   osg::Material * mm = 
dynamic_castosg::Material*(stateset-getAttribute(osg::StateAttribute::MATERIAL));
   if (!mm)
  mm = new osg::Material;
   mm-setAlpha(osg::Material::FRONT, transparency);
   stateset-setAttributeAndModes( mm, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON);
   stateset-setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON );
   stateset-setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON );
   stateset-setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

}
 

This is Okay, I see a part of the aircraft that becomes transparent, when the 
mouse cursor goes in front of it.

What I would want to do, afterwards, is that if the cursor leaves that part of 
the aircraft, the rendering comes back to the initial state (not transparent).
But I don 't know how to do... the main question behind my post (sorry for 
being so long !) is that I don't understand why the intersector accesses to a 
drawable, while the aircraft comes from a Node File.
I believed that drawables were linked to Geode class ?!

When I ask for the strings strName and strNameParent with the functions :
strName = CString(hitr-drawable-getName().c_str());
strNameParent = CString(hitr-drawable-getParent(0)-getName().c_str());

I see  in strName
and Tail or Wing or Rotor... in strNameParent, depending on where the 
cursor is. Logic.
So the intersector reads someting that comes from the node file.
But is this a drawable ??

In the beginning of the appli, can I have the list of all drawables, those 
sub-parts of the aircraft model (tail, wing ...) and put a osg::StateSet on 
each of them ?
If I could, I would activate/desactivate transparency possibilities as I want.
For the moment, if I have access to a drawable (via the hitr-drawable), I 
don't have access to others, so when a drawable becomes transparent, it will 
always be. I can't  manipulate several drawables in the same time.

I hope I was clear. I've just started working with OSG. It is fascinating but 
not easy !
As all information are in the .3ds file, I don't know if can manipulate 
something with OSG.

Thanks in advance.

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





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


Re: [osg-users] Misunderstanding NODE / DRAWABLE notions

2010-07-14 Thread Mathieu Scorpionis

Alberto Luaces wrote:
 
 A Geode is a Node.
 


Hello Alberto,

Yes a geode is a node. But how is it possible to create a geode, from a 3DS 
(or.OSG) file ?

Mathieu

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





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