00001 /* ======================================================================== 00002 * Copyright (c) 2006, 00003 * Institute for Computer Graphics and Vision 00004 * Graz University of Technology 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are 00009 * met: 00010 * 00011 * Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the distribution. 00017 * 00018 * Neither the name of the Graz University of Technology nor the names of 00019 * its contributors may be used to endorse or promote products derived from 00020 * this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00023 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00024 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00025 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00026 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * ======================================================================== 00034 * PROJECT: OpenTracker 00035 * ======================================================================== */ 00042 /* ======================================================================= */ 00043 00080 #ifndef _GOGOSINKSOURCE_H 00081 #define _GOGOSINKSOURCE_H 00082 00083 #include "../OpenTracker.h" 00084 #include "../common/ConsoleSource.h" 00085 00086 #ifdef USE_GOGO 00087 00088 // assign nodekit buttons 00089 #define OTCOM_NONE 0 00090 #define OTCOM_RESETPOSITION 1 00091 #define OTCOM_RESETROTATION 2 00092 #define OTCOM_TOGGLE_ROTATECAMERAAXIS 3 00093 00094 00095 00096 00097 namespace ot { 00098 00104 class OPENTRACKER_API GoGoSinkSource : public Node 00105 { 00106 // Members 00107 public: 00109 Event event; 00110 00111 // Methods 00112 public: 00114 GoGoSinkSource() : Node() 00115 { 00116 for(int i(0);i<3;i++) 00117 { 00118 viewerLocationPos[i] = 0.f; 00119 relativeInputPos[i] = 0.f; 00120 tmpEventPos[i] = 0.f; 00121 viewerLocationOri[i] = 0.f; 00122 relativeInputOri[i] = 0.f; 00123 tmpEventOri[i] = 0.f; 00124 } 00125 viewerLocationOri[3] = 1.f; 00126 relativeInputOri[3] = 1.f; 00127 tmpEventOri[3] = 1.f; 00128 00129 tmpEventCursorDistance=0.f; 00130 tmpEventScalingFactor=0.f; 00131 00132 // default values 00133 tWeightDefault = 0.5f; 00134 rWeightDefault = 0.1f; 00135 00136 tWeight = tWeightDefault; 00137 rWeight = rWeightDefault; 00138 00139 nlDistance = 10; 00140 gogok = 1.0f; //1.0f/6.0f; 00141 //scale = 1.0f; 00142 00143 useAbsRotation = true; 00144 }; 00145 00149 virtual int isEventGenerator() 00150 { 00151 return 1; 00152 } 00153 00155 void push(); 00156 00157 virtual void onEventGenerated( Event& event, Node& generator); 00158 00159 protected: 00160 // SpaceMouse Cursor-specific variables 00161 bool useAbsRotation; 00162 00163 // Incoming events providing data for calculations 00164 float viewerLocationPos[3]; 00165 float relativeInputPos[3]; 00166 float viewerLocationOri[4]; 00167 float relativeInputOri[4]; 00168 unsigned short relativeInputBut, gogoDeviceKitBut; 00169 00170 // This Event holds the result of the calculation of 00171 // current cursor position and is sent to the observers 00172 float tmpEventPos[3]; 00173 float tmpEventOri[4]; 00174 unsigned short tmpEventBut; 00175 float tmpEventCursorDistance, tmpEventScalingFactor; 00176 00177 // A flag to indicate whether tmpEvent was changed during processing 00178 int changed; 00179 00180 // old event type depricated???User Position 00181 //Event usrpos; 00182 00183 // weights for translation and rotation 00184 float tWeightDefault, rWeightDefault; 00185 float tWeight, rWeight; 00186 00187 // old depricated??? 00188 bool extNode; 00189 00190 // scaling factor 00191 //float scale; 00192 //float cursorDistance; 00193 00194 // parameters for GoGo Interaction 00195 float nlDistance; // distance where non-linear movement starts 00196 float gogok; 00197 // scaling factor for nonlinear movement acceleration 00198 00199 bool newEvent, newKitEvent; 00200 00201 void computeNewLocation(); 00202 void computeGoGoNodeKitEvent(); 00203 00204 friend class GoGoModule; 00205 00206 private: 00207 00208 // indicates that a new event has arrived 00209 00210 00211 }; 00212 00213 } // namespace ot 00214 00215 #endif //USE_GOGO 00216 00217 #endif //_GOGOSINKSOURCE_H
1.4.6