Hi,
thank you both for your replies.

Gerrit Voss wrote:
>>> I'm now switching to OpenSG 2.0 and the ComplexSceneManager. What would be 
>>> a good strategy to use a custom device to move around in a scene? Should I 
>>> use the glut functions again? Or is there a better way? If so, where would 
>>> I find the documentation?
>> Unfortunately, I don't understand the details of CSM myself, perhaps 
>> Gerrit (cc'ed) can give you some hints on how to extend or configure it 
>> so that it works with your device.
> 
> I have an idea, give me a second to get a sample implementation. Short
> question, what kind of data are you receiving ?

I'm using two optical mouse infrared sensors which are attached to a 
programmable I/O board (Arduino). The Arduino board is attached to the 
USB bus. I'm receiving information from four coordinates (x and y from 
each sensor), but I'm only using two of them (x from sensor 1 and y from 
sensor 2). Thus, the two sensors combine to a single "virtual mouse". 
I'm using libserial to read out the USB bus. In brief, here is the 
relevant code snippet:

void read_arduino(boost::shared_ptr<SerialPort> dev_file,
                   std::valarray<int>& x1, std::valarray<int>& y1,
                   std::valarray<int>& x2, std::valarray<int>& y2)
{
     std::string l = dev_file->ReadLine();

     /* assert that the string contains 6 bytes (X1, Y1, X2, Y2, '\r', 
'\n') */
     if (l.length() == 6) {

         /* Read 4 bytes, convert to integers */
         x1[1] = int(l[0]); /* X Sensor 1 */
         y1[1] = int(l[1]); /* Y Sensor 1 */
         x2[1] = int(l[2]); /* X Sensor 2 */
         y2[1] = int(l[3]); /* Y Sensor 2 */

         /* store coordinates for next plot */
         x1[0]=x1[1];
         y1[0]=y1[1];
         x2[0]=x2[1];
         y2[0]=y2[1];
     }
}

I could easily change the output of the I/O board if that would make 
integration into OpenSG easier. I've started to modify the 
OSGCSMTrackball class so that it reads the custom device rather than the 
regular mouse in OSGCSMTrackball::changed. However, the problem is that 
OSGCSMTrackball::changed is only called upon events from the regular 
mouse, but not when the custom device is active.

I greatly appreciate your help,
Christoph



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to