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

P_GrabTool.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: P_GrabTool.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.34 $       $Date: 2019/01/17 21:21:00 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * This is Paul's new Tracker code -- pgrayson@ks.uiuc.edu
00019  *
00020  *
00021  ***************************************************************************/
00022 
00023 #include "P_GrabTool.h"
00024 #include "utilities.h"
00025 #include "Matrix4.h"
00026 
00027 GrabTool::GrabTool(int id, VMDApp *vmdapp, Displayable *disp) 
00028 : Tool(id, vmdapp, disp) {
00029   targetting=0;
00030 }
00031 
00032 void GrabTool::do_event() {
00033   float mypos[3], kick[3]={.5,0,0}; 
00034   float zero[9]={0,0,0, 0,0,0, 0,0,0};
00035   Matrix4 o;
00036 
00037   if (!position()) 
00038     return;
00039 
00040   if (!wasgrabbing && isgrabbing()) {
00041     if (target(TARGET_GRAB, mypos, 0)) {
00042       o = *orientation();
00043       vec_copy(mypos, position());
00044       o.multpoint3d(kick, kick);
00045 
00046       setforcefield(position(), kick, zero);
00047       sendforce();
00048       
00049       targetting = 1;
00050     } else { 
00051       targetting=0;
00052     }
00053   } else if (!isgrabbing() && wasgrabbing && targetting) {
00054     o = *orientation();
00055     vec_copy(mypos, position());
00056     o.multpoint3d(kick, kick);
00057     vec_negate(kick, kick);
00058 
00059     setforcefield(position(), kick, zero);
00060     sendforce();
00061   } else {
00062     forceoff();
00063   }
00064   wasgrabbing = isgrabbing();
00065 }
00066 

Generated on Wed Apr 24 02:43:08 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002