Thanks for your reply, Wes. I've finally found out why it didn't work
correctly. I wasn't giving the right initial mouse position to the translate
and scale functions. Now it works fine.
Thanks again.
Emmanuelle.
> Howdy,
>
> Taking a quick look at your code, I don't see anything obviously wrong.
> You appear to have correct code for the crucial pieces:
> 1. modification of camera as a function of mouse position and button
> pushes;
> 2. the FLTK redraw function is correctly invoked, which will in turn
> invoke the OpenRM renderer
>
> You mention using an orthographic projection... the rmauxDolly function
> does not "scale" the image in the isomorphic scaling sense, but moves
> the camera around. When using an orthographic projection, small changes
> in z-component of the object or camera will not appear to make any
> difference visually. For this reason, many prefer to use perspective
> projections. Orthographic projections are important for applications
> that require preservation of angles (as the perspective projection is
> non-affine).
>
> My suggestions are:
> 1. use a perspective projection, and
> 2. if you can make a tarball of the entire application, I'll take a look
> at it in the interest of ferreting out any OpenRM bugs.
>
> tx,
> wes
>
> Emmanuelle Bourrat wrote:
> >
> > Hi OpenRm users,
> >
> > I made an application using Fltk and OpenRM. I'm using
> > "rmauxTranslate", "rmauxDolly" and "rmauxArcBall" to translate, scale
> > and rotate my scene. The rotation works fine, but the translation and
> > the scaling work with a delay: if I click and drag the mouse to the
> > right, the scene is translated to the right, but if a change direction
> > and drag to the left, the scene is still translated to the right, and
> > only after a while it starts being translated to the left. I'm
> > experiencing the same problem with the scaling.
> >
> > I've enclosed my code. I'd appreciate any help with this problem!
> > Thanks a lot.
> > Emmanuelle.
> >
> > ----------------------
> > int Vl_FlRmWindow::handle(int event)
> > {
> > // press, drag and release actions on b1 mapped to arcball rotation
> > model,
> > // button2 : translation and button3: scaling
> >
> > int rstat = 0;
> > int whichButton;
> >
> > switch(event)
> > {
> > case FL_PUSH:
> > whichButton = Fl::event_button();
> >
> > // Rotation
> >
> > if (whichButton == 1)
> > {
> > this->buttonDownX = pixeltovp(Fl::event_x(), this->w());
> > this->buttonDownY = -1.0F * pixeltovp(Fl::event_y(), this->h());
> >
> > if (rmNodeGetRotateMatrix(this->myObjs,&(this->initialTransform)) ==
> > RM_WHACKED)
> > rmMatrixIdentity(&(this->initialTransform));
> >
> > this->doingTransform = 1;
> > rstat = 1;
> > }
> > // Translation
> >
> > else if (whichButton == 2)
> > {
> > this->buttonDownX = pixeltovp(Fl::event_x(), this->w()) / 8;
> > this->buttonDownY = -1.0F * pixeltovp(Fl::event_y(), this->h()) / 8;
> >
> > this->doingTransform = 2;
> > rstat = 1;
> > }
> >
> > // Scaling
> >
> > else if (whichButton == 3)
> > {
> > this->buttonDownX = pixeltovp(Fl::event_x(), this->w())/8;
> > this->buttonDownY = -1.0F * pixeltovp(Fl::event_y(), this->h())/8;
> >
> > this->doingTransform = 3;
> > rstat = 1;
> > }
> > else
> > this->doingTransform = 0;
> >
> > break;
> >
> > case FL_DRAG:
> > {
> > float bx, by;
> >
> > // Rotation
> >
> > if (this->doingTransform == 1)
> > {
> > RMmatrix resultTransform;
> > bx = pixeltovp(Fl::event_x(), this->w());
> > by = -1.0F * pixeltovp(Fl::event_y(), this->h());
> > rmauxArcBall (&(this->buttonDownX), &(this->buttonDownY),
> > &bx, &by, &resultTransform);
> > rmMatrixMultiply(&(this->initialTransform), &resultTransform,
> > &resultTransform);
> > rmNodeSetRotateMatrix(this->myObjs, &resultTransform);
> > this->redraw();
> > rstat = 1;
> > }
> >
> > // Translation
> >
> > else if (this->doingTransform == 2)
> > {
> > bx = pixeltovp(Fl::event_x(), this->w()) / 8;
> > by = -1.0F * pixeltovp(Fl::event_y(), this->h()) / 8;
> > RMcamera3D * cam=NULL;
> > if (rmNodeGetSceneCamera3D (myRoot, &cam) == RM_WHACKED)
> > {
> > printf ("Error getting camera.\n");
> > rstat = 0;
> > }
> >
> > // Changed the order of the parameters, because when we use
> > // the orthographic projection, the interaction with the mouse
> > // is "mirored" (moving left, translates to the right)
> >
> > //rmauxTranslate (cam, &(this->buttonDownX), &(this->buttonDownY),
> > // &bx, &by);
> > rmauxTranslate (cam, &bx, &by, &(this->buttonDownX),
> > &(this->buttonDownY));
> >
> > rmNodeSetSceneCamera3D (myRoot, cam);
> > rmCamera3DDelete(cam);
> > this->redraw();
> > rstat = 1;
> > }
> >
> > // Scaling
> >
> > else if (this->doingTransform == 3)
> > {
> > bx = pixeltovp(Fl::event_x(), this->w())/8;
> > by = -1.0F * pixeltovp(Fl::event_y(), this->h())/8;
> > RMcamera3D * cam=NULL;
> > if (rmNodeGetSceneCamera3D (myRoot, &cam) == RM_WHACKED)
> > {
> > printf ("Error getting camera.\n");
> > rstat = 0;
> > }
> > rmauxDolly (cam, &(this->buttonDownX), &(this->buttonDownY),
> > &bx, &by);
> > rmNodeSetSceneCamera3D (myRoot, cam);
> > rmCamera3DDelete(cam);
> >
> > this->redraw();
> >
> > rstat = 1;
> > }
> > }
> > break;
> >
> > case FL_RELEASE:
> > {
> > rstat = 1;
> > this->doingTransform = 0;
> > }
> > break;
> > }
> >
> > if (rstat == 0)
> > return Fl_Gl_Window::handle(event);
> > else
> > return 1;
> > }
> >
> > _______________________________________________
> > Openrm-users mailing list
> > Openrm-users@...
> > https://lists.sourceforge.net/lists/listinfo/openrm-users
>
> --
> Wes Bethel wbethel@...
> R3vis Corporation http://www.r3vis.com/
> Phone: 415-898-0814 FAX: 415-898-2814
>
> _______________________________________________
> Openrm-users mailing list
> Openrm-users@...
> https://lists.sourceforge.net/lists/listinfo/openrm-users
|