Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

PhoneTracker.C

Go to the documentation of this file.
00001 /***************************************************************************
00002 *cr 
00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 
00004 *cr University of Illinois 
00005 *cr All Rights Reserved 
00006 *cr 
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010 * RCS INFORMATION:
00011 *
00012 * $RCSfile: PhoneTracker.C,v $
00013 * $Author: johns $ $Locker: $ $State: Exp $
00014 * $Revision: 1.6 $ $Date: 2019年01月17日 21:21:01 $
00015 *
00016 ***************************************************************************
00017 * DESCRIPTION:
00018 * Listen for UDP packets from WiFi mobile input devices such 
00019 * as smartphones, tablets, etc.
00020 *
00021 ***************************************************************************/
00022 #if defined(VMDPHONETRACKER)
00023 
00024 #include <stdlib.h> // for getenv(), abs() etc.
00025 #include <string.h>
00026 #include <math.h>
00027 #include "VMDApp.h"
00028 #include "PhoneTracker.h"
00029 #include "Matrix4.h"
00030 #include "Inform.h"
00031 #include "utilities.h"
00032 
00033 /* socket stuff */
00034 #include <stdio.h>
00035 #include <arpa/inet.h>
00036 #include <fcntl.h>
00037 #include <sys/types.h>
00038 #include <unistd.h>
00039 #include <sys/socket.h>
00040 #include <time.h>
00041 #include <netinet/in.h>
00042 
00043 PhoneTracker::PhoneTracker(VMDApp *vmdapp) {
00044 app = vmdapp; // copy VMDApp pointer for use in accessing local spaceball
00045 }
00046 
00047 int PhoneTracker::do_start(const SensorConfig *config) {
00048 if (!config->require_local()) return 0;
00049 if (!config->have_one_sensor()) return 0;
00050 
00051 char *myUSL = stringdup(config->getname());
00052 
00053 printf("Phone USL: '%s'\n", myUSL);
00054 
00055 // set the default translation and rotation increments
00056 // these really need to be made user modifiable at runtime
00057 transInc = 1.0f;
00058 rotInc = 0.01f;
00059 scaleInc = 1.0f;
00060 
00061 // reset the position
00062 moveto(0,0,0);
00063 orient->identity();
00064 
00065 delete [] myUSL;
00066 
00067 return TRUE;
00068 }
00069 
00070 PhoneTracker::~PhoneTracker(void) {
00071 }
00072 
00073 void PhoneTracker::update() {
00074 Matrix4 temp;
00075 
00076 if(!alive()) {
00077 moveto(0,0,0);
00078 orient->identity();
00079 return;
00080 }
00081 
00082 if (app != NULL ) {
00083 float tx, ty, tz, rx, ry, rz;
00084 tx=ty=tz=rx=ry=rz=0.0f;
00085 int buttons=0;
00086 
00087 printf("polling mobile status socket..\n");
00088 app->mobile_get_tracker_status(tx, ty, tz, rx, ry, rz, buttons);
00089 
00090 temp.identity();
00091 temp.rot( ((float)rx)*rotInc, 'x' );
00092 temp.rot( ((float)ry)*rotInc, 'y' );
00093 temp.rot( ((float)rz)*rotInc, 'z' );
00094 temp.multmatrix(*orient);
00095 orient->loadmatrix(temp);
00096 pos[0] += tx * transInc;
00097 pos[1] += ty * transInc;
00098 pos[2] +=-tz * transInc;
00099 }
00100 }
00101 
00102 #endif

Generated on Tue Nov 18 02:47:54 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /