Hello,

Alexandra Wolyniec wrote:
> Hey there!
> I'm a newbie with OpenSG and at the moment I'm trying to deal with
> transformations.
> I've generated three boxes which should move independently by pressing a
> key. This works so far, but actually I have a problem with those
> translations.
> Right now if I press the key to activate the translation the result is the
> new order of the boxes. The movement to this position is unfortunately not
> visible.
> I know that I have to make this dependent from
> 
>  Real32 time = glutGet(GLUT_ELAPSED_TIME);
> 
> but if I do this, the movement is endless. My wish is to have a translation
> from point x to point y.

hm, looking ahead at the code below, I'm a bit confused. Do you want the 
box to move along a straight line from x to y or should it move along 
some other path ?
For the straight line movement, every time your display callback runs 
you need to compute where the box should be, based on the time it 
started to move, the current time and how long it should take the box to 
get from x to y. These three time allow you to compute a scaling value 
in [0, 1] that you multiply with the vector from x to y. If you add that 
scaled vector to the starting point x, you get the location of the box 
for the current frame.

> I thought to use a loop like this:
> 
>  Vec3f rot1 = (osgsin(time / 1000.f),
>                                osgcos(time / 1000.f),      //this is only an
> example for a translation dependent on 'time'
>                                osgsin(time / 1000.f));
>  Matrix r,p,q;                                                   // p should
> be the result-matrix, r and q are just for help
> 
>  q.setTransform(Vec3f(0,1,0));
>  Vec3f  v = (Vec3f(2,1,0));
> 
>  while (q.getTransform != v){
                        ^^^^
        this seems strange, does the code you posted compile ?
>       r.setTransform(rot1);
>       r.mult(q);
>       p.setValue(r);
> }
 >
> but actually I don't know how to handle 'getTransform' and besides I'm not
> sure if I'm on the right way or if there are maybe some existing functions
> yet??!

hm, there may be functions that help with what you want to do, but I'm 
not sure I have fully understood what that is. The code you posted above 
does not seem to do what you want, but it is the only description you 
have given.

> I've just spent far too much time with this problem, that's why I'm 
> hoping for help here :D

Getting started with these things is not easy and it takes a bit to get 
used to transformations and how they interact, therefore I would hope 
that if you could describe again what it is that you wish to achieve, it 
might also help you a bit getting a better understanding of the problem.

        Thanks,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to