Re: [osg-users] Setting BoundingBox

2008-02-23 Thread Ulrich Hertlein
Ulrich Hertlein wrote:
> Renan Mendes wrote:
>> what I mean with that. A snap is basically a sudden transformation of 
>> the shape on the screen to a certain orientation and position in space 
> 
> Sorry, missed that the first time.
> As I understand it you want to scale the Drawable to a given size, place it 
> in a 
> certain position?

Sorry, I just now got what you're trying. Ignore my previous post, Brian's 
approach (ComputeBoundingBoxCallback) is what you want.

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


Re: [osg-users] Setting BoundingBox

2008-02-23 Thread Ulrich Hertlein
Hi Renan,

Renan Mendes wrote:
> what I mean with that. A snap is basically a sudden transformation of 
> the shape on the screen to a certain orientation and position in space 

Sorry, missed that the first time.
As I understand it you want to scale the Drawable to a given size, place it in 
a 
certain position?

To change the position, scale/size, or orientation of a Geode you should place 
a 
MatrixTransform above that node and set its matrix to do what you want. (To 
change the size of a single Drawable you'd have to modify it's coordinates 
directly.)

E.g. say you want to change to Geode to a certain size you could do the 
following:

// node hierarchy is xform=MatrixTransform -> Geode -> drawable=Drawable

// desired size
osg::Vec3 dSize(100,100,100);

// get current bounding box
const osg::BoundingBox& bbox = drawable.getBound();
osg::Vec3 bboxSize = (bbox._max - bbox._min);

xform->setMatrix(osg::Matrix::scale(bboxSize.x() / dSize.x(),
bboxSize.y() / dSize.y(),
 bboxSize.z() / dSize.z()));

This is from memory, so it may not work out of the box.

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


Re: [osg-users] Setting BoundingBox

2008-02-23 Thread Renan Mendes
Hi, Ulrich.

   This is what I've said in my first email:
   "I am currently trying to implement 'snaps' in my application. I
don't know if that's the standard nomenclature, so I'll explain briefly what
I mean with that. A snap is basically a sudden transformation of the shape
on the screen to a certain orientation and position in space when it reaches
a certain state in the scene. For example, when a point gets close to a
plane, it gets translated to its projection on the plane [...]"

   What I thought was that the function intersects() would give me a
'warning' when two shapes got close enough. That's what I've thought when I
decided to use BoundingBox. Is there a better way to do that?

Thanks for your help, Ulrich.

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


Re: [osg-users] Setting BoundingBox

2008-02-23 Thread Brian R Hill
To change the drawable bounding box you either need to change the actual
geometry, or you need to add a callback to override the computebound method
behavior. Search the osg code for ComputeBoundingBoxCallback.

Brian

[EMAIL PROTECTED] wrote: -


To: OpenSceneGraph Users 
From: Ulrich Hertlein <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
Date: 02/22/2008 11:48PM
Subject: Re: [osg-users] Setting BoundingBox

Renan Mendes wrote:
>"2 overloads have no legal conversion for 'this' pointer"
> ...
> (drawable->getBound()).set(-COMPRIMENTO - 0.1, -LARGURA - 0.1,
> -ESPESSURA - 0.1,
>  COMPRIMENTO + 0.1, LARGURA +
> 0.1, ESPESSURA + 0.1); // constants in capital letters
>
> Anyone could explain to me what's happening?

The osg::Drawable::getBound() is const, so you cannot modify the bounding
box
returned to you.

What are you trying to achieve? Maybe you're using the bounding box for
something it's not intended to do (or something that's just wrong usage of
the API).

If you would give some more information it would be easier to solve the
problem.
Cheers,
/ulrich
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.


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


Re: [osg-users] Setting BoundingBox

2008-02-22 Thread Ulrich Hertlein
Renan Mendes wrote:
>"2 overloads have no legal conversion for 'this' pointer"
> ...
> (drawable->getBound()).set(-COMPRIMENTO - 0.1, -LARGURA - 0.1, 
> -ESPESSURA - 0.1,
>  COMPRIMENTO + 0.1, LARGURA + 
> 0.1, ESPESSURA + 0.1); // constants in capital letters
> 
> Anyone could explain to me what's happening?

The osg::Drawable::getBound() is const, so you cannot modify the bounding box 
returned to you.

What are you trying to achieve? Maybe you're using the bounding box for 
something it's not intended to do (or something that's just wrong usage of the 
API).

If you would give some more information it would be easier to solve the problem.
Cheers,
/ulrich
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Setting BoundingBox

2008-02-21 Thread Renan Mendes
Hi, everyone.

I am currently trying to implement 'snaps' in my application. I
don't know if that's the standard nomenclature, so I'll explain briefly what
I mean with that.
   A snap is basically a sudden transformation of the shape on the
screen to a certain orientation and position in space when it reaches a
certain state in the scene. For example, when a point gets close to a plane,
it gets translated to its projection on the plane, which is exactly what I'm
trying to do in my application. For that, I thought of using bounding boxes.
But to be able to control the minimum distance in which the bb's will
intersect, I must set their extensions. While trying to do that with the
function 'set', my compiler accused the following error:

   "2 overloads have no legal conversion for 'this' pointer"

   I'll paste the source code I am using:

osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(posicao,
largura, comprimento, espessura)); // these are the same arguments of the
function
(drawable->getBound()).set(-COMPRIMENTO - 0.1, -LARGURA - 0.1, -ESPESSURA -
0.1,
 COMPRIMENTO + 0.1, LARGURA + 0.1,
ESPESSURA + 0.1); // constants in capital letters

Anyone could explain to me what's happening?

   Thanks for your help.

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