help

16 views
Skip to first unread message

mohamed mediouni

unread,
May 2, 2014, 3:48:51 PM5/2/14
to vrjuggler...@googlegroups.com
How can move 3D object with Joystick in the CAVE
software: OpenGl + VRjuggler

Carsten Neumann

unread,
May 2, 2014, 6:31:47 PM5/2/14
to vrjuggler...@googlegroups.com

    Hello,
 
please don't send repeated mails with (nearly) the same content to different mailing lists of the project, give folks time to consider your question and compose a reply. 
 
> Gesendet: Freitag, 02. Mai 2014 um 21:48 Uhr
> Von: "mohamed mediouni" <mohamed.s...@gmail.com>
> An: vrjuggler...@googlegroups.com
> Betreff: [vrjuggler-questions] help

> How can move 3D object with Joystick in the CAVE
> software: OpenGl + VRjuggler
 
You don't provide a lot of information on what _exactly_ your problem is, e.g. whether the problem is configuring vrjuggler to work with a joystick, accessing the joystick data from your application, or using that information to modify the location of an object?
One of your other mails seems to indicate that you already know how to obtain the matrix from a tracked wand. You would use that matrix to modify the model matrix of the object you want to move. For a joystick you would in general have a couple of analog inputs (for the actual stick axes) and digital inputs for the buttons. The analog input can be used to construct a translation matrix that again would be applied to the model matrix of the object you want to move.
The documentation has information on how to configure vjuggler to work with a joystick device and how to access that data from your application.

Cheers,
Carsten

mohamed mediouni

unread,
May 2, 2014, 8:57:39 PM5/2/14
to vrjuggler...@googlegroups.com
hello
Thank you for response ,

So, for moving the objects, we need a selection,

My approach is to put some object in boundigBox

and after, to choose an object, we need, the intersection of the JOystick with the bounding box.
The selection is correct but the object d'ont move
Than you

--Mohamed--



--

---
You received this message because you are subscribed to a topic in the Google Groups "vrjuggler-questions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vrjuggler-questions/DTifg0yXxrE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vrjuggler-quest...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carsten Neumann

unread,
May 3, 2014, 5:30:21 AM5/3/14
to vrjuggler...@googlegroups.com
Hello Mohamed,

On 05/03/2014 02:57 AM, mohamed mediouni wrote:
> So, for moving the objects, we need a selection,
>
> Myapproach is to put some object in boundigBox
>
> and after, to choose an object, we need, the intersection of the
> JOystick with the bounding box.
> The selection is correct but the object d'ont move

ok, unfortunately to give a precise answer you'd have to provide a lot
more information what and how you are doing things - so, let's try this:
Ignoring the joystick input for a moment, would you know how to make the
object move at all, say have it rotate in place? If the answer is yes,
your problem seems to boil down to constructing an appropriate
transformation matrix from the joystick input. In that case could you
provide a description of what kind of motion you want to happen and
perhaps post the relevant pieces of your code?
However, if the answer is no, I would highly recommend you work through
some OpenGL tutorials [1] to get a better understanding of how
transformation matrices are used in computer graphics to place and move
objects in a virtual scene.

Cheers,
Carsten


[1] The OpenGL wiki has a collection of tutorials at:
http://www.opengl.org/wiki/Getting_Started#Tutorials_and_How_To_Guides
I personally like http://www.arcsynthesis.org/gltut since it provides
good explanations of the underlying principles IMHO.

mohamed mediouni

unread,
May 3, 2014, 2:00:50 PM5/3/14
to vrjuggler...@googlegroups.com
Thank you for your response
This my code. But i do all information but the object d'ont nove
please help me. I'm stuck for 2 months


--

--- You received this message because you are subscribed to a topic in the Google Groups "vrjuggler-questions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vrjuggler-questions/DTifg0yXxrE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vrjuggler-questions+unsub...@googlegroups.com.
mohmaed.zip

Carsten Neumann

unread,
May 3, 2014, 6:23:07 PM5/3/14
to vrjuggler...@googlegroups.com
Hello Mohamed,

On 2014-05-03 20:00, mohamed mediouni wrote:
> Thank you for your response
> This my code. But i do all information but the object d'ont nove

have you checked that mWand->getData() actually produces matrices that
are different from the identity matrix?

Your OsApp:draw() function has a stray glPopMatrix in there (after
drawing the model called "mesh"). Also, assuming that mNavMatrix is your
view matrix (since it gets applied to all other objects), it is not
being applied to the selected "femur8" model - is that intentional?
I'm not sure if fixing these things will solve your problem, but at
least they should make analyzing what is happening easier. I also highly
suspect that you'd have been able to spot these things immediately
yourself if your OsApp::draw() function was cleanly formatted [1], the
way it is makes reading and understanding it unnecessary hard IMHO.

> please help me. I'm stuck for 2 months

Hmm, my suggestion would be to do the following:
- Ignore the selection aspect for now, choose one object that you can move
- Find two otherwise unused buttons of your joystick and if one is
pressed apply a translation by a fixed amount along the x-axis to your
moveable object. If the other button is pressed apply the same fixed
amount of translation in the opposite direction along the x-axis.
- If that works make sure your navigation still works and the object
moves in the expected direction even after you change your point of view.
- You could then construct a more interesting transformation to be
applied to the moveable object, for example instead of just translating
along the x-axis, use the wand matrix.
- Finally, bring back the ability to select different objects and have
the movement applied to the selected one, instead of a hard coded choice.
The overall idea behind these steps is to simplify the problem to the
point where it is easier to see what exactly goes wrong if things don't
work right away and then build up from there. Hope it helps,

Cheers,
Carsten

[1] Cleanly formatted code is of course not inherently of better
quality, but at least it does not make it harder to understand what goes
on - or what goes wrong in case of code that you are debugging ;)

mohamed mediouni

unread,
May 5, 2014, 4:23:32 PM5/5/14
to vrjuggler...@googlegroups.com
Thank you for response
II followed your approach, 
I can move one object now 
if I click on button button on Joystick, the object moves according to the position Joystick


void OsApp::updateGrabbing()
{
   // Get wand matrix in the virtual world coordinate system
   // wand_vw = vw_M_w * wand_w
   gmtl::Matrix44f vw_M_w;
   gmtl::invert(vw_M_w, mNavMatrix);      // Nav matrix is: w_M_vw.  So invert it
   gmtl::Matrix44f wand_matrix = vw_M_w * mWand->getData();

   // Get the point in space where the wand is located

   gmtl::Point3f wand_pt = gmtl::makeTrans<gmtl::Point3f>(wand_matrix);

void OsApp::updateGrabbing()
{
   // Get wand matrix in the virtual world coordinate system
   // wand_vw = vw_M_w * wand_w
   gmtl::Matrix44f vw_M_w;
   gmtl::invert(vw_M_w, mNavMatrix);      // Nav matrix is: w_M_vw.  So invert it
   gmtl::Matrix44f wand_matrix = vw_M_w * mWand->getData();

   // Get the point in space where the wand is located

   gmtl::Point3f wand_pt = gmtl::makeTrans<gmtl::Point3f>(wand_matrix);



glPushMatrix();

    glMultMatrixf(mouve.mData);
    

 glMultMatrixf(mouve.mData);
   glRotatef(50.0f,0.0f,1.0f,0.0);
   glRotatef(90.0f,1.0f,0.0f,0.0);
   glScalef(0.07f,0.07f,0.07f);
   ahla->draw_model();
   glTranslatef(tr[0],tr[1],tr[2]);
   object->draw_bbox();
glPopMatrix();



The problem we do the selection 
how solve this


Carsten Neumann

unread,
May 5, 2014, 5:50:26 PM5/5/14
to vrjuggler...@googlegroups.com
Hello Mohamed,

On 2014-05-05 22:23, mohamed mediouni wrote:
> Thank you for response
> II followed your approach,
> I can move one object now
> if I click on button button on Joystick, the object moves according to
> the position Joystick

ok, glad to hear it.

> The problem we do the selection
> how solve this

Hmm, I thought you had that working before? There are many ways to
present the selection to the user. A often used method if you have
tracking is to attach a line to a tracked object and use that to "point"
into your virtual environment. For that you'd calculate the intersection
of the line with your object (or a placeholder geometry, like the
object's bounding box).
In your code you need a way to map from the intersected geometry to the
objects in your scene, mark that one as selected, and then apply the
movement only to the object marked as currently selected.

Cheers,
Carsten

mohamed mediouni

unread,
May 9, 2014, 2:18:13 PM5/9/14
to vrjuggler...@googlegroups.com
hi

What is the transition matrix of the real world to the virtual world. I have a problem when i do the intersection beteen the Joystick and Bounding box.
thank you
--mohamed--


Reply all
Reply to author
Forward
0 new messages