Remove leapmotion, it's outdated and unsupported.

master
Nicky 2016-01-06 13:59:08 +01:00
parent a6ea90197a
commit 4ffd74e025
19 changed files with 2 additions and 2022 deletions

View File

@ -136,54 +136,6 @@
</map>
</map>
</map>
<key>leap-motion</key>
<map>
<key>license</key>
<string>leap-motion</string>
<key>license_file</key>
<string>LICENSES/leap-motion.txt</string>
<key>name</key>
<string>leap-motion</string>
<key>platforms</key>
<map>
<key>darwin</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>94fa8329ff292e43a5f5527ed4a05291</string>
<key>url</key>
<string>file:///opt/firestorm/leap_motion-1.0.9+8391-darwin-20131127.tar.bz2</string>
</map>
<key>name</key>
<string>darwin</string>
</map>
<key>linux</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>c71a6149cda34b32103c17ed460cce66</string>
<key>url</key>
<string>file:///opt/firestorm/leap_motion-1.0.9+8391-linux-x64-20131128.tar.bz2</string>
</map>
<key>name</key>
<string>linux</string>
</map>
<key>windows</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>12f025c0b3d76dd3f83d963615b7964b</string>
<key>url</key>
<string>file:///c:/cygwin/opt/firestorm/leap_motion-1.0.9+8391-windows-20131128.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
</map>
</map>
</map>
<key>SDL</key>
<map>

View File

@ -82,7 +82,6 @@ set(cmake_SOURCE_FILES
LLVFS.cmake
LLWindow.cmake
LLXML.cmake
LeapMotion.cmake
# <FS:CR> We'll be fine without you -> LScript.cmake
Linking.cmake
MediaPluginBase.cmake

View File

@ -74,16 +74,6 @@ if(WINDOWS)
endif( NOT ND_BUILD64BIT_ARCH )
endif (FMODEX)
if (LEAPMOTION)
if( NOT ND_BUILD64BIT_ARCH )
set(debug_files ${debug_files} x86/Leapd.dll)
set(release_files ${release_files} x86/Leap.dll)
else( NOT ND_BUILD64BIT_ARCH )
set(debug_files ${debug_files} x64/Leapd.dll)
set(release_files ${release_files} x64/Leap.dll)
endif( NOT ND_BUILD64BIT_ARCH )
endif (LEAPMOTION)
#*******************************
# Copy MS C runtime dlls, required for packaging.
# *TODO - Adapt this to support VC9
@ -209,10 +199,6 @@ elseif(DARWIN)
set(release_files ${release_files} libfmodex.dylib)
endif (FMODEX)
if (LEAPMOTION)
set(release_files ${release_files} libLeap.dylib)
endif (LEAPMOTION)
elseif(LINUX)
# linux is weird, multiple side by side configurations aren't supported
# and we don't seem to have any debug shared libs built yet anyways...
@ -279,14 +265,6 @@ elseif(LINUX)
set(release_files ${release_files} "libfmodex.so")
endif (FMODEX)
if (LEAPMOTION)
if( NOT ND_BUILD64BIT_ARCH )
set(release_files ${release_files} x86/libLeap.so)
else( NOT ND_BUILD64BIT_ARCH )
set(release_files ${release_files} x64/libLeap.so)
endif( NOT ND_BUILD64BIT_ARCH )
endif (LEAPMOTION)
else(WINDOWS)
message(STATUS "WARNING: unrecognized platform for staging 3rd party libs, skipping...")
set(vivox_src_dir "${CMAKE_SOURCE_DIR}/newview/vivox-runtime/i686-linux")

View File

@ -1,36 +0,0 @@
# -*- cmake -*-
include(Linking)
if (INSTALL_PROPRIETARY)
set(LEAPMOTION ON CACHE BOOL "Building with Leap Motion Controller support.")
endif (INSTALL_PROPRIETARY)
if( LEAPMOTION )
if (USESYSTEMLIBS)
# *TODO: Standalone support
else (USESYSTEMLIBS)
include(Prebuilt)
use_prebuilt_binary(leap-motion)
if (DARWIN)
set(LEAP_MOTION_LIBRARY libLeap.dylib)
elseif (WINDOWS)
if (ND_BUILD64BIT_ARCH)
set(LEAP_MOTION_LIBRARY
debug ${LIBS_PREBUILT_DIR}/lib/debug/x64/Leapd.lib
optimized ${LIBS_PREBUILT_DIR}/lib/release/x64/Leap.lib)
else (ND_BUILD64BIT_ARCH)
set(LEAP_MOTION_LIBRARY
debug ${LIBS_PREBUILT_DIR}/lib/debug/x86/Leapd.lib
optimized ${LIBS_PREBUILT_DIR}/lib/release/x86/Leap.lib)
endif (ND_BUILD64BIT_ARCH)
elseif (LINUX)
if (ND_BUILD64BIT_ARCH)
set(LEAP_MOTION_LIBRARY ${LIBS_PREBUILT_DIR}/lib/release/x64/libLeap.so)
else (ND_BUILD64BIT_ARCH)
set(LEAP_MOTION_LIBRARY ${LIBS_PREBUILT_DIR}/lib/release/x86/libLeap.so)
endif (ND_BUILD64BIT_ARCH)
endif()
set(LEAP_MOTION_INCLUDE_DIR ${LIBS_OPEN_DIR}/leap-motion)
endif (USESYSTEMLIBS)
endif( LEAPMOTION )

View File

@ -36,7 +36,6 @@ include(LLUI)
include(LLVFS)
include(LLWindow)
include(LLXML)
include(LeapMotion)
# <FS:CR> Nope -> include(LScript)
include(Linking)
include(NDOF)
@ -72,11 +71,6 @@ if(FMODEX)
include_directories(${FMODEX_INCLUDE_DIR})
endif(FMODEX)
if(LEAPMOTION)
add_definitions(-DUSE_LEAPMOTION=1)
include_directories(${LEAP_MOTION_INCLUDE_DIR})
endif(LEAPMOTION)
include_directories(
${DBUSGLIB_INCLUDE_DIRS}
${JSONCPP_INCLUDE_DIR}
@ -1623,14 +1617,6 @@ set_source_files_properties(
# COMPILE_DEFINITIONS "${VIEWER_CHANNEL_VERSION_DEFINES}" # see BuildVersion.cmake
)
LIST(APPEND viewer_SOURCE_FILES llleapmotioncontroller.cpp)
LIST(APPEND viewer_HEADER_FILES llleapmotioncontroller.h)
if (LEAPMOTION)
LIST(APPEND viewer_SOURCE_FILES fsleaptool.cpp fsleapexampletool.cpp fsleapmaniptool.cpp )
LIST(APPEND viewer_HEADER_FILES fsleaptool.h fsleapexampletool.h fsleapmaniptool.h )
endif (LEAPMOTION)
if (DARWIN)
LIST(APPEND viewer_SOURCE_FILES llappviewermacosx.cpp)
LIST(APPEND viewer_SOURCE_FILES llappviewermacosx-objc.mm)
@ -2144,14 +2130,7 @@ if (WINDOWS)
${SHARED_LIB_STAGING_DIR}/Debug/fmodexL.dll
)
endif (FMODEX)
if (LEAPMOTION)
list(APPEND COPY_INPUT_DEPENDENCIES
${SHARED_LIB_STAGING_DIR}/Release/Leap.dll
${SHARED_LIB_STAGING_DIR}/Debug/Leapd.dll
)
endif (LEAPMOTION)
add_custom_command(
OUTPUT ${CMAKE_CFG_INTDIR}/copy_touched.bat
COMMAND ${PYTHON_EXECUTABLE}
@ -2351,12 +2330,6 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${GROWL_LIBRARY}
)
if (LEAPMOTION)
target_link_libraries(${VIEWER_BINARY_NAME}
${LEAP_MOTION_LIBRARY}
)
endif (LEAPMOTION)
if (WINDOWS)
target_link_libraries(${VIEWER_BINARY_NAME}
${GROWL_LIBRARY}

View File

@ -7526,17 +7526,6 @@
<key>Value</key>
<integer>2</integer>
</map>
<key>LeapMotionTestMode</key>
<map>
<key>Comment</key>
<string>Test mode for Leap Motion gesture controller</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>LeftClickShowMenu</key>
<map>
<key>Comment</key>

View File

@ -1,67 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include <leap-motion/Leap.h>
#include "fsleapexampletool.h"
namespace nd
{
namespace leap
{
std::string ExampleTool::getName()
{
return "Example tool";
}
std::string ExampleTool::getDebugString()
{
std::stringstream strm;
strm << mHands << " hands deteced; " << mFingers << " fingers in total";
return strm.str();
}
S32 ExampleTool::getId()
{
return 111;
}
void ExampleTool::onLeapFrame( Leap::Frame const &aFrame )
{
mHands = aFrame.hands().count();
mFingers = 0;
for( int i = 0; i < mHands; ++ i )
mFingers += aFrame.hands()[ i ].fingers().count();
}
void ExampleTool::onRenderFrame( Leap::Frame const &aFrame )
{
}
void ExampleTool::render()
{
}
}
}

View File

@ -1,55 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#ifndef NDLEAPEXAMPLETOOL_H
#define NDLEAPEXAMPLETOOL_H
#pragma once
#include "fsleaptool.h"
class LLViewerObject;
namespace nd
{
namespace leap
{
class ExampleTool: public Tool
{
int mHands;
int mFingers;
public:
virtual ~ExampleTool(){}
virtual void onLeapFrame( Leap::Frame const& );
virtual void onRenderFrame( Leap::Frame const& );
virtual void render();
virtual std::string getDebugString();
virtual std::string getName();
virtual S32 getId();
};
}
}
#endif

View File

@ -1,572 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include <leap-motion/Leap.h>
#include "fsleapmaniptool.h"
#include "llviewerwindow.h"
#include "llviewerobject.h"
#include "lldrawable.h"
#include "pipeline.h"
#include "llvoavatarself.h"
#include "llviewershadermgr.h"
#include "llselectmgr.h"
namespace nd
{
namespace leap
{
struct Finger
{
Finger( )
{
clear();
}
void clear()
{
memset( this, 0, sizeof( Finger ) );
}
bool isValid( ) const
{ return mTimestamp > 0; }
U64 mId;
U64 mTimestamp;
float mTip[3];
float mDir[3];
float mFromLast[3];
float mLenFromLast;
float mWidth;
float mLength;
U16 mPartner;
LLViewerObject *mSelected;
};
struct Fingers
{
Fingers( )
{
clear();
}
void clear()
{
mTimestamp = 0;
for( int i = 0; i < eMaxFingers; ++i )
mFingers[ i ].clear();
mStoredFingers = 0;
}
Finger* getFinger( U64 aId )
{
for( int i = 0; i < mStoredFingers; ++i )
{
if( aId == mFingers[ i ].mId )
return mFingers + i;
}
return 0;
}
Finger* at( U16 aIndex )
{
return &mFingers[ aIndex ];
}
enum MAXFIGERS { eMaxFingers = 10 };
U64 mTimestamp;
U16 mStoredFingers;
Finger mFingers[eMaxFingers];
};
/* Do the rotation:
| 0 0 -1 | | x |
| -1 0 0 | * | y |
| 0 1 0 | | z |
in this case it's just value flipping.
*/
static LLVector3 toAgentCS( float aX, float aY, float aZ )
{
return LLVector3( -aZ, -aX, aY );
}
static float scaleY( float aIn )
{
return aIn - 150.f;
}
static LLVector3 scaleToSL( LLVector3 const &aIn )
{
return aIn * 1.f/25.f;
}
static void copy( Leap::Vector const &aFrom, float *aTo )
{
aTo[0] = aFrom[0];
aTo[1] = aFrom[1];
aTo[2] = aFrom[2];
}
static float length( float const *aVec )
{
return sqrt( aVec[0]*aVec[0] + aVec[1]*aVec[1] + aVec[2]*aVec[2] );
}
static float normalize( float *aVec )
{
float len = length( aVec );
if( fabs( len ) > 0.0001f )
{
aVec[0] /= len;
aVec[1] /= len;
aVec[2] /= len;
}
else
{
len = aVec[0] = aVec[1] = aVec[2] = 0.f;
}
return len;
}
static float dot( float const *aVec1, float const *aVec2, bool aUnitVectors = true )
{
float alpha = aVec1[0]*aVec2[0] + aVec1[1]*aVec2[1] + aVec1[2]*aVec2[2];
if( !aUnitVectors )
alpha /= ( length( aVec1 )*length(aVec2) );
return acos( alpha );
}
static void subtract( float const *aLeft, float const *aRight, float *aOut )
{
aOut[0] = aLeft[0] - aRight[0];
aOut[1] = aLeft[1] - aRight[1];
aOut[2] = aLeft[2] - aRight[2];
}
static void move( float const *aStart, float const *aDirecton, float aScale, float *aOut )
{
aOut[0] = aStart[0] + aDirecton[0]*aScale;
aOut[1] = aStart[1] + aDirecton[1]*aScale;
aOut[2] = aStart[2] + aDirecton[2]*aScale;
}
ManipTool::ManipTool()
{
mLastExaminedFrame = 0;
mLastStoredFrame = 0;
mNextRenderedFrame = 0;
mTotalStoredFrames = 0;
mFingersPerFrame = new Fingers[ eMaxKeptFrames ];
}
ManipTool::~ManipTool()
{
delete []mFingersPerFrame;
}
std::string ManipTool::getName()
{
return "Manipulation tool";
}
std::string ManipTool::getDebugString()
{
return "";
}
S32 ManipTool::getId()
{
return 11;
}
void ManipTool::clearSelection()
{
//for( std::vector< LLViewerObject* >::iterator itr = mHighlighted.begin(); itr != mHighlighted.end(); ++itr )
//{
// LLViewerObject *pO = *itr;
// LLSelectMgr::getInstance()->unhighlightObjectOnly( pO );
//}
//mHighlighted.clear();
LLSelectMgr::getInstance()->unhighlightAll();
}
void ManipTool::onLeapFrame( Leap::Frame const &aFrame )
{
if( (aFrame.timestamp() - mLastExaminedFrame ) < 16*1000 )
return;
if( aFrame.hands().count() > 2 )
return;
mLastExaminedFrame = aFrame.timestamp();
U16 curFrame = getNextFrameNo( mLastStoredFrame );
Fingers &curFingers = mFingersPerFrame[ curFrame ];
U16 curFinger = 0;
curFingers.clear();
curFingers.mTimestamp = mLastExaminedFrame;
Leap::HandList hands = aFrame.hands();
for( int i = 0; i < hands.count(); ++i )
{
for( int j = 0; j < hands[i].fingers().count(); ++j )
{
Leap::Finger oFinger( hands[i].fingers()[j] );
Finger &oF = curFingers.mFingers[ curFinger++ ];
oF.mId = oFinger.id();
oF.mTimestamp = mLastExaminedFrame;
copy( oFinger.direction(), oF.mDir );
copy( oFinger.tipPosition(), oF.mTip );
oF.mWidth = oFinger.width();
oF.mLength = oFinger.length();
}
}
curFingers.mStoredFingers = curFinger;
if( mTotalStoredFrames > 0 )
{
Fingers &prevFingers = mFingersPerFrame[ mLastStoredFrame ];
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
{
Finger &curFinger = curFingers.mFingers[i];
Finger const *prevFinger = prevFingers.getFinger( curFinger.mId );
if( !prevFinger )
continue;
subtract( curFinger.mTip, prevFinger->mTip, curFinger.mFromLast );
curFinger.mLenFromLast = normalize( curFinger.mFromLast );
}
}
mLastStoredFrame = curFrame;
++mTotalStoredFrames;
}
void ManipTool::onRenderFrame( Leap::Frame const &aFrame )
{
clearSelection();
doSelect( );
}
void ManipTool::findPartner( U16 aIndex )
{
Fingers &curFingers = mFingersPerFrame[ mNextRenderedFrame ];
Finger &curFinger = curFingers.mFingers[ aIndex ];
if( !curFinger.mSelected )
return;
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
{
if( curFingers.mFingers[i].mSelected == curFinger.mSelected )
{
if( !curFingers.mFingers[i].mPartner )
{
curFingers.mFingers[i].mPartner = aIndex;
curFinger.mPartner = i;
}
else
curFinger.mSelected = 0;
break;
}
}
}
void ManipTool::selectWithFinger( U16 aIndex )
{
Finger &oFinger = mFingersPerFrame[ mNextRenderedFrame ].mFingers[ aIndex ];
GLfloat x( oFinger.mTip[0] );
GLfloat y( scaleY( oFinger.mTip[1] ) );
GLfloat z( oFinger.mTip[2] );
LLVector3 oV1( scaleToSL( toAgentCS( x, y, z) ) );
x += oFinger.mDir[0] * oFinger.mLength;
y += oFinger.mDir[1] * oFinger.mLength;
z += oFinger.mDir[2] * oFinger.mLength;
LLVector3 oV2( scaleToSL( toAgentCS( x, y, z ) ) );
oV1 *= gAgentAvatarp->getRotationRegion();
oV2 *= gAgentAvatarp->getRotationRegion();
oV1 += gAgentAvatarp->getPositionAgent( );
oV2 += gAgentAvatarp->getPositionAgent( );
LLVector4a oF1,oF2;
oF1.load3( oV1.mV );
oF2.load3( oV2.mV );
S32 nFace(0);
LLViewerObject *pHit = gPipeline.lineSegmentIntersectInWorld( oF1,oF2, FALSE, TRUE, &nFace );
if( pHit )
oFinger.mSelected = pHit;
findPartner( aIndex );
}
void ManipTool::doSelect()
{
Fingers &curFingers = mFingersPerFrame[ mNextRenderedFrame ];
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
selectWithFinger( i );
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
{
Finger &curFinger = curFingers.mFingers[ i ];
if( curFinger.mPartner < i )
continue;
if( !curFinger.mSelected )
continue;
LLColor4 oCol( 0.f, 0.f, 1.f );
if( curFinger.mPartner )
oCol.set( 0.f, 1.f, 0.f );
LLSelectMgr::getInstance()->highlightObjectOnly( curFinger.mSelected, oCol );
}
}
void ManipTool::renderCone( Finger const &aFinger )
{
GLfloat x( aFinger.mTip[0] );
GLfloat y( scaleY( aFinger.mTip[1] ) );
GLfloat z( aFinger.mTip[2] );
LLVector3 oTip( scaleToSL( toAgentCS( x, y, z ) ) );
float dist = aFinger.mWidth*2;
x -= aFinger.mDir[0] *dist;
y -= aFinger.mDir[1] *dist;
z -= aFinger.mDir[2] *dist;
LLVector3 oM( scaleToSL( toAgentCS( x, y, z) ) );
float r = 0.25;
int slices = 16;
float alpha = (F_PI*2)/slices;
for( int i = 0; i < slices; ++i )
{
GLfloat cx = cos( alpha*i )*r;
GLfloat cy = sin( alpha*i )*r;
GLfloat cx2 = cos( alpha*(i+1) )*r;
GLfloat cy2 = sin( alpha*(i+1) )*r;
LLVector3 oV1( oM );
LLVector3 oV2( oM );
oV1 += LLVector3( 0, cy, -cx );
oV2 += LLVector3( 0, cy2, -cx2 );
gGL.vertex3fv( oTip.mV );
gGL.vertex3fv( oV1.mV );
gGL.vertex3fv( oV1.mV );
gGL.vertex3fv( oV2.mV );
gGL.vertex3fv( oV2.mV );
gGL.vertex3fv( oTip.mV );
}
}
void ManipTool::renderMovementDirection( Finger const &aFinger )
{
float lenDir = aFinger.mLenFromLast;
U16 prevFrame = getPrevFrameNo( mNextRenderedFrame );
Finger *prevFinger = mFingersPerFrame[ prevFrame ].getFinger( aFinger.mId );
while( prevFinger && prevFinger->mTimestamp < aFinger.mTimestamp && (aFinger.mTimestamp - prevFinger->mTimestamp ) < getMaxBacktrackMicroseconds() )
{
float alpha = dot( aFinger.mFromLast, prevFinger->mFromLast );
if( alpha > F_PI/18 )
break;
lenDir += prevFinger->mLenFromLast;
prevFrame = getPrevFrameNo( prevFrame );
prevFinger = mFingersPerFrame[ prevFrame ].getFinger( aFinger.mId );
}
#if 0
float vec[3];
bool haveVec( false );
while( aFinger.mTimestamp > mFingersPerFrame[ prevFrame ].mTimestamp &&
(aFinger.mTimestamp > mFingersPerFrame[ prevFrame ].mTimestamp) < getMaxBacktrackMicroseconds() )
{
Finger *pFinger = mFingersPerFrame[ prevFrame ].getFinger( aFinger.mId );
if( pFinger )
{
if( !haveVec )
{
subtract( aFinger.mTip, pFinger->mTip, vec );
lenDir = normalize( vec );
haveVec = true;
}
else
{
float vec2[3];
subtract( aFinger.mTip, pFinger->mTip, vec2 );
float lenDir2 = normalize( vec );
float alpha = dot( vec, vec2 );
if( alpha > F_PI/18 )
break;
lenDir += lenDir2;
}
}
prevFrame = getPrevFrameNo( prevFrame );
}
#endif
if( lenDir > 0 )
{
GLfloat x( aFinger.mTip[0] );
GLfloat y( scaleY( aFinger.mTip[1] ) );
GLfloat z( aFinger.mTip[2] );
LLVector3 oStart( scaleToSL( toAgentCS( x, y, z ) ) );
x -= aFinger.mFromLast[0] *lenDir;
y -= aFinger.mFromLast[1] *lenDir;
z -= aFinger.mFromLast[2] *lenDir;
LLVector3 oEnd( scaleToSL( toAgentCS( x, y, z) ) );
gGL.vertex3fv( oStart.mV );
gGL.vertex3fv( oEnd.mV );
}
}
void ManipTool::renderMovementAngle( Finger const &aFinger, U16 aIndex )
{
if( !aFinger.mPartner || aFinger.mPartner < aIndex )
return;
U16 prevFrame = getPrevFrameNo( mNextRenderedFrame );
Finger *prevFinger = mFingersPerFrame[ prevFrame ].getFinger( aFinger.mId );
U16 startFrame(mNextRenderedFrame);
while( prevFinger &&
prevFinger->mTimestamp < aFinger.mTimestamp && (aFinger.mTimestamp - prevFinger->mTimestamp ) < getMaxBacktrackMicroseconds() &&
prevFinger->mPartner )
{
startFrame = prevFrame;
prevFrame = getPrevFrameNo( prevFrame );
prevFinger = mFingersPerFrame[ prevFrame ].getFinger( aFinger.mId );
}
if( mNextRenderedFrame == startFrame )
return;
Finger const *startFinger( mFingersPerFrame[ startFrame ].getFinger( aFinger.mId ) );
Finger const *startPartner( mFingersPerFrame[ startFrame ].at( startFinger->mPartner ) );
Finger const *endFinger( &aFinger );
Finger const *endPartner( mFingersPerFrame[ startFrame ].at( endFinger->mPartner ) );
float vecStart[3], vecEnd[3];
subtract( startFinger->mTip, startPartner->mTip, vecStart );
subtract( endFinger->mTip, endPartner->mTip, vecEnd );
float lenStart = normalize( vecStart );
float lenEnd = normalize( vecEnd );
float radius = lenStart>lenEnd?lenStart:lenEnd;
float alpha = dot( vecStart, vecEnd );
float ptStart[3], ptEnd[3];
move( startFinger->mTip, vecStart, radius/2, ptStart );
ptEnd[0] = ptStart[0]*cos(alpha) - ptStart[1]*sin(alpha);
ptEnd[1] = ptStart[1]*cos(alpha) + ptStart[0]*sin(alpha);
ptEnd[2] = ptStart[2];
gGL.vertex3fv( ptStart );
gGL.vertex3fv( ptEnd );
}
void ManipTool::renderFinger( Finger const &aFinger, U16 aIndex )
{
if( aFinger.mPartner )
gGL.diffuseColor4f( 0.f, 1.0f, 0.0f, 1.f);
else if( aFinger.mSelected )
gGL.diffuseColor4f( 0.f, 0.0f, 1.0f, 1.f);
else
gGL.diffuseColor4f( 1.f, 1.0f, 1.0f, 1.f);
renderCone( aFinger );
renderMovementDirection( aFinger );
renderMovementAngle( aFinger, aIndex );
}
void ManipTool::render()
{
LLGLEnable blend(GL_BLEND);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
gGL.begin(LLRender::LINES);
LLQuaternion rot = gAgentAvatarp->getRotationRegion();
LLVector3 pos = gAgentAvatarp->getPositionAgent();
gGL.translatef( pos.mV[0], pos.mV[1], pos.mV[2] );
gGL.multMatrix( (GLfloat*) gAgentAvatarp->getRotationRegion().getMatrix4().mMatrix );
gGL.begin(LLRender::LINES);
Fingers &curFingers = mFingersPerFrame[ mNextRenderedFrame ];
for( U16 i = 0; i < curFingers.mStoredFingers; ++i )
{
Finger &curFinger = curFingers.mFingers[ i ];
renderFinger( curFinger, i );
}
gGL.end();
gGL.popMatrix();
mNextRenderedFrame = mLastStoredFrame;
}
}
}

View File

@ -1,85 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#ifndef NDLEAPMANIPTOOL_H
#define NDLEAPMANIPTOOL_H
#pragma once
#include "fsleaptool.h"
#include <string.h>
class LLViewerObject;
namespace nd
{
namespace leap
{
struct Finger;
struct Fingers;
class ManipTool: public Tool
{
enum EMAXKEPTFRAMES{ eMaxKeptFrames = 120 };
inline U16 getNextFrameNo( U16 aFrame ) const
{ return aFrame==eMaxKeptFrames-1?0:aFrame+1; }
inline U16 getPrevFrameNo( U16 aFrame ) const
{ return aFrame==0?eMaxKeptFrames-1:aFrame-1; }
inline U32 getMaxBacktrackMicroseconds() const
{ return 1500*1000; }
U64 mLastExaminedFrame;
U16 mLastStoredFrame;
U16 mNextRenderedFrame;
U64 mTotalStoredFrames;
Fingers *mFingersPerFrame;
void clearSelection();
void doSelect();
void selectWithFinger( U16 aIndex );
void findPartner( U16 aIndex );
void renderCone( Finger const & );
void renderMovementDirection( Finger const & );
void renderMovementAngle( Finger const &, U16 aIndex );
void renderFinger( Finger const&, U16 aIndex );
public:
ManipTool();
virtual ~ManipTool();
virtual void onLeapFrame( Leap::Frame const& );
virtual void onRenderFrame( Leap::Frame const& );
virtual void render();
virtual std::string getDebugString();
virtual std::string getName();
virtual S32 getId();
};
}
}
#endif

View File

@ -1,38 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "fsleaptool.h"
#include "fsleapexampletool.h"
#include "fsleapmaniptool.h"
nd::leap::Tool* nd::leap::constructTool( S32 aTool )
{
if( 111 == aTool )
return new nd::leap::ExampleTool();
if( 11 == aTool )
return new nd::leap::ManipTool();
return 0;
}

View File

@ -1,57 +0,0 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#ifndef NDLEAPTOOL_H
#define NDLEAPTOOL_H
#pragma once
namespace Leap
{
class HandList;
class Frame;
}
namespace nd
{
namespace leap
{
class Tool
{
public:
virtual ~Tool(){}
virtual void onLeapFrame( Leap::Frame const& ) = 0;
virtual void onRenderFrame( Leap::Frame const& ) = 0;
virtual void render() = 0;
virtual std::string getDebugString() = 0;
virtual std::string getName() = 0;
virtual S32 getId() = 0;
};
Tool *constructTool( S32 aTool );
}
}
#endif

View File

@ -250,7 +250,6 @@
#include "llviewereventrecorder.h"
#include "llleapmotioncontroller.h"
#if HAS_GROWL
#include "growlmanager.h"
#endif
@ -1531,10 +1530,6 @@ bool LLAppViewer::mainLoop()
joystick = LLViewerJoystick::getInstance();
joystick->setNeedsReset(true);
// [FS:CR]
gestureController = LLLeapMotionController::getInstance();
// [/FS:CR]
#ifdef LL_DARWIN
// Ensure that this section of code never gets called again on OS X.
mMainLoopInitialized = true;
@ -1729,10 +1724,6 @@ bool LLAppViewer::mainLoop()
}
}
// [FS:CR] Run any LeapMotion devices
if (gestureController)
gestureController->stepFrame();
pingMainloopTimeout("Main:Sleep");
pauseMainloopTimeout();
@ -1979,8 +1970,6 @@ void LLAppViewer::flushVFSIO()
bool LLAppViewer::cleanup()
{
LLLeapMotionController::getInstance()->cleanup(); // <FS:ND/> shutdown leap support
//ditch LLVOAvatarSelf instance
gAgentAvatarp = NULL;
@ -5976,14 +5965,6 @@ void LLAppViewer::idle()
{
gAgentPilot.moveCamera();
}
// <FS:Zi> Leap Motion flycam
#ifdef USE_LEAPMOTION
else if(gestureController && gestureController->getOverrideCamera())
{
gestureController->moveFlycam();
}
#endif //USE_LEAPMOTION
// </FS:Zi>
else if (LLViewerJoystick::getInstance()->getOverrideCamera())
{
LLViewerJoystick::getInstance()->moveFlycam();

View File

@ -42,7 +42,6 @@ class LLTextureFetch;
class LLWatchdogTimeout;
class LLUpdaterService;
class LLViewerJoystick;
class LLLeapMotionController; // [FS:CR]
extern LLTrace::BlockTimerStatHandle FTM_FRAME;
@ -295,10 +294,6 @@ private:
bool mMainLoopInitialized;
LLViewerJoystick* joystick;
// [FS:CR]
LLLeapMotionController* gestureController;
// [/FS:CR]
bool mSavedFinalSnapshot;
bool mSavePerAccountSettings; // only save per account settings if login succeeded

View File

@ -57,8 +57,6 @@
// void drawBoxOutline(const LLVector3& pos,const LLVector3& size); // llspatialpartition.cpp
// </FS:Zi>
#include "llleapmotioncontroller.h"
static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK;
static U32 sBufferUsage = GL_STREAM_DRAW_ARB;
static U32 sShaderLevel = 0;
@ -1250,11 +1248,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
return;
}
// <FS:ND> Leap motion visualizer
if( avatarp->isSelf() && 1 == pass )
LLLeapMotionController::getInstance()->render();
// <FS:ND>
// <FS:Zi> Add avatar hitbox debug
static LLCachedControl<bool> render_hitbox(gSavedSettings,"DebugRenderHitboxes",false);

View File

@ -1,863 +0,0 @@
/**
* @file llleapmotioncontroller.cpp
* @brief LLLeapMotionController class implementation
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2013, Cinder Roxley <cinder.roxley@phoenixviewer.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llleapmotioncontroller.h"
#ifdef USE_LEAPMOTION
#include "llagent.h"
#include "llagentcamera.h"
#include "llgesturemgr.h"
#include "llmath.h"
#include "llstartup.h"
#include "lltimer.h"
#include "llviewercontrol.h"
#include "fsnearbychathub.h"
#include "fsleaptool.h"
#include <leap-motion/Leap.h>
// <FS:Zi> Leap Motion flycam
#include "llmoveview.h"
#include "llquaternion.h"
#include "llviewercamera.h"
#include "llviewerjoystick.h"
// </FS:Zi>
const F32 LM_DEAD_ZONE = 20.f; // Dead zone in the middle of the space
const F32 LM_ORBIT_RATE_FACTOR = 80.f; // Number for camera orbit magic factor
class LLLMImpl : public Leap::Listener
{
public:
LLLMImpl();
~LLLMImpl();
// LeapMotion callbacks
virtual void onInit(const Leap::Controller&);
virtual void onConnect(const Leap::Controller&);
virtual void onDisconnect(const Leap::Controller&);
virtual void onFrame(const Leap::Controller&);
// Called from viewer main loop
void stepFrame();
Leap::Controller * mLMController; // Leapmotion's object
bool mLMConnected; // true if device is connected
bool mFrameAvailable; // true if there is a new frame of data available
int64_t mCurrentFrameID; // Id of the most recent frame of data
LLTimer mYawTimer; // Avoid turning left / right too fast
// Hacky demo code - send controller data to in-world objects via chat
LLTimer mChatMsgTimer; // Throttle sending LM controller data to region local chat
LLTimer mGestureTimer; // Throttle invoking SL gestures
std::string getDebugString();
void render();
private:
nd::leap::Tool *mTool;
// Various controller modes
void modeFlyingControlTest(Leap::HandList & hands);
void modeStreamDataToSL(Leap::HandList & hands);
void modeGestureDetection1(Leap::HandList & hands);
void modeMoveAndCamTest1(Leap::HandList & hands);
void modeDumpDebugInfo(Leap::HandList & hands);
// <FS:Zi> Leap Motion flycam
public:
// returns true when in leapmotion flycam mode
bool getOverrideCamera();
// called once per frame when in flycam mode
void moveFlycam();
private:
Leap::Vector mHandCenterPos; // point where the hand entered flycam
void modeFlycam(Leap::HandList & hands);
bool mOverrideCamera; // true when in leapmotion flycam mode
LLVector3 mFlycamDelta; // next movement delta for flycam
LLVector3 mFlycamFeatheredDelta; // feathered positional data
LLVector3 mFlycamPos; // current flycam position
LLQuaternion mFlycamInitialRot; // initial flycam rotation
LLVector3 mFlycamRot; // current flycam rotation as vector
LLVector3 mFlycamFeatheredRot; // current feathered rotation as vector
// </FS:Zi>
};
const F32 LLLEAP_YAW_INTERVAL = 0.075f;
// Time between spamming chat messages. Server-side throttle is 200 msgs in 10 seconds
const F32 LLLEAP_CHAT_MSG_INTERVAL = 0.200f; // Send 5/second
const F32 LLLEAP_GESTURE_INTERVAL = 3.f; // 3 seconds in between SL gestures
LLLMImpl::LLLMImpl() : mLMController(NULL)
, mLMConnected(false)
, mFrameAvailable(false)
, mCurrentFrameID(0)
, mOverrideCamera(false) // <FS:Zi> Leap Motion flycam
, mTool(0)
{
mLMController = new Leap::Controller(*this);
mYawTimer.setTimerExpirySec(LLLEAP_YAW_INTERVAL);
mChatMsgTimer.setTimerExpirySec(LLLEAP_CHAT_MSG_INTERVAL);
mGestureTimer.setTimerExpirySec(LLLEAP_GESTURE_INTERVAL);
}
LLLMImpl::~LLLMImpl()
{
delete mLMController;
delete mTool;
}
void LLLMImpl::onInit(const Leap::Controller& controller)
{
LL_INFOS("LeapMotion") << "Initialized" << LL_ENDL;
}
void LLLMImpl::onConnect(const Leap::Controller& controller)
{
LL_INFOS("LeapMotion") << "Connected" << LL_ENDL;
mLMConnected = true;
mCurrentFrameID = 0;
}
void LLLMImpl::onDisconnect(const Leap::Controller& controller)
{
LL_INFOS("LeapMotion") << "Disconnected" << LL_ENDL;
mLMConnected = false;
}
// Callback from Leapmotion code when a new frame is available. It simply
// sets a flag so stepFrame() can pick up new controller data
void LLLMImpl::onFrame(const Leap::Controller& controller)
{
if (mLMConnected)
{
// Get the most recent frame and report some basic information
const Leap::Frame frame = controller.frame();
int64_t frame_id = frame.id();
if (frame_id != mCurrentFrameID)
{ // Just record the ID and set flag indicating data is available
mCurrentFrameID = frame_id;
mFrameAvailable = true;
}
if( mTool )
mTool->onLeapFrame( frame);
}
}
std::string LLLMImpl::getDebugString()
{
if( mTool )
return mTool->getDebugString();
return "";
}
void LLLMImpl::render()
{
if( mTool )
return mTool->render();
}
// This is called every SL viewer frame
void LLLMImpl::stepFrame()
{
if (mLMController
&& mFrameAvailable
&& mLMConnected)
{
mFrameAvailable = false;
// Get the most recent frame and report some basic information
const Leap::Frame frame = mLMController->frame();
Leap::HandList hands = frame.hands();
static LLCachedControl<S32> sControllerMode(gSavedSettings, "LeapMotionTestMode", 0);
if( !mTool || mTool->getId() != sControllerMode )
{
delete mTool;
mTool = nd::leap::constructTool( sControllerMode );
}
if( mTool )
mTool->onRenderFrame( frame );
else
{
switch (sControllerMode)
{
case 1:
modeFlyingControlTest(hands);
break;
case 2:
modeStreamDataToSL(hands);
break;
case 3:
modeGestureDetection1(hands);
break;
case 4:
modeMoveAndCamTest1(hands);
break;
// <FS:Zi> Leap Motion flycam
case 10:
modeFlycam(hands);
break;
// </FS:Zi>
case 411:
modeDumpDebugInfo(hands);
break;
default:
// Do nothing
break;
}
}
}
}
// This controller mode is used to fly the avatar, going up, down, forward and turning.
void LLLMImpl::modeFlyingControlTest(Leap::HandList & hands)
{
static S32 sLMFlyingHysteresis = 0;
S32 numHands = hands.count();
BOOL agent_is_flying = gAgent.getFlying();
if (numHands == 0
&& agent_is_flying
&& sLMFlyingHysteresis > 0)
{
sLMFlyingHysteresis--;
if (sLMFlyingHysteresis == 0)
{
LL_INFOS("LeapMotion") << "LM stop flying - look ma, no hands!" << LL_ENDL;
gAgent.setFlying(FALSE);
}
}
else if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
// Number of fingers controls flying on / off
if (num_fingers == 0 && // To do - add hysteresis or data smoothing?
agent_is_flying)
{
if (sLMFlyingHysteresis > 0)
{
sLMFlyingHysteresis--;
}
else
{
LL_INFOS("LeapMotion") << "LM stop flying" << LL_ENDL;
gAgent.setFlying(FALSE);
}
}
else if (num_fingers > 2 &&
!agent_is_flying)
{
LL_INFOS("LeapMotion") << "LM start flying" << LL_ENDL;
gAgent.setFlying(TRUE);
sLMFlyingHysteresis = 5;
}
// Radius of ball controls forward motion
if (agent_is_flying)
{
if (ball_radius > 110.f)
{ // Open hand, move fast
gAgent.setControlFlags(AGENT_CONTROL_AT_POS | AGENT_CONTROL_FAST_AT);
}
else if (ball_radius > 85.f)
{ // Partially open, move slow
gAgent.setControlFlags(AGENT_CONTROL_AT_POS);
}
else
{ // Closed - stop
gAgent.clearControlFlags(AGENT_CONTROL_AT_POS);
}
// Height of palm controls moving up and down
if (palm_pos.y > 260.f)
{ // Go up fast
gAgent.setControlFlags(AGENT_CONTROL_UP_POS | AGENT_CONTROL_FAST_UP);
}
else if (palm_pos.y > 200.f)
{ // Go up
gAgent.setControlFlags(AGENT_CONTROL_UP_POS);
}
else if (palm_pos.y < 60.f)
{ // Go down fast
gAgent.setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_NEG);
}
else if (palm_pos.y < 120.f)
{ // Go down
gAgent.setControlFlags(AGENT_CONTROL_UP_NEG);
}
else
{ // Clear up / down
gAgent.clearControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_POS | AGENT_CONTROL_UP_NEG);
}
// Palm normal going left / right controls direction
if (mYawTimer.checkExpirationAndReset(LLLEAP_YAW_INTERVAL))
{
if (palm_normal.x > 0.4f)
{ // Go left fast
gAgent.moveYaw(1.f);
}
else if (palm_normal.x < -0.4f)
{ // Go right fast
gAgent.moveYaw(-1.f);
}
}
} // end flying controls
}
}
// This experimental mode sends chat messages into SL on a back channel for LSL scripts
// to intercept with a listen() event. This is experimental and not sustainable for
// a production feature ... many avatars using this would flood the chat system and
// hurt server performance. Depending on how useful this proves to be, a better
// mechanism should be designed to stream data from the viewer into SL scripts.
void LLLMImpl::modeStreamDataToSL(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1 &&
mChatMsgTimer.checkExpirationAndReset(LLLEAP_CHAT_MSG_INTERVAL))
{
// Get the first (and only) hand
Leap::Hand hand = hands[0];
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
// Chat message looks like "/2343 LM1,<palm pos>,<palm normal>,<sphere center>,<sphere radius>"
LLVector3 vec;
std::stringstream status_chat_msg;
status_chat_msg << "/2343 LM,";
status_chat_msg << "<" << palm_pos.x << "," << palm_pos.y << "," << palm_pos.z << ">,";
status_chat_msg << "<" << palm_normal.x << "," << palm_normal.y << "," << palm_normal.z << ">,";
status_chat_msg << "<" << ball_center.x << "," << ball_center.y << "," << ball_center.z << ">," << ball_radius;
FSNearbyChat::instance().sendChatFromViewer(status_chat_msg.str(), CHAT_TYPE_SHOUT, FALSE);
}
}
// This mode tries to detect simple hand motion and either triggers an avatar gesture or
// sends a chat message into SL in response. It is very rough, hard-coded for detecting
// a hand wave (a SL gesture) or the wiggling-thumb gun trigger (a chat message sent to a
// special version of the popgun).
void LLLMImpl::modeGestureDetection1(Leap::HandList & hands)
{
static S32 trigger_direction = -1;
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
static S32 last_num_fingers = 0;
if (num_fingers == 1)
{ // One finger ... possibly reset the
Leap::Finger finger = finger_list[0];
Leap::Vector finger_dir = finger.direction();
// Negative Z is into the screen - check that it's the largest component
S32 abs_z_dir = llabs(finger_dir.z);
if (finger_dir.z < -0.5 &&
abs_z_dir > llabs(finger_dir.x) &&
abs_z_dir > llabs(finger_dir.y))
{
Leap::Vector finger_pos = finger.tipPosition();
Leap::Vector finger_vel = finger.tipVelocity();
LL_INFOS("LeapMotion") << "finger direction is " << finger_dir.x << ", " << finger_dir.y << ", " << finger_dir.z
<< ", position " << finger_pos.x << ", " << finger_pos.y << ", " << finger_pos.z
<< ", velocity " << finger_vel.x << ", " << finger_vel.y << ", " << finger_vel.z
<< LL_ENDL;
}
if (trigger_direction != -1)
{
LL_INFOS("LeapMotion") << "Reset trigger_direction - one finger" << LL_ENDL;
trigger_direction = -1;
}
}
else if (num_fingers == 2)
{
Leap::Finger barrel_finger = finger_list[0];
Leap::Vector barrel_finger_dir = barrel_finger.direction();
// Negative Z is into the screen - check that it's the largest component
F32 abs_z_dir = llabs(barrel_finger_dir.z);
if (barrel_finger_dir.z < -0.5f &&
abs_z_dir > llabs(barrel_finger_dir.x) &&
abs_z_dir > llabs(barrel_finger_dir.y))
{
Leap::Finger thumb_finger = finger_list[1];
Leap::Vector thumb_finger_dir = thumb_finger.direction();
Leap::Vector thumb_finger_pos = thumb_finger.tipPosition();
Leap::Vector thumb_finger_vel = thumb_finger.tipVelocity();
if ((thumb_finger_dir.x < barrel_finger_dir.x) )
{ // Trigger gunfire
if (trigger_direction < 0 && // Haven't fired
thumb_finger_vel.x > 50.f && // Moving into screen
thumb_finger_vel.z < -50.f &&
mChatMsgTimer.checkExpirationAndReset(LLLEAP_CHAT_MSG_INTERVAL))
{
// Chat message looks like "/2343 LM2 gunfire"
std::string gesture_chat_msg("/2343 LM2 gunfire");
//LLNearbyChatBar::sendChatFromViewer(gesture_chat_msg, CHAT_TYPE_SHOUT, FALSE);
trigger_direction = 1;
LL_INFOS("LeapMotion") << "Sent gunfire chat" << LL_ENDL;
}
else if (trigger_direction > 0 && // Have fired, need to pull thumb back
thumb_finger_vel.x < -50.f &&
thumb_finger_vel.z > 50.f) // Moving out of screen
{
trigger_direction = -1;
LL_INFOS("LeapMotion") << "Reset trigger_direction" << LL_ENDL;
}
}
}
else if (trigger_direction != -1)
{
LL_INFOS("LeapMotion") << "Reset trigger_direction - hand pos" << LL_ENDL;
trigger_direction = -1;
}
}
else if (num_fingers == 5 &&
num_fingers == last_num_fingers)
{
if (mGestureTimer.checkExpirationAndReset(LLLEAP_GESTURE_INTERVAL))
{
// figure out a gesture to trigger
std::string gestureString("/overhere");
LLGestureMgr::instance().triggerAndReviseString( gestureString );
}
}
last_num_fingers = num_fingers;
}
}
// This mode tries to move the avatar and camera in Second Life. It's pretty rough and needs a lot of work
void LLLMImpl::modeMoveAndCamTest1(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
F32 orbit_rate = 0.f;
Leap::Vector pos(0, 0, 0);
for (size_t i = 0; i < num_fingers; ++i)
{
Leap::Finger finger = finger_list[i];
pos += finger.tipPosition();
}
pos = Leap::Vector(pos.x/num_fingers, pos.y/num_fingers, pos.z/num_fingers);
if (num_fingers == 1)
{ // 1 finger - move avatar
if (pos.x < -LM_DEAD_ZONE)
{ // Move left
gAgent.moveLeftNudge(1.f);
}
else if (pos.x > LM_DEAD_ZONE)
{
gAgent.moveLeftNudge(-1.f);
}
/*
if (pos.z < -LM_DEAD_ZONE)
{
gAgent.moveAtNudge(1.f);
}
else if (pos.z > LM_DEAD_ZONE)
{
gAgent.moveAtNudge(-1.f);
} */
if (pos.y < -LM_DEAD_ZONE)
{
gAgent.moveYaw(-1.f);
}
else if (pos.y > LM_DEAD_ZONE)
{
gAgent.moveYaw(1.f);
}
} // end 1 finger
else if (num_fingers == 2)
{ // 2 fingers - move camera around
// X values run from about -170 to +170
if (pos.x < -LM_DEAD_ZONE)
{ // Camera rotate left
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.x) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitLeftKey(orbit_rate);
}
else if (pos.x > LM_DEAD_ZONE)
{
gAgentCamera.unlockView();
orbit_rate = (pos.x - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitRightKey(orbit_rate);
}
if (pos.z < -LM_DEAD_ZONE)
{ // Camera zoom in
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.z) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitInKey(orbit_rate);
}
else if (pos.z > LM_DEAD_ZONE)
{ // Camera zoom out
gAgentCamera.unlockView();
orbit_rate = (pos.z - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitOutKey(orbit_rate);
}
if (pos.y < -LM_DEAD_ZONE)
{ // Camera zoom in
gAgentCamera.unlockView();
orbit_rate = (llabs(pos.y) - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitUpKey(orbit_rate);
}
else if (pos.y > LM_DEAD_ZONE)
{ // Camera zoom out
gAgentCamera.unlockView();
orbit_rate = (pos.y - LM_DEAD_ZONE) / LM_ORBIT_RATE_FACTOR;
gAgentCamera.setOrbitDownKey(orbit_rate);
}
} // end 2 finger
}
}
// This controller mode just dumps out a bunch of the Leap Motion device data, which can then be
// analyzed for other use.
void LLLMImpl::modeDumpDebugInfo(Leap::HandList & hands)
{
S32 numHands = hands.count();
if (numHands == 1)
{
// Get the first hand
Leap::Hand hand = hands[0];
// Check if the hand has any fingers
Leap::FingerList finger_list = hand.fingers();
S32 num_fingers = finger_list.count();
if (num_fingers >= 1)
{ // Calculate the hand's average finger tip position
Leap::Vector pos(0, 0, 0);
Leap::Vector direction(0, 0, 0);
for (size_t i = 0; i < num_fingers; ++i)
{
Leap::Finger finger = finger_list[i];
pos += finger.tipPosition();
direction += finger.direction();
// Lots of log spam
LL_INFOS("LeapMotion") << "Finger " << i << " string is " << finger.toString() << LL_ENDL;
}
pos = Leap::Vector(pos.x/num_fingers, pos.y/num_fingers, pos.z/num_fingers);
direction = Leap::Vector(direction.x/num_fingers, direction.y/num_fingers, direction.z/num_fingers);
LL_INFOS("LeapMotion") << "Hand has " << num_fingers << " fingers with average tip position"
<< " (" << pos.x << ", " << pos.y << ", " << pos.z << ")"
<< " direction (" << direction.x << ", " << direction.y << ", " << direction.z << ")"
<< LL_ENDL;
}
Leap::Vector palm_pos = hand.palmPosition();
Leap::Vector palm_normal = hand.palmNormal();
LL_INFOS("LeapMotion") << "Palm pos " << palm_pos.x
<< ", " << palm_pos.y
<< ", " << palm_pos.z
<< ". Normal: " << palm_normal.x
<< ", " << palm_normal.y
<< ", " << palm_normal.z
<< LL_ENDL;
F32 ball_radius = (F32) hand.sphereRadius();
Leap::Vector ball_center = hand.sphereCenter();
LL_INFOS("LeapMotion") << "Ball pos " << ball_center.x
<< ", " << ball_center.y
<< ", " << ball_center.z
<< ", radius " << ball_radius
<< LL_ENDL;
} // dump_out_data
}
// --------------------------------------------------------------------------------
// The LLLeapMotionController class is a thin public glue layer into the LLLMImpl
// class, which does all the interesting work.
// One controller instance to rule them all
LLLeapMotionController::LLLeapMotionController()
{
mController = new LLLMImpl();
}
LLLeapMotionController::~LLLeapMotionController()
{
cleanup();
}
void LLLeapMotionController::cleanup()
{
delete mController;
mController = NULL;
}
// Called every viewer frame
void LLLeapMotionController::stepFrame()
{
if (mController &&
STATE_STARTED == LLStartUp::getStartupState())
{
mController->stepFrame();
}
}
// <FS:Zi> Leap Motion flycam
bool LLLMImpl::getOverrideCamera()
{
return mOverrideCamera;
}
// This controller mode is used to fly around with the camera
void LLLMImpl::modeFlycam(Leap::HandList& hands)
{
static bool old_joystick_enabled=false;
S32 numHands=hands.count();
if(numHands!=1)
{
if(mOverrideCamera)
{
mOverrideCamera=false;
gSavedSettings.setBOOL("JoystickEnabled",old_joystick_enabled);
gSavedSettings.setBOOL("JoystickFlycamEnabled",false);
LLPanelStandStopFlying::clearStandStopFlyingMode(LLPanelStandStopFlying::SSFM_FLYCAM);
// make sure to keep the camera where we left it when we switch off flycam
LLViewerJoystick::instance().setCameraNeedsUpdate(false);
}
}
else
{
// Get the first hand
Leap::Hand hand=hands[0];
// Check if the hand has at least 3 fingers
Leap::FingerList finger_list=hand.fingers();
S32 num_fingers=finger_list.count();
static F32 y_rot=0.0f;
static F32 z_rot=0.0f;
if(!mOverrideCamera)
{
mOverrideCamera=true;
old_joystick_enabled=gSavedSettings.getBOOL("JoystickEnabled");
gSavedSettings.setBOOL("JoystickEnabled",true);
gSavedSettings.setBOOL("JoystickFlycamEnabled",true);
mFlycamPos=LLViewerCamera::instance().getOrigin();
mFlycamDelta=LLVector3::zero;
mFlycamFeatheredDelta=LLVector3::zero;
mFlycamInitialRot=LLViewerCamera::instance().getQuaternion();
mFlycamRot=LLVector3::zero;
mFlycamFeatheredRot=LLVector3::zero;
y_rot=0.0f;
z_rot=0.0f;
LLPanelStandStopFlying::setStandStopFlyingMode(LLPanelStandStopFlying::SSFM_FLYCAM);
}
Leap::Vector palm_pos=hand.palmPosition();
Leap::Vector palm_normal=hand.palmNormal();
if(num_fingers<3)
{
mFlycamDelta=LLVector3::zero;
mHandCenterPos=hand.palmPosition();
// auto leveling (not quite perfect yet)
mFlycamRot=LLVector3(0.0f,y_rot,z_rot);
}
else
{
F32 delta=palm_pos.z-mHandCenterPos.z;
if(fabsf(delta)>5.0f)
{
mFlycamDelta.mV[VX]=-delta*fabsf(delta)/1000.0f;
}
delta=palm_pos.y-mHandCenterPos.y;
if(fabsf(delta)>5.0f)
{
mFlycamDelta.mV[VZ]=delta*fabsf(delta)/1000.0f;
}
delta=palm_pos.x-mHandCenterPos.x;
if(fabsf(delta)>5.0f)
{
mFlycamDelta.mV[VY]=-delta*fabsf(delta)/1000.0f;
}
y_rot=palm_normal.z*150.0f;
if(fabsf(palm_normal.x)>0.2f)
{
z_rot+=(palm_normal.x*fabsf(palm_normal.x)*50.0f);
}
// palm_normal.z = pitch
// palm_normal.x = roll
mFlycamRot=LLVector3(-palm_normal.x*60.0f,y_rot,z_rot);
}
}
}
void LLLMImpl::moveFlycam()
{
if(!mOverrideCamera)
{
return;
}
// simple feathering of the positional data
mFlycamFeatheredDelta+=(mFlycamDelta-mFlycamFeatheredDelta)/10.0f;
// simple feathering of the rotational data
mFlycamFeatheredRot+=(mFlycamRot-mFlycamFeatheredRot)/10.0f;
LLQuaternion final_flycam_rot=mayaQ(
mFlycamFeatheredRot.mV[VX],
mFlycamFeatheredRot.mV[VY],
mFlycamFeatheredRot.mV[VZ],
LLQuaternion::XYZ
);
final_flycam_rot=final_flycam_rot*mayaQ(
0.0f,
0.0f,
mFlycamFeatheredRot.mV[VZ],
LLQuaternion::XYZ
);
final_flycam_rot=final_flycam_rot*mFlycamInitialRot;
mFlycamPos+=mFlycamFeatheredDelta*final_flycam_rot;
LLViewerCamera::instance().setView(LLViewerCamera::instance().getView());
LLViewerCamera::instance().setOrigin(mFlycamPos);
LLMatrix3 mat(final_flycam_rot);
LLViewerCamera::instance().mXAxis=LLVector3(mat.mMatrix[0]);
LLViewerCamera::instance().mYAxis=LLVector3(mat.mMatrix[1]);
LLViewerCamera::instance().mZAxis=LLVector3(mat.mMatrix[2]);
}
bool LLLeapMotionController::getOverrideCamera()
{
return mController->getOverrideCamera();
}
void LLLeapMotionController::moveFlycam()
{
if(mController->getOverrideCamera())
{
mController->moveFlycam();
}
}
// </FS:Zi>
std::string LLLeapMotionController::getDebugString()
{
if( !mController || STATE_STARTED != LLStartUp::getStartupState())
return "";
return mController->getDebugString();
}
void LLLeapMotionController::render()
{
if( !mController || STATE_STARTED != LLStartUp::getStartupState())
return;
return mController->render();
}
#endif

View File

@ -1,91 +0,0 @@
/**
* @file llleapmotioncontroller.h
* @brief LLLeapMotionController class definition
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLLEAPMOTIONCONTROLLER_H
#define LL_LLLEAPMOTIONCONTROLLER_H
#include "llsingleton.h"
class LLLMImpl;
class LLLeapMotionController : public LLSingleton<LLLeapMotionController>
{
friend class LLSingleton<LLLeapMotionController>;
public:
LLLeapMotionController();
~LLLeapMotionController();
void cleanup();
// Called every viewer frame
void stepFrame();
std::string getDebugString();
void render();
protected:
LLLMImpl * mController;
// <FS:Zi> Leap Motion flycam
public:
// returns true if in leapmotion flycam mode
bool getOverrideCamera();
// Called every viewer frame when in flycam mode
void moveFlycam();
// </FS:Zi>
};
#ifndef USE_LEAPMOTION
inline LLLeapMotionController::LLLeapMotionController()
{
}
inline LLLeapMotionController::~LLLeapMotionController()
{
}
inline void LLLeapMotionController::cleanup()
{
}
inline void LLLeapMotionController::stepFrame()
{
}
inline std::string LLLeapMotionController::getDebugString()
{
return "";
}
inline void LLLeapMotionController::render()
{
}
#endif
#endif // LL_LLLEAPMOTIONCONTROLLER_H

View File

@ -232,7 +232,6 @@
#include "llnetmap.h"
#include "lggcontactsets.h"
#include "llleapmotioncontroller.h"
#include "lltracerecording.h"
//
@ -922,12 +921,6 @@ public:
if( LLImageBase::getAllocationErrors() )
addText( xpos, ypos, llformat( "# textures discarded due to insufficient memory %ld", LLImageBase::getAllocationErrors() ) );
// </FS:ND>
// <FS:ND> Add some fancy leap debug text
std::string strLeapDebug( LLLeapMotionController::getInstance()->getDebugString() );
if( strLeapDebug.size() )
addText( xpos, ypos, strLeapDebug );
// </FS:ND>
}
void draw()

View File

@ -17,7 +17,6 @@ FALSE=1
# <string>-DINSTALL_PROPRIETARY=FALSE</string>
# <string>-DUSE_KDU=TRUE</string>
# <string>-DFMODEX:BOOL=ON</string>
# <string>-DLEAPMOTION:BOOL=OFF</string>
# <string>-DOPENSIM:BOOL=ON</string>
# <string>-DUSE_AVX_OPTIMIZATION:BOOL=OFF</string>
# <string>-DLL_TESTS:BOOL=OFF</string>
@ -34,7 +33,6 @@ WANTS_PACKAGE=$FALSE
WANTS_VERSION=$FALSE
WANTS_KDU=$FALSE
WANTS_FMODEX=$FALSE
WANTS_LEAPMOTION=$FALSE
WANTS_OPENSIM=$TRUE
WANTS_AVX=$FALSE
WANTS_BUILD=$FALSE
@ -99,7 +97,6 @@ getArgs()
;;
kdu) WANTS_KDU=$TRUE;;
fmodex) WANTS_FMODEX=$TRUE;;
leapmotion) WANTS_LEAPMOTION=$TRUE;;
opensim) WANTS_OPENSIM=$TRUE;;
no-opensim) WANTS_OPENSIM=$FALSE;;
avx) WANTS_AVX=$TRUE;;
@ -276,7 +273,6 @@ echo -e "configure_firestorm.py" > $LOG
echo -e " PLATFORM: '$PLATFORM'" | tee -a $LOG
echo -e " KDU: `b2a $WANTS_KDU`" | tee -a $LOG
echo -e " FMODEX: `b2a $WANTS_FMODEX`" | tee -a $LOG
echo -e " LEAPMOTION: `b2a $WANTS_LEAPMOTION`" | tee -a $LOG
echo -e " OPENSIM: `b2a $WANTS_OPENSIM`" | tee -a $LOG
echo -e " AVX: `b2a $WANTS_AVX` " | tee -a $LOG
echo -e " PACKAGE: `b2a $WANTS_PACKAGE`" | tee -a $LOG
@ -374,11 +370,6 @@ if [ $WANTS_CONFIG -eq $TRUE ] ; then
else
FMODEX="-DFMODEX:BOOL=OFF"
fi
if [ $WANTS_LEAPMOTION -eq $TRUE ] ; then
LEAPMOTION="-DLEAPMOTION:BOOL=ON"
else
LEAPMOTION="-DLEAPMOTION:BOOL=OFF"
fi
if [ $WANTS_OPENSIM -eq $TRUE ] ; then
OPENSIM="-DOPENSIM:BOOL=ON"
else
@ -444,7 +435,7 @@ if [ $WANTS_CONFIG -eq $TRUE ] ; then
UNATTENDED="-DUNATTENDED=ON"
fi
cmake -G "$TARGET" ../indra $CHANNEL $FMODEX $KDU $LEAPMOTION $OPENSIM $AVX_OPTIMIZATION $PACKAGE $UNATTENDED -DLL_TESTS:BOOL=OFF -DWORD_SIZE:STRING=$WORD_SIZE -DCMAKE_BUILD_TYPE:STRING=$BTYPE \
cmake -G "$TARGET" ../indra $CHANNEL $FMODEX $KDU $OPENSIM $AVX_OPTIMIZATION $PACKAGE $UNATTENDED -DLL_TESTS:BOOL=OFF -DWORD_SIZE:STRING=$WORD_SIZE -DCMAKE_BUILD_TYPE:STRING=$BTYPE \
-DNDTARGET_ARCH:STRING="${TARGET_ARCH}" -DROOT_PROJECT_NAME:STRING=Firestorm $LL_ARGS_PASSTHRU | tee $LOG
if [ $PLATFORM == "win32" ] ; then