Re: [osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-02-05 Thread Peter Hrenka

Hi Julien-Charles,

Julien-Charles Lévesque schrieb:

Hi Peter,

What do you mean by a degenerated polytope of volume 0 ? That polytope 
definitely doesn't have a null volume since I've been using it to select 
objects in my application and it works.


The four planes all have the same starting point because I want the 
polytope to be a pyramid coming out from a user's hand, so the planes 
-should- all intersect at the summit, no ?


You are right. I did not look closely enough and assumed
you where trying to build a parallel polytope.
The polytope looks to be alright.



Julien-Charles

On Thu, Feb 4, 2010 at 8:35 AM, Peter Hrenka 
p.hre...@science-computing.de mailto:p.hre...@science-computing.de 
wrote:


Hi Julien-Charles,

Julien-Charles Lévesque schrieb:

[...]


Here is my code... stripped down to a minimum. I assume that you
have a 4x4 matrix containing orientation of your selector
(lOrientation) and a vec3 containing it's position (lPosition).
I built the polytope to point in the direction of positive
y-axis. Sorry for the french variable names and comments here
and there... I don't think they hurt readability much at this
level :P

However, I wasn't able to extract a reliable 3x3 rotation matrix
from mouse coordinates. I can only say that this code works well
with the raw 3x3 orientation and position provided by my
tracker. Do you have any idea for a desktop variation ? I can
implement it. I could also integrate all this in the
examplekeyboardmouse, once I've figured out how to do it with a
mouse :P


I would suggest to control the rotation and position
using the keyboard. This should be enough for the
purpose of an osg-example. I think it would be nice
if the polytope would be visualized as a wireframe
model.
I also would suggest of creating a new osgpolytopeintersector-
example because nobody really looks into osgkeyboardmouse
when looking for polytope-intersection functionality...



Cheers,

Peter
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech

Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 



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


Re: [osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-02-04 Thread Peter Hrenka

Hi Julien-Charles,

Julien-Charles Lévesque schrieb:

[...]

Here is my code... stripped down to a minimum. I assume that you have a 
4x4 matrix containing orientation of your selector (lOrientation) and a 
vec3 containing it's position (lPosition). I built the polytope to point 
in the direction of positive y-axis. Sorry for the french variable names 
and comments here and there... I don't think they hurt readability much 
at this level :P


However, I wasn't able to extract a reliable 3x3 rotation matrix from 
mouse coordinates. I can only say that this code works well with the raw 
3x3 orientation and position provided by my tracker. Do you have any 
idea for a desktop variation ? I can implement it. I could also 
integrate all this in the examplekeyboardmouse, once I've figured out 
how to do it with a mouse :P


You seem to use the same base-point for all but one
plane:

 lPlane.set(lNorm, lPosition);

This will give you a degenerated polytope of
volume 0.
Try using
 lPlane.set(lNorm, lPosition-radius*lNorm);
with some radius  0


Cheers,

Peter
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech

Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 


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


Re: [osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-02-04 Thread Julien-Charles Lévesque
Hi Peter,

What do you mean by a degenerated polytope of volume 0 ? That polytope
definitely doesn't have a null volume since I've been using it to select
objects in my application and it works.

The four planes all have the same starting point because I want the polytope
to be a pyramid coming out from a user's hand, so the planes -should- all
intersect at the summit, no ?

Julien-Charles

On Thu, Feb 4, 2010 at 8:35 AM, Peter Hrenka
p.hre...@science-computing.dewrote:

 Hi Julien-Charles,

 Julien-Charles Lévesque schrieb:

 [...]


 Here is my code... stripped down to a minimum. I assume that you have a
 4x4 matrix containing orientation of your selector (lOrientation) and a vec3
 containing it's position (lPosition). I built the polytope to point in the
 direction of positive y-axis. Sorry for the french variable names and
 comments here and there... I don't think they hurt readability much at this
 level :P

 However, I wasn't able to extract a reliable 3x3 rotation matrix from
 mouse coordinates. I can only say that this code works well with the raw 3x3
 orientation and position provided by my tracker. Do you have any idea for a
 desktop variation ? I can implement it. I could also integrate all this in
 the examplekeyboardmouse, once I've figured out how to do it with a mouse :P


 You seem to use the same base-point for all but one
 plane:

  lPlane.set(lNorm, lPosition);

 This will give you a degenerated polytope of
 volume 0.
 Try using
  lPlane.set(lNorm, lPosition-radius*lNorm);
 with some radius  0



 Cheers,

 Peter
 --
 Vorstand/Board of Management:
 Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
 Vorsitzender des Aufsichtsrats/
 Chairman of the Supervisory Board:
 Michel Lepert
 Sitz/Registered Office: Tuebingen
 Registergericht/Registration Court: Stuttgart
 Registernummer/Commercial Register No.: HRB 382196
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




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


Re: [osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-02-02 Thread Julien-Charles Lévesque
Hi Peter,

Julien-Charles Levesque schrieb:

 Hi,

 I'm trying to use a PolytopeIntersector in my scene and so far I have
 succeeded but only by using the camera (i.e. mCamera-accept(PolyVisitor))
 with a PolytopeIntersector built from x and y coordinates in window frame.
 However I would rather pass the visitor the root of my scene. I am doing
 this in a virtual reality project, and using the camera seems to complicate
 things a fair bit because we modify projection matrices and viewports a
 whole lot.
 For my LineSegmentIntersector I have used 3D points in model space, which
 worked fine when visiting the root of the scene. For the PolytopeIntersector
 I am unsure how to do this... Only examples I have found so far used either
 coordinates in projection space or coordinates in window space.


 Yes, the examples do not use all available constructors of
 PolytopeIntersector.
 That is something that has been sitting on my to-do-list for a long time...


Here is my code... stripped down to a minimum. I assume that you have a 4x4
matrix containing orientation of your selector (lOrientation) and a vec3
containing it's position (lPosition). I built the polytope to point in the
direction of positive y-axis. Sorry for the french variable names and
comments here and there... I don't think they hurt readability much at this
level :P

However, I wasn't able to extract a reliable 3x3 rotation matrix from mouse
coordinates. I can only say that this code works well with the raw 3x3
orientation and position provided by my tracker. Do you have any idea for a
desktop variation ? I can implement it. I could also integrate all this in
the examplekeyboardmouse, once I've figured out how to do it with a mouse :P

osg::Vec3 lPosition;
osg::Matrixd lOrientation;

osg::Vec3d lEnd = lPosition + lOrientation * osg::Vec3d(0,LENGTH, 0);
//pointe vers Y à l'origine

//construction d'un polytope dans le repere monde.
osg::Polytope lPolytope;
osg::Plane lPlane;
osg::Vec3d lNorm;

//This is the angle by which your planes are rotated. Wider angle = larger
selection.
double lTheta = 0.5 * PI / 180.;

//Left X Plane
lNorm.set(cos(lTheta),sin(lTheta),0);
lNorm = lOrientation*lNorm;
lPlane.set(lNorm, lPosition);
lPolytope.add(lPlane);

//Right X Plane
lNorm.set(-cos(lTheta),sin(lTheta),0); //car cos(theta) = cos(-theta) et
sin(theta)=-sin(-theta)
lNorm = lOrientation*lNorm;
lPlane.set(lNorm, lPosition);
lPolytope.add(lPlane);

//Top Z Plane
lNorm.set(0,sin(lTheta),-cos(lTheta));
lNorm = lOrientation*lNorm;
lPlane.set(lNorm, lPosition);
lPolytope.add(lPlane);

//Bottom Z Plane
lNorm.set(0,sin(lTheta),cos(lTheta));
lNorm = lOrientation*lNorm;
lPlane.set(lNorm, lPosition);
lPolytope.add(lPlane);

//Far Y Plane.
lNorm.set(0,-1,0);
lNorm = lOrientation*lNorm;
lPlane.set(lNorm, lEnd);
lPolytope.add(lPlane);

osg::ref_ptrosgUtil::PolytopeIntersector lIntersecteur =
new osgUtil::PolytopeIntersector(lPolytope);

// Création d'un visiteur.
osg::ref_ptrosgUtil::IntersectionVisitor lVisiteur = new
osgUtil::IntersectionVisitor;
lVisiteur-setIntersector(lIntersecteur);

//Set mask only if you must... in our
//application it was for focusable objects.
//lVisiteur-setTraversalMask(OBJET_DESIGNABLE);

//Accept node at root of scene.
mRootNode-accept(lVisiteur);

if(lIntersecteur-containsIntersections())
{
   // Récupère les objets en intersection avec la droite.
   osgUtil::PolytopeIntersector::Intersections lIntersections =
lIntersecteur-getIntersections();

   //Parcours la liste des intersections, en commençant par les objets les
plus près
   for (osgUtil::PolytopeIntersector::Intersections::iterator lII =
lIntersections.begin();
   lII != lIntersections.end();
  lII++)
   {
  const osg::NodePath lNodePath = lII-nodePath;
  //Do whatever you have to here!
   }
}




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


Re: [osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-01-27 Thread Peter Hrenka

Hi Julien-Charles,

Julien-Charles Levesque schrieb:

Hi,

I'm trying to use a PolytopeIntersector in my scene and so far I have succeeded but only by using the camera (i.e. mCamera-accept(PolyVisitor)) with a PolytopeIntersector built from x and y coordinates in window frame. However I would rather pass the visitor the root of my scene. I am doing this in a virtual reality project, and using the camera seems to complicate things a fair bit because we modify projection matrices and viewports a whole lot. 


For my LineSegmentIntersector I have used 3D points in model space, which 
worked fine when visiting the root of the scene. For the PolytopeIntersector I 
am unsure how to do this... Only examples I have found so far used either 
coordinates in projection space or coordinates in window space.


Yes, the examples do not use all available constructors of 
PolytopeIntersector.

That is something that has been sitting on my to-do-list for a long time...


Now I have seen the CoordinateFrame MODEL or VIEW in the PolytopeIntersector 
constructor, but I am unsure as how to use it. I have seen that the Znear plane 
is fixed to 0 for MODEL and VIEW coordinate frames.. Does this mean that any 
object behind Z=0 could not be intersected?

I also have a bad feeling that building and using the PolytopeIntersector in MODEL and VIEW coordinate frames will make it just rectangular instead of pyramidal. 


There are two constructors that should be suitable for your use-case:

/** Construct a PolytopeIntersector using specified polytope in 


MODEL coordinates.*/
PolytopeIntersector(const osg::Polytope polytope);

/** Construct a PolytopeIntersector using specified polytope in
specified coordinate frame.*/
PolytopeIntersector(CoordinateFrame cf,
const osg::Polytope polytope);

You can pass an arbitrary Polytope which does not have to be
rectangular.

To recapitulate : I am trying to build a polytpe intersector from one 3d point in model space (or world space) and it's orientation. I would prefer this polytope intersector to be independent from the cameras or viewports. I am stuck at this point. Am I assuming something wrong? Did I miss something that could make this simpler? Do you have any clue that could help me? Am I even making sense? :D 


Try using one of the contructors above with a polytope that you
provide and use the MODEL coordinate frame. That should work.


Thank a lot,

Sincerely,
Julien-Charles


Cheers,

Peter
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech

Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 



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


[osg-users] Using PolytopeIntersector from the root of the scene graph instead of camera

2010-01-26 Thread Julien-Charles Levesque
Hi,

I'm trying to use a PolytopeIntersector in my scene and so far I have succeeded 
but only by using the camera (i.e. mCamera-accept(PolyVisitor)) with a 
PolytopeIntersector built from x and y coordinates in window frame. However I 
would rather pass the visitor the root of my scene. I am doing this in a 
virtual reality project, and using the camera seems to complicate things a fair 
bit because we modify projection matrices and viewports a whole lot. 

For my LineSegmentIntersector I have used 3D points in model space, which 
worked fine when visiting the root of the scene. For the PolytopeIntersector I 
am unsure how to do this... Only examples I have found so far used either 
coordinates in projection space or coordinates in window space.

Now I have seen the CoordinateFrame MODEL or VIEW in the PolytopeIntersector 
constructor, but I am unsure as how to use it. I have seen that the Znear plane 
is fixed to 0 for MODEL and VIEW coordinate frames.. Does this mean that any 
object behind Z=0 could not be intersected?

I also have a bad feeling that building and using the PolytopeIntersector in 
MODEL and VIEW coordinate frames will make it just rectangular instead of 
pyramidal. 

To recapitulate : I am trying to build a polytpe intersector from one 3d point 
in model space (or world space) and it's orientation. I would prefer this 
polytope intersector to be independent from the cameras or viewports. I am 
stuck at this point. Am I assuming something wrong? Did I miss something that 
could make this simpler? Do you have any clue that could help me? Am I even 
making sense? :D 

Thank a lot,

Sincerely,
Julien-Charles

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





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